LinearGradientBrush.SetBlendTriangularShape 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
使用中心色彩和在兩端的單一色彩線形減少來建立線形漸層。
多載
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
指定色彩多快從開始色彩減少到 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
會將位置表示為沿著漸層線距離的比例。 漸層會以線性方式下降至任一端的起始色彩。
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應