LinearGradientBrush.SetBlendTriangularShape 方法

定义

创建具有中心颜色的线性渐变,并在两端创建单个颜色的线性下降。

重载

SetBlendTriangularShape(Single)

创建具有中心颜色的线性渐变,并在两端创建单个颜色的线性下降。

SetBlendTriangularShape(Single, Single)

创建具有中心颜色的线性渐变,并在两端创建单个颜色的线性下降。

SetBlendTriangularShape(Single)

Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs

创建具有中心颜色的线性渐变,并在两端创建单个颜色的线性下降。

public:
 void SetBlendTriangularShape(float focus);
public void SetBlendTriangularShape (float focus);
member this.SetBlendTriangularShape : single -> unit
Public Sub SetBlendTriangularShape (focus As Single)

参数

focus
Single

一个介于 0 到 1 的值,该值指定渐变的中心(渐变仅由结束颜色构成的点)。

示例

有关示例,请参阅 SetBlendTriangularShape

注解

此方法指定一个 focus,即渐变仅由结束颜色构成的点。 focus 参数将一个位置表示为沿渐变线距离的比例。 渐变将线性下降到任一端的起始颜色。

适用于

SetBlendTriangularShape(Single, Single)

Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs
Source:
LinearGradientBrush.cs

创建具有中心颜色的线性渐变,并在两端创建单个颜色的线性下降。

public:
 void SetBlendTriangularShape(float focus, float scale);
public void SetBlendTriangularShape (float focus, float scale);
member this.SetBlendTriangularShape : single * single -> unit
Public Sub SetBlendTriangularShape (focus As Single, scale As Single)

参数

focus
Single

一个介于 0 到 1 的值,该值指定渐变的中心(渐变仅由结束颜色构成的点)。

scale
Single

一个介于 0 到 1 的值,该值指定颜色从起始颜色到 focus(结束颜色)的下降速度

示例

下面的代码示例旨在与 Windows 窗体一起使用,它需要 PaintEventArgseOnPaint 事件对象。 该代码执行以下操作:

  • 创建新的 LinearGradientBrush

  • 使用此画笔向屏幕绘制椭圆,该屏幕具有颜色的线性、从左到右的切换效果。

  • LinearGradientBrush 转换为三角形状,其峰值位于中心。

  • 使用转换后的画笔向屏幕绘制第二个椭圆。

请注意,下椭圆的渐变从蓝色过渡到红色,然后转换回蓝色。

private:
   void SetBlendTriangularShapeExample( PaintEventArgs^ e )
   {
      // Create a LinearGradientBrush.
      Rectangle myRect = Rectangle(20,20,200,100);
      LinearGradientBrush^ myLGBrush = gcnew LinearGradientBrush( myRect,Color::Blue,Color::Red,0.0f,true );

      // Draw an ellipse to the screen using the LinearGradientBrush.
      e->Graphics->FillEllipse( myLGBrush, myRect );

      // Create a triangular shaped brush with the peak at the center
      // of the drawing area.
      myLGBrush->SetBlendTriangularShape( .5f, 1.0f );

      // Use the triangular brush to draw a second ellipse.
      myRect.Y = 150;
      e->Graphics->FillEllipse( myLGBrush, myRect );
   }
private void SetBlendTriangularShapeExample(PaintEventArgs e)
{
             
    // Create a LinearGradientBrush.
    Rectangle myRect = new Rectangle(20, 20, 200, 100);
    LinearGradientBrush myLGBrush = new LinearGradientBrush(
        myRect, Color.Blue, Color.Red,  0.0f, true);
             
    // Draw an ellipse to the screen using the LinearGradientBrush.
    e.Graphics.FillEllipse(myLGBrush, myRect);
             
    // Create a triangular shaped brush with the peak at the center
    // of the drawing area.
    myLGBrush.SetBlendTriangularShape(.5f, 1.0f);
             
    // Use the triangular brush to draw a second ellipse.
    myRect.Y = 150;
    e.Graphics.FillEllipse(myLGBrush, myRect);
}
Public Sub SetBlendTriangularShapeExample(ByVal e As PaintEventArgs)

    ' Create a LinearGradientBrush.
    Dim myRect As New Rectangle(20, 20, 200, 100)
    Dim myLGBrush As New LinearGradientBrush(myRect, Color.Blue, _
    Color.Red, 0.0F, True)

    ' Draw an ellipse to the screen using the LinearGradientBrush.
    e.Graphics.FillEllipse(myLGBrush, myRect)

    ' Create a triangular shaped brush with the peak at the center

    ' of the drawing area.
    myLGBrush.SetBlendTriangularShape(0.5F, 1.0F)

    ' Use the triangular brush to draw a second ellipse.
    myRect.Y = 150
    e.Graphics.FillEllipse(myLGBrush, myRect)
End Sub

注解

此方法指定一个 focus,即渐变仅由结束颜色构成的点。 focus 参数将一个位置表示为沿渐变线距离的比例。 渐变将线性下降到任一端的起始颜色。

适用于