LinearGradientBrush.SetBlendTriangularShape 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
建立具有中心色彩的線性漸層,以及兩端單一色彩的線性遞減。
多載
| 名稱 | Description |
|---|---|
| SetBlendTriangularShape(Single) |
建立具有中心色彩的線性漸層,以及兩端單一色彩的線性遞減。 |
| SetBlendTriangularShape(Single, Single) |
建立具有中心色彩的線性漸層,以及兩端單一色彩的線性遞減。 |
SetBlendTriangularShape(Single)
建立具有中心色彩的線性漸層,以及兩端單一色彩的線性遞減。
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)
建立具有中心色彩的線性漸層,以及兩端單一色彩的線性遞減。
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 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 以梯度線上距離的比例表示一個位置。 漸層會線性地從起始顏色的兩側逐漸下降。