Share via


LinearGradientBrush.SetBlendTriangularShape 方法

定義

使用中心色彩和在兩端的單一色彩線形減少來建立線形漸層。

多載

SetBlendTriangularShape(Single)

使用中心色彩和在兩端的單一色彩線形減少來建立線形漸層。

SetBlendTriangularShape(Single, Single)

使用中心色彩和在兩端的單一色彩線形減少來建立線形漸層。

SetBlendTriangularShape(Single)

來源:
LinearGradientBrush.cs
來源:
LinearGradientBrush.cs
來源:
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)

來源:
LinearGradientBrush.cs
來源:
LinearGradientBrush.cs
來源:
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

指定色彩多快從開始色彩減少到 focus (結束色彩) 的從 0 到 1 的值。

範例

下列程式代碼範例是設計來搭配 Windows Forms 使用,而且需要 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 會將位置表示為沿著漸層線距離的比例。 漸層會以線性方式下降至任一端的起始色彩。

適用於