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

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

根據繪製圖表區段的順序,圖會視為順時針或反時針。

適用於

另請參閱