zoukankan      html  css  js  c++  java
  • 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;
    
  • 相关阅读:
    dom event 笔记
    提交安钮 提交一次加了 59秒倒计时
    时间倒计时
    把表单数据封装成json格式 插件可用
    dbgrid显示access备注信息
    stringgird中使用TClientDataSet排序的问题
    【单位矩阵】【杭电OJ1575】
    【矩阵快速幂】【杭电OJ1757】
    【关键路径】【拓扑排序+逆拓扑排序】【转】
    【拓扑排序】【关键路径】
  • 原文地址:https://www.cnblogs.com/del/p/1624159.html
Copyright © 2011-2022 走看看