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;
    
  • 相关阅读:
    【力扣】两个数组的交集
    【编译原理课程设计】词法分析程序设计
    【力扣14】最长公共前缀
    【力扣20】有效的括号
    【力扣26】删除排序数组中的重复项
    【力扣13】罗马数字转整数
    【力扣9】回文数
    【力扣7】整数反转
    【力扣1】两数之和
    golang micro client 报错500 {"id":"go.micro.client","code":408,"detail":"call timeout: context deadline exceeded","status":"Request Timeout"}
  • 原文地址:https://www.cnblogs.com/del/p/1624159.html
Copyright © 2011-2022 走看看