FillMode FillMode FillMode FillMode Enum

定义

指定如何填充闭合路径的内部。Specifies how the interior of a closed path is filled.

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

字段

Alternate Alternate Alternate Alternate 0

指定交替填充模式。Specifies the alternate fill mode.

Winding Winding Winding Winding 1

指定环绕填充模式。Specifies the winding fill mode.

示例

下面的示例创建一个路径, 该路径具有一个开图 (圆弧) 和一个闭合图形 (椭圆)。The following example creates a path that has one open figure (an arc) and one closed figure (an ellipse). FillPath 方法根据默认填充模式 (可选) 填充路径。下图显示了该示例代码的输出。The FillPath method fills the path according to the default fill mode, which is Alternate.The following illustration shows the output of the example code. 请注意, 该路径已填充 (根据备用), 就像从其结束点到起点为止, 闭合图形是闭合的。Note that the path is filled (according to Alternate) as if the open figure were closed by a straight line from its ending point to its starting point.

填充打开路径Fill Open Path

下面的示例旨在与 Windows 窗体一起使用, 并且它需要PaintEventArgs e作为Paint事件处理程序的参数。The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler.

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)

注解

应用程序使用以下两种填充模式之一填充路径的内部: 备用或缠绕。An application fills the interior of a path using one of two fill modes: alternate or winding. 模式确定如何填充和剪裁闭合图形的内部。The mode determines how to fill and clip the interior of a closed figure.

默认模式为备用模式。The default mode is Alternate. 若要确定处于备用模式的闭合图形的内部, 请从路径中的任意起始点绘制一条线条, 使其在路径外明显地指向某个点。To determine the interiors of closed figures in the alternate mode, draw a line from any arbitrary start point in the path to some point obviously outside the path. 如果行与奇数个路径段相交, 则起始点在闭合区域内, 因而是填充或剪辑区域的一部分。If the line crosses an odd number of path segments, the starting point is inside the closed region and is therefore part of the fill or clipping area. 偶数个交叉点表示该点不在要填充或剪裁的区域中。An even number of crossings means that the point is not in an area to be filled or clipped. 通过使用线条将最后一个点连接到图形的第一个点, 对其进行填充或剪裁。An open figure is filled or clipped by using a line to connect the last point to the first point of the figure.

缠绕模式在每个交集处考虑路径段的方向。The Winding mode considers the direction of the path segments at each intersection. 它为每个顺时针交集添加一个, 并为每个逆时针交集减去一个。It adds one for every clockwise intersection, and subtracts one for every counterclockwise intersection. 如果结果为非零值, 则将点视为填充或剪辑区域内。If the result is nonzero, the point is considered inside the fill or clip area. 如果计数为零, 则表示该点位于填充或剪辑区域的外部。A zero count means that the point lies outside the fill or clip area.

根据图形线段的绘制顺序, 将图形视为顺时针或逆时针。A figure is considered clockwise or counterclockwise based on the order in which the segments of the figure are drawn.

适用于

另请参阅