• GdiPlus[16]: IGPLinearGradientBrush 之 SetBlendBellShape、SetBlendTriangularShape



    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;
    
  • 相关阅读:
    Flash 终将谢幕:微软将于年底( 2020 年 )停止对 Flash 的支持
    分布式id生成方案总结
    如何设计一个亿级网关(API Gateway)?
    服务之间的调用为啥不直接用 HTTP 而用 RPC?
    Dubbo 总结:关于 Dubbo 的重要知识点
    CAP理论解读
    单点登录(SSO)的设计与实现
    入职微软三个月把老板炒了,七个月自己跑路是一种怎样的体验?
    有关链表的小技巧,我都给你总结好了
    排序算法入门之「选择排序」
  • 原文地址:https://www.cnblogs.com/del/p/1624159.html
Copyright © 2020-2023  润新知