GdiPlus[16]: IGPLinearGradientBrush 之 SetBlendBellShape、SetBlendTriangularShape
GdiPlus[16]: IGPLinearGradientBrush 之 SetBlendBellShape、SetBlendTriangularShape
涂孟超 发表于4年前
GdiPlus[16]: IGPLinearGradientBrush 之 SetBlendBellShape、SetBlendTriangularShape
  • 发表于 4年前
  • 阅读 19
  • 收藏 0
  • 点赞 0
  • 评论 0

【腾讯云】新注册用户域名抢购1元起>>>   


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;

 
 
 
 
 

 

 

  
  • 打赏
  • 点赞
  • 收藏
  • 分享
共有 人打赏支持
粉丝 12
博文 2004
码字总数 14107
×
涂孟超
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: