FillMode 列舉

定義

指定如何填滿關閉路徑的內部。

public enum class FillMode
public enum FillMode
type FillMode = 
Public Enum FillMode
繼承
FillMode

欄位

Alternate 0

指定替代的填滿模式。

Winding 1

指定捲曲的填滿模式。

範例

下列範例會建立一個路徑,其中一個開啟的圖形 (弧形) ,另一個封閉圖 (橢圓形) 。 FillPath 方法會根據預設填滿模式填滿路徑,也就是 Alternate。 下圖顯示範常式序代碼的輸出。 請注意,路徑會根據替代) 填滿 (,就像開啟的圖形從結束點到起點的直線關閉一樣。

填滿開啟路徑

下列範例是設計來搭配Windows Forms使用,而且需要 PaintEventArgse ,這是事件處理常式的參數 Paint

GraphicsPath path = new GraphicsPath();

// Add an open figure.
path.AddArc(0, 0, 150, 120, 30, 120);

// Add an intrinsically closed figure.
path.AddEllipse(50, 50, 50, 100);

Pen pen = new Pen(Color.FromArgb(128, 0, 0, 255), 5);
SolidBrush brush = new SolidBrush(Color.Red);

// The fill mode is FillMode.Alternate by default.
e.Graphics.FillPath(brush, path);
e.Graphics.DrawPath(pen, path);
Dim path As New GraphicsPath()

' Add an open figure.
path.AddArc(0, 0, 150, 120, 30, 120)

' Add an intrinsically closed figure.
path.AddEllipse(50, 50, 50, 100)

Dim pen As New Pen(Color.FromArgb(128, 0, 0, 255), 5)
Dim brush As New SolidBrush(Color.Red)

' The fill mode is FillMode.Alternate by default.
e.Graphics.FillPath(brush, path)
e.Graphics.DrawPath(pen, path)

備註

應用程式會使用兩種填滿模式之一來填滿路徑的內部:替代或線圈。 模式會決定如何填滿和裁剪封閉式圖形的內部。

預設模式為 Alternate。 若要判斷替代模式中封閉式圖形的內部,請從路徑中的任何任意起點繪製線條,以明顯地在路徑外繪製某個點。 如果線條跨越奇數的路徑區段,則起點位於封閉區域內,因此是填滿或裁剪區域的一部分。 偶數的交叉表示點不在要填滿或裁剪的區域。 使用線條將最後一個點連接到圖的第一個點,填滿或裁剪開啟的圖形。

線圈模式會考慮每個交集的路徑區段方向。 它會為每個順時針交集新增一個,並針對每個逆時針交集減一個。 如果結果為非零,則會將點視為填滿或裁剪區域內。 零計數表示點位於填滿或裁剪區域之外。

圖表會根據繪製圖形區段的順序,以順時針或逆時針方式計算。

適用於

另請參閱