随笔 - 2146  文章 - 97 评论 - 11758 trackbacks - 253


SetBlendBellShape 方法: 创建基于钟形曲线的渐变过渡过程;

SetBlendTriangularShape 方法: 创建一个从中心色向两端单个颜色线性过渡的线性渐变过程.

两个方法好像区别不大.

SetBlendBellShape 测试效果图:



SetBlendTriangularShape 测试效果图:



SetBlendBellShape 测试代码:

uses GdiPlus;

procedure TForm1.FormPaint(Sender: TObject);
var
  Graphics: IGPGraphics;
  Rect: TGPRectF;
  Brush: IGPLinearGradientBrush;
begin
  Graphics := TGPGraphics.Create(Canvas.Handle);
  Rect.Initialize(10, 10, 120, 150);
  Brush := TGPLinearGradientBrush.Create(Rect, $FFFF0000, $FF0000FF, 0);

  Brush.SetBlendBellShape(1);
  Graphics.FillEllipse(Brush, Rect);

  Brush.SetBlendBellShape(0.8);
  Graphics.TranslateTransform(Rect.X + Rect.Width, 0);
  Graphics.FillEllipse(Brush, Rect);
  
  Brush.SetBlendBellShape(0.5);
  Graphics.TranslateTransform(Rect.X + Rect.Width, 0);
  Graphics.FillEllipse(Brush, Rect);

  Brush.SetBlendBellShape(0.2);
  Graphics.TranslateTransform(Rect.X + Rect.Width, 0);
  Graphics.FillEllipse(Brush, Rect);

  Brush.SetBlendBellShape(0);
  Graphics.TranslateTransform(Rect.X + Rect.Width, 0);
  Graphics.FillEllipse(Brush, Rect);

  //
  Graphics.TranslateTransform(-Graphics.Transform.OffsetX, Rect.Y + Rect.Height);

  Brush.SetBlendBellShape(1, 1);
  Graphics.FillEllipse(Brush, Rect);

  Brush.SetBlendBellShape(1, 0.8);
  Graphics.TranslateTransform(Rect.X + Rect.Width, 0);
  Graphics.FillEllipse(Brush, Rect);
  
  Brush.SetBlendBellShape(1, 0.5);
  Graphics.TranslateTransform(Rect.X + Rect.Width, 0);
  Graphics.FillEllipse(Brush, Rect);

  Brush.SetBlendBellShape(1, 0.2);
  Graphics.TranslateTransform(Rect.X + Rect.Width, 0);
  Graphics.FillEllipse(Brush, Rect);

  Brush.SetBlendBellShape(1, 0);
  Graphics.TranslateTransform(Rect.X + Rect.Width, 0);
  Graphics.FillEllipse(Brush, Rect);
end;


SetBlendTriangularShape 测试代码:

uses GdiPlus;

procedure TForm1.FormPaint(Sender: TObject);
var
  Graphics: IGPGraphics;
  Rect: TGPRectF;
  Brush: IGPLinearGradientBrush;
begin
  Graphics := TGPGraphics.Create(Canvas.Handle);
  Rect.Initialize(10, 10, 120, 150);
  Brush := TGPLinearGradientBrush.Create(Rect, $FFFF0000, $FF0000FF, 0);

  Brush.SetBlendBellShape(1);
  Graphics.FillEllipse(Brush, Rect);

  Brush.SetBlendTriangularShape(0.8);
  Graphics.TranslateTransform(Rect.X + Rect.Width, 0);
  Graphics.FillEllipse(Brush, Rect);
  
  Brush.SetBlendTriangularShape(0.5);
  Graphics.TranslateTransform(Rect.X + Rect.Width, 0);
  Graphics.FillEllipse(Brush, Rect);

  Brush.SetBlendTriangularShape(0.2);
  Graphics.TranslateTransform(Rect.X + Rect.Width, 0);
  Graphics.FillEllipse(Brush, Rect);

  Brush.SetBlendTriangularShape(0);
  Graphics.TranslateTransform(Rect.X + Rect.Width, 0);
  Graphics.FillEllipse(Brush, Rect);

  //
  Graphics.TranslateTransform(-Graphics.Transform.OffsetX, Rect.Y + Rect.Height);

  Brush.SetBlendTriangularShape(1, 1);
  Graphics.FillEllipse(Brush, Rect);

  Brush.SetBlendTriangularShape(1, 0.8);
  Graphics.TranslateTransform(Rect.X + Rect.Width, 0);
  Graphics.FillEllipse(Brush, Rect);
  
  Brush.SetBlendTriangularShape(1, 0.5);
  Graphics.TranslateTransform(Rect.X + Rect.Width, 0);
  Graphics.FillEllipse(Brush, Rect);

  Brush.SetBlendTriangularShape(1, 0.2);
  Graphics.TranslateTransform(Rect.X + Rect.Width, 0);
  Graphics.FillEllipse(Brush, Rect);

  Brush.SetBlendTriangularShape(1, 0);
  Graphics.TranslateTransform(Rect.X + Rect.Width, 0);
  Graphics.FillEllipse(Brush, Rect);
end;

posted on 2009-12-14 22:19 万一 阅读(...) 评论(...) 编辑 收藏