PathGradientBrush.SetSigmaBellShape 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
根據鐘型曲線在中心色彩和第一個環繞色彩之間建立漸層減少。
多載
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物件。 此程式碼會執行下列動作:
建立圖形路徑,並將矩形加入其中。
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 有多個色彩,則陣列中的第一個色彩會用於結束色彩。 此陣列中指定的色彩是筆刷界限路徑上離散點所使用的色彩。
根據預設,當您從路徑漸層的界限移至中心點時,色彩會逐漸從界限色彩變更為中央色彩。 您可以藉由呼叫此方法,自定義界限和中央色彩的定位和混合。
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應