PathGradientBrush 類別

定義

封裝 Brush 物件,這個物件會使用漸層來填滿 GraphicsPath 物件的內部。 此類別無法獲得繼承。

public ref class PathGradientBrush sealed : System::Drawing::Brush
public sealed class PathGradientBrush : System.Drawing.Brush
type PathGradientBrush = class
    inherit Brush
Public NotInheritable Class PathGradientBrush
Inherits Brush
繼承
PathGradientBrush

範例

下列程式代碼範例示範如何建立 PathGradientBrush。 此範例是專為搭配 Windows Forms 使用而設計,而且需要 PaintEventArgs e,這是 的參數PaintEventHandler

public void FillEllipseWithPathGradient(PaintEventArgs e)
{
    // Create a path that consists of a single ellipse.
    GraphicsPath path = new GraphicsPath();
    path.AddEllipse(0, 0, 140, 70);

    // Use the path to construct a brush.
    PathGradientBrush pthGrBrush = new PathGradientBrush(path);

    // Set the color at the center of the path to blue.
    pthGrBrush.CenterColor = Color.FromArgb(255, 0, 0, 255);

    // Set the color along the entire boundary 
    // of the path to aqua.
    Color[] colors = { Color.FromArgb(255, 0, 255, 255) };
    pthGrBrush.SurroundColors = colors;

    e.Graphics.FillEllipse(pthGrBrush, 0, 0, 140, 70);
}
' Create a path that consists of a single ellipse.
Dim path As New GraphicsPath()
path.AddEllipse(0, 0, 140, 70)

' Use the path to construct a brush.
Dim pthGrBrush As New PathGradientBrush(path)

' Set the color at the center of the path to blue.
pthGrBrush.CenterColor = Color.FromArgb(255, 0, 0, 255)

' Set the color along the entire boundary 
' of the path to aqua.
Dim colors As Color() = {Color.FromArgb(255, 0, 255, 255)}
pthGrBrush.SurroundColors = colors

e.Graphics.FillEllipse(pthGrBrush, 0, 0, 140, 70)

備註

色彩漸層是從路徑中央點到路徑外部界限邊緣的平滑色彩底紋。 混合因數、位置和樣式會影響漸層開始和結束的位置,以及其變更陰影的速度。

路徑漸層筆刷不會遵守 SmoothingMode 用來執行繪圖的物件 Graphics 屬性。 不論平滑模式為何,使用 PathGradientBrush 物件填滿的區域會以相同方式呈現 (別名) 。

注意

在 .NET 6 和更新版本中,只有 Windows 作業系統才支援包含此類型的 System.Drawing.Common 套件。 在跨平臺應用程式中使用此類型會導致編譯時間警告和運行時間例外狀況。 如需詳細資訊,請參閱 僅限 Windows 上支援的 System.Drawing.Common

建構函式

PathGradientBrush(GraphicsPath)

使用指定的路徑來初始化 PathGradientBrush 類別的新執行個體。

PathGradientBrush(Point[])

使用指定的點來初始化 PathGradientBrush 類別的新執行個體。

PathGradientBrush(Point[], WrapMode)

使用指定的點和環繞模式來初始化 PathGradientBrush 類別的新執行個體。

PathGradientBrush(PointF[])

使用指定的點來初始化 PathGradientBrush 類別的新執行個體。

PathGradientBrush(PointF[], WrapMode)

使用指定的點和環繞模式來初始化 PathGradientBrush 類別的新執行個體。

屬性

Blend

取得或設定 Blend,此物件指定定義漸層之自訂減少的位置和因數。

CenterColor

取得或設定路徑漸層中心點的色彩。

CenterPoint

取得或設定路徑漸層的中心點。

FocusScales

取得或設定漸層減少的焦點。

InterpolationColors

取得或設定定義多色線形漸層的 ColorBlend

Rectangle

取得這個 PathGradientBrush 的週框。

SurroundColors

取得或設定色彩陣列,對應至這個 PathGradientBrush 所填滿之路徑中的點。

Transform

取得或設定 Matrix 的複本,這個複本會為此 PathGradientBrush 定義局部幾何轉換。

WrapMode

取得或設定 WrapMode,指示這個 PathGradientBrush 的環繞模式。

方法

Clone()

建立這個 PathGradientBrush 的完全相同複本。

CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。

(繼承來源 MarshalByRefObject)
Dispose()

釋放這個 Brush 物件使用的所有資源。

(繼承來源 Brush)
Dispose(Boolean)

釋放 Brush 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

(繼承來源 Brush)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetLifetimeService()
已淘汰.

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。

(繼承來源 MarshalByRefObject)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
InitializeLifetimeService()
已淘汰.

取得存留期服務物件,以控制這個執行個體的存留期原則。

(繼承來源 MarshalByRefObject)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。

(繼承來源 MarshalByRefObject)
MultiplyTransform(Matrix)

使用筆刷轉換矩陣乘以其他矩陣的乘積來更新筆刷的轉換矩陣。

MultiplyTransform(Matrix, MatrixOrder)

使用筆刷轉換矩陣乘以其他矩陣的乘積來更新筆刷的轉換矩陣。

ResetTransform()

Transform 屬性重設為識別 (Identity)。

RotateTransform(Single)

根據指定的數量來旋轉局部幾何轉換。 這個方法會預先規劃轉換的旋轉。

RotateTransform(Single, MatrixOrder)

依照指定的順序,根據指定的數量來旋轉局部幾何轉換。

ScaleTransform(Single, Single)

以指定的數量,縮放局部的幾何轉換。 這個方法預先規劃轉換的縮放矩陣。

ScaleTransform(Single, Single, MatrixOrder)

依照指定的順序,根據指定的數量來縮放局部幾何轉換。

SetBlendTriangularShape(Single)

使用中心色彩和一個環繞色彩的線型減少來建立漸層。

SetBlendTriangularShape(Single, Single)

使用中心色彩和每個環繞色彩的線型減少來建立漸層。

SetNativeBrush(IntPtr)

在衍生類別中,設定 GDI+ 筆刷對象的參考。

(繼承來源 Brush)
SetSigmaBellShape(Single)

建立從路徑中心開始向外至路徑邊界變更色彩的漸層筆刷。 從一個色彩轉換為另一個色彩是根據鐘型曲線。

SetSigmaBellShape(Single, Single)

建立從路徑中心開始向外至路徑邊界變更色彩的漸層筆刷。 從一個色彩轉換為另一個色彩是根據鐘型曲線。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)
TranslateTransform(Single, Single)

將指定的轉換套用至區域幾何轉換。 這個方法預先規劃轉換的轉換。

TranslateTransform(Single, Single, MatrixOrder)

依照指定的順序將指定的轉換套用至區域幾何轉換。

適用於

另請參閱