PathGradientBrush.SetSigmaBellShape 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
根據鐘形曲線,在中心色與第一個周圍色之間產生漸層衰減。
多載
| 名稱 | Description |
|---|---|
| SetSigmaBellShape(Single) |
建立一個漸層筆刷,從路徑中心向外延伸到路徑邊界變色。 顏色從一種顏色過渡到另一種顏色是基於鐘形曲線。 |
| SetSigmaBellShape(Single, Single) |
建立一個漸層筆刷,從路徑中心向外延伸到路徑邊界變色。 顏色從一種顏色過渡到另一種顏色是基於鐘形曲線。 |
SetSigmaBellShape(Single)
建立一個漸層筆刷,從路徑中心向外延伸到路徑邊界變色。 顏色從一種顏色過渡到另一種顏色是基於鐘形曲線。
public:
void SetSigmaBellShape(float focus);
public void SetSigmaBellShape(float focus);
member this.SetSigmaBellShape : single -> unit
Public Sub SetSigmaBellShape (focus As Single)
參數
- focus
- Single
從 0 到 1 的值,指定從路徑中心到路徑邊界的任意徑向,中心顏色會處於最高強度。 預設值為 1 時,強度最高會放在路徑中心。
範例
如需範例,請參閱 SetSigmaBellShape。
備註
若陣列中 SurroundColors 有多個顏色,則使用陣列中的第一個顏色作為結尾色。 此陣列中指定的顏色是用於筆刷邊界路徑上離散點的顏色。
預設情況下,當你從路徑漸層邊界移動到中心點時,顏色會逐漸從邊界色變成中心色。 你可以透過呼叫這個方法來自訂邊界和中心顏色的位置與混合。
適用於
SetSigmaBellShape(Single, Single)
建立一個漸層筆刷,從路徑中心向外延伸到路徑邊界變色。 顏色從一種顏色過渡到另一種顏色是基於鐘形曲線。
public:
void SetSigmaBellShape(float focus, float scale);
public void SetSigmaBellShape(float focus, float scale);
member this.SetSigmaBellShape : single * single -> unit
Public Sub SetSigmaBellShape (focus As Single, scale As Single)
參數
- focus
- Single
從 0 到 1 的值,指定從路徑中心到路徑邊界的任意徑向,中心顏色會處於最高強度。 預設值為 1 時,強度最高會放在路徑中心。
- scale
- Single
一個從0到1的值,指定中心色與邊界色融合的最大強度。 值為 1 會使中心顏色達到最高可能的強度,且為預設值。
範例
以下程式碼範例是為 Windows Forms 設計,並需要 PaintEventArgse,一個 OnPaint 事件物件。 此程式碼會執行下列動作:
建立圖形路徑並加入一個矩形。
從路徑點(在此例中,點形成矩形,但幾乎可以是任何形狀)建立 a PathGradientBrush 。
將中心顏色設為紅色,周圍顏色設為藍色。
在套用混合變換前,先 PathGradientBrush 將 繪製到 畫面。
用它 SetSigmaBellShape 的方法套用混合轉換到筆刷上。
呼叫 TranslateTransform 移動畫筆矩形的方法,使其不會覆蓋先前繪製到螢幕上的長方形。
將轉換後的畫筆矩形繪製到螢幕上。
請注意,最大中心顏色(紅色)位於路徑中心到路徑邊界的中點。
public:
void SetSigmaBellShapeExample( PaintEventArgs^ e )
{
// Create a graphics path and add a rectangle.
GraphicsPath^ myPath = gcnew GraphicsPath;
Rectangle rect = Rectangle(100,20,100,50);
myPath->AddRectangle( rect );
// Get the path's array of points.
array<PointF>^myPathPointArray = myPath->PathPoints;
// Create a path gradient brush.
PathGradientBrush^ myPGBrush = gcnew PathGradientBrush( myPathPointArray );
// Set the color span.
myPGBrush->CenterColor = Color::Red;
array<Color>^ mySurroundColor = {Color::Blue};
myPGBrush->SurroundColors = mySurroundColor;
// Draw the brush to the screen prior to blend.
e->Graphics->FillRectangle( myPGBrush, 10, 10, 200, 200 );
// Set the Blend factors and transform the brush.
myPGBrush->SetSigmaBellShape( 0.5f, 1.0f );
// Move the brush down by 100 by applying the translate
// transform to the brush.
myPGBrush->TranslateTransform( 0, 100, MatrixOrder::Append );
// Draw the brush to the screen again after setting the
// blend and applying the transform.
e->Graphics->FillRectangle( myPGBrush, 10, 10, 300, 300 );
}
public void SetSigmaBellShapeExample(PaintEventArgs e)
{
// Create a graphics path and add a rectangle.
GraphicsPath myPath = new GraphicsPath();
Rectangle rect = new Rectangle(100, 20, 100, 50);
myPath.AddRectangle(rect);
// Get the path's array of points.
PointF[] myPathPointArray = myPath.PathPoints;
// Create a path gradient brush.
PathGradientBrush myPGBrush = new
PathGradientBrush(myPathPointArray);
// Set the color span.
myPGBrush.CenterColor = Color.Red;
Color[] mySurroundColor = {Color.Blue};
myPGBrush.SurroundColors = mySurroundColor;
// Draw the brush to the screen prior to blend.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200);
// Set the Blend factors and transform the brush.
myPGBrush.SetSigmaBellShape(0.5f, 1.0f);
// Move the brush down by 100 by applying the translate
// transform to the brush.
myPGBrush.TranslateTransform(0, 100, MatrixOrder.Append);
// Draw the brush to the screen again after setting the
// blend and applying the transform.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 300, 300);
}
Public Sub SetSigmaBellShapeExample(ByVal e As PaintEventArgs)
' Create a graphics path and add a rectangle.
Dim myPath As New GraphicsPath
Dim rect As New Rectangle(100, 20, 100, 50)
myPath.AddRectangle(rect)
' Get the path's array of points.
Dim myPathPointArray As PointF() = myPath.PathPoints
' Create a path gradient brush.
Dim myPGBrush As New PathGradientBrush(myPathPointArray)
' Set the color span.
myPGBrush.CenterColor = Color.Red
Dim mySurroundColor As Color() = {Color.Blue}
myPGBrush.SurroundColors = mySurroundColor
' Draw the brush to the screen prior to blend.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 200, 200)
' Set the Blend factors.
myPGBrush.SetSigmaBellShape(0.5F, 1.0F)
' Move the brush down by 100 by applying the translate
' transform to the brush.
myPGBrush.TranslateTransform(0, 100, MatrixOrder.Append)
' Draw the brush to the screen again after setting the
' blend and applying the transform.
e.Graphics.FillRectangle(myPGBrush, 10, 10, 300, 300)
End Sub
備註
若陣列中 SurroundColors 有多個顏色,則使用陣列中的第一個顏色作為結尾色。 此陣列中指定的顏色是用於筆刷邊界路徑上離散點的顏色。
預設情況下,當你從路徑漸層邊界移動到中心點時,顏色會逐漸從邊界色變成中心色。 你可以透過呼叫這個方法來自訂邊界和中心顏色的位置與混合。