LinearGradientBrush.SetBlendTriangularShape 方法

定义

创建一个从中心色向两端单一颜色线性过渡的线性渐变过程。

重载

SetBlendTriangularShape(Single)

创建一个从中心色向两端单一颜色线性过渡的线性渐变过程。

SetBlendTriangularShape(Single, Single)

创建一个从中心色向两端单一颜色线性过渡的线性渐变过程。

SetBlendTriangularShape(Single)

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

创建一个从中心色向两端单一颜色线性过渡的线性渐变过程。

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 窗体,它需要 PaintEventArgse事件OnPaint对象。 此代码执行以下操作:

  • 创建一个新的 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 表示一个位置,表示为沿渐变线的距离的比例。 渐变以线性方式向任一侧的起始颜色下降。

适用于