Skip to main content

GraphicsPath

Namespace: System.Drawing.Drawing2D

Assembly: System.Drawing.Managed (4.0.0.0)

Represents a series of connected lines and curves. This class cannot be inherited.

public class GraphicsPath : MarshalByRefObject, ICloneable, IDisposable

Constructors

Instance member GraphicsPath()

Initializes a new instance of the GraphicsPath class with a FillMode value of Alternate.

Instance member GraphicsPath(fillMode)

Initializes a new instance of the GraphicsPath class with the specified FillMode enumeration.

NameTypeDescription
fillModeFillModeThe FillMode enumeration that determines how the interior of this GraphicsPath is filled.

Instance member GraphicsPath(pts, types)

Initializes a new instance of the GraphicsPath class with the specified Point array and Byte arrays.

NameTypeDescription
ptsPointF[]An array of Point structures that defines the coordinates of the points that make up this GraphicsPath.
typesByte[]An array of PathPointType enumeration elements that specifies the type of each corresponding point in the pts array.

Instance member GraphicsPath(pts, types, fillMode)

Initializes a new instance of the GraphicsPath class with the specified PointF array and Byte arrays.

NameTypeDescription
ptsPointF[]An array of PointF structures that defines the coordinates of the points that make up this GraphicsPath.
typesByte[]An array of PathPointType enumeration elements that specifies the type of each corresponding point in the pts array.
fillModeFillModeThe FillMode enumeration that determines how the interior of this GraphicsPath is filled.

Instance member GraphicsPath(pts, types)

Initializes a new instance of the GraphicsPath class with the specified PathPointType and Point arrays and with the specified FillMode enumeration element.

NameTypeDescription
ptsPoint[]An array of Point structures that defines the coordinates of the points that make up this GraphicsPath.
typesByte[]An array of PathPointType enumeration elements that specifies the type of each corresponding point in the pts array.

Instance member GraphicsPath(pts, types, fillMode)

Initializes a new instance of the GraphicsPath class with the specified PathPointType and PointF arrays and with the specified FillMode enumeration element.

NameTypeDescription
ptsPoint[]An array of PointF structures that defines the coordinates of the points that make up this GraphicsPath.
typesByte[]An array of PathPointType enumeration elements that specifies the type of each corresponding point in the pts array.
fillModeFillModeThe FillMode enumeration that determines how the interior of this GraphicsPath is filled.

Properties

Instance member FillMode

FillMode: Gets or sets a FillMode enumeration that determines how the interiors of shapes in this GraphicsPath are filled.

Instance member PathData

PathData: Gets a PathData that encapsulates arrays of points (points) and types (types) for this GraphicsPath.

Instance member PathPoints

PointF[]: Gets the points in the path.

Instance member PathTypes

Byte[]: Gets the types of the corresponding points in the PathPoints array.

Instance member PointCount

Int32: Gets the number of elements in the PathPoints or the PathTypes array.

Methods

Instance member AddArc(rect, startAngle, sweepAngle)

Appends an elliptical arc to the current figure.

ParameterTypeDescription
rectRectangleFA RectangleF that represents the rectangular bounds of the ellipse from which the arc is taken.
startAngleSingleThe starting angle of the arc, measured in degrees clockwise from the x-axis.
sweepAngleSingleThe angle between startAngle and the end of the arc.

If there are previous lines or curves in the figure, a line is added to connect the endpoint of the previous segment to the beginning of the arc. The arc is traced along the perimeter of the ellipse bounded by the specified rectangle.The starting point of the arc is determined by measuring clockwise from the x-axis of the ellipse (at the 0-degree angle) by the number of degrees in the start angle.The endpoint is similarly located by measuring clockwise from the starting point by the number of degrees in the sweep angle.If the sweep angle is greater than 360 degrees or less than -360 degrees, the arc is swept by exactly 360 degrees or -360 degrees, respectively.

Instance member AddArc(x, y, width, height, startAngle, sweepAngle)

Appends an elliptical arc to the current figure.

ParameterTypeDescription
xSingleThe x-coordinate of the upper-left corner of the rectangular region that defines the ellipse from which the arc is drawn.
ySingleThe y-coordinate of the upper-left corner of the rectangular region that defines the ellipse from which the arc is drawn.
widthSingleThe width of the rectangular region that defines the ellipse from which the arc is drawn.
heightSingleThe height of the rectangular region that defines the ellipse from which the arc is drawn.
startAngleSingleThe starting angle of the arc, measured in degrees clockwise from the x-axis.
sweepAngleSingleThe angle between startAngle and the end of the arc.

Instance member AddArc(rect, startAngle, sweepAngle)

Appends an elliptical arc to the current figure.

ParameterTypeDescription
rectRectangleA RectangleF that represents the rectangular bounds of the ellipse from which the arc is taken.
startAngleSingleThe starting angle of the arc, measured in degrees clockwise from the x-axis.
sweepAngleSingleThe angle between startAngle and the end of the arc.

If there are previous lines or curves in the figure, a line is added to connect the endpoint of the previous segment to the beginning of the arc. The arc is traced along the perimeter of the ellipse bounded by the specified rectangle.The starting point of the arc is determined by measuring clockwise from the x-axis of the ellipse (at the 0-degree angle) by the number of degrees in the start angle.The endpoint is similarly located by measuring clockwise from the starting point by the number of degrees in the sweep angle.If the sweep angle is greater than 360 degrees or less than -360 degrees, the arc is swept by exactly 360 degrees or -360 degrees, respectively.

Instance member AddArc(x, y, width, height, startAngle, sweepAngle)

Appends an elliptical arc to the current figure.

ParameterTypeDescription
xInt32The x-coordinate of the upper-left corner of the rectangular region that defines the ellipse from which the arc is drawn.
yInt32The y-coordinate of the upper-left corner of the rectangular region that defines the ellipse from which the arc is drawn.
widthInt32The width of the rectangular region that defines the ellipse from which the arc is drawn.
heightInt32The height of the rectangular region that defines the ellipse from which the arc is drawn.
startAngleSingleThe starting angle of the arc, measured in degrees clockwise from the x-axis.
sweepAngleSingleThe angle between startAngle and the end of the arc.

Instance member AddBezier(pt1, pt2, pt3, pt4)

Adds a cubic Bézier curve to the current figure.

ParameterTypeDescription
pt1PointA Point that represents the starting point of the curve.
pt2PointA Point that represents the first control point for the curve.
pt3PointA Point that represents the second control point for the curve.
pt4PointA Point that represents the endpoint of the curve.

The cubic curve is constructed from the first point to the fourth point by using the second and third points as control points. If there is a previous line or curve segment in the figure, a line is added to connect the endpoint of the previous segment to the starting point of the cubic curve.

Instance member AddBezier(x1, y1, x2, y2, x3, y3, x4, y4)

Adds a cubic Bézier curve to the current figure.

ParameterTypeDescription
x1Int32The x-coordinate of the starting point of the curve.
y1Int32The y-coordinate of the starting point of the curve.
x2Int32The x-coordinate of the first control point for the curve.
y2Int32The y-coordinate of the first control point for the curve.
x3Int32The x-coordinate of the second control point for the curve.
y3Int32The y-coordinate of the second control point for the curve.
x4Int32The x-coordinate of the endpoint of the curve.
y4Int32The y-coordinate of the endpoint of the curve.

The cubic curve is constructed from the first point to the fourth point by using the second and third points as control points. If there is a previous line or curve segment in the figure, a line is added to connect the endpoint of the previous segment to the starting point of the cubic curve.

Instance member AddBezier(pt1, pt2, pt3, pt4)

Adds a cubic Bézier curve to the current figure.

ParameterTypeDescription
pt1PointFA PointF that represents the starting point of the curve.
pt2PointFA PointF that represents the first control point for the curve.
pt3PointFA PointF that represents the second control point for the curve.
pt4PointFA PointF that represents the endpoint of the curve.

The cubic curve is constructed from the first point to the fourth point by using the second and third points as control points. If there is a previous line or curve segment in the figure, a line is added to connect the endpoint of the previous segment to the starting point of the cubic curve.

Instance member AddBezier(x1, y1, x2, y2, x3, y3, x4, y4)

Adds a cubic Bézier curve to the current figure.

ParameterTypeDescription
x1SingleThe x-coordinate of the starting point of the curve.
y1SingleThe y-coordinate of the starting point of the curve.
x2SingleThe x-coordinate of the first control point for the curve.
y2SingleThe y-coordinate of the first control point for the curve.
x3SingleThe x-coordinate of the second control point for the curve.
y3SingleThe y-coordinate of the second control point for the curve.
x4SingleThe x-coordinate of the endpoint of the curve.
y4SingleThe y-coordinate of the endpoint of the curve.

The cubic curve is constructed from the first point to the fourth point by using the second and third points as control points. If there is a previous line or curve segment in the figure, a line is added to connect the endpoint of the previous segment to the starting point of the cubic curve.

Instance member AddBeziers(points)

Adds a sequence of connected cubic Bézier curves to the current figure.

ParameterTypeDescription
pointsPoint[]An array of Point structures that represents the points that define the curves.

Instance member AddBeziers(points)

Adds a sequence of connected cubic Bézier curves to the current figure.

ParameterTypeDescription
pointsPointF[]An array of PointF structures that represents the points that define the curves.

Instance member AddClosedCurve(points)

Adds a closed curve to this path. A cardinal spline curve is used because the curve travels through each of the points in the array.

ParameterTypeDescription
pointsPoint[]An array of Point structures that represents the points that define the curve.

Instance member AddClosedCurve(points, tension)

Adds a closed curve to this path. A cardinal spline curve is used because the curve travels through each of the points in the array.

ParameterTypeDescription
pointsPoint[]An array of Point structures that represents the points that define the curve.
tensionSingleA value between from 0 through 1 that specifies the amount that the curve bends between points, with 0 being the smallest curve (sharpest corner) and 1 being the smoothest curve.

Instance member AddClosedCurve(points)

Adds a closed curve to this path. A cardinal spline curve is used because the curve travels through each of the points in the array.

ParameterTypeDescription
pointsPointF[]An array of Point structures that represents the points that define the curve.

Instance member AddClosedCurve(points, tension)

Adds a closed curve to this path. A cardinal spline curve is used because the curve travels through each of the points in the array.

ParameterTypeDescription
pointsPointF[]An array of Point structures that represents the points that define the curve.
tensionSingleA value between from 0 through 1 that specifies the amount that the curve bends between points, with 0 being the smallest curve (sharpest corner) and 1 being the smoothest curve.

Instance member AddCurve(points)

Adds a spline curve to the current figure.

ParameterTypeDescription
pointsPoint[]An array of PointF structures that represents the points that define the curve.

Instance member AddCurve(points)

Adds a spline curve to the current figure.

ParameterTypeDescription
pointsPointF[]An array of PointF structures that represents the points that define the curve.

Instance member AddCurve(points, tension)

Adds a spline curve to the current figure.

ParameterTypeDescription
pointsPoint[]An array of PointF structures that represents the points that define the curve.
tensionSingleA value that specifies the amount that the curve bends between control points. Values greater than 1 produce unpredictable results.

Instance member AddCurve(points, tension)

Adds a spline curve to the current figure.

ParameterTypeDescription
pointsPointF[]An array of PointF structures that represents the points that define the curve.
tensionSingleA value that specifies the amount that the curve bends between control points. Values greater than 1 produce unpredictable results.

Instance member AddCurve(points, offset, numberOfSegments, tension)

Adds a spline curve to the current figure.

ParameterTypeDescription
pointsPoint[]An array of Point structures that represents the points that define the curve.
offsetInt32The index of the element in the points array that is used as the first point in the curve.
numberOfSegmentsInt32The number of segments used to draw the curve. A segment can be thought of as a line connecting two points.
tensionSingleA value that specifies the amount that the curve bends between control points. Values greater than 1 produce unpredictable results.

Instance member AddCurve(points, offset, numberOfSegments, tension)

Adds a spline curve to the current figure.

ParameterTypeDescription
pointsPointF[]An array of PointF structures that represents the points that define the curve.
offsetInt32The index of the element in the points array that is used as the first point in the curve.
numberOfSegmentsInt32The number of segments used to draw the curve. A segment can be thought of as a line connecting two points.
tensionSingleA value that specifies the amount that the curve bends between control points. Values greater than 1 produce unpredictable results.

Instance member AddEllipse(x, y, width, height)

Adds an ellipse to the current path.

ParameterTypeDescription
xSingleThe x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.
ySingleThe y-coordinate of the upper left corner of the bounding rectangle that defines the ellipse.
widthSingleThe width of the bounding rectangle that defines the ellipse.
heightSingleThe height of the bounding rectangle that defines the ellipse.

Instance member AddEllipse(x, y, width, height)

Adds an ellipse to the current path.

ParameterTypeDescription
xInt32The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.
yInt32The y-coordinate of the upper left corner of the bounding rectangle that defines the ellipse.
widthInt32The width of the bounding rectangle that defines the ellipse.
heightInt32The height of the bounding rectangle that defines the ellipse.

Instance member AddEllipse(rect)

Adds an ellipse to the current path.

ParameterTypeDescription
rectRectangleA Rectangle that represents the bounding rectangle that defines the ellipse.

Instance member AddEllipse(rect)

Adds an ellipse to the current path.

ParameterTypeDescription
rectRectangleFA RectangleF that represents the bounding rectangle that defines the ellipse.

Instance member AddLine(x1, y1, x2, y2)

Appends a line segment to this GraphicsPath.

ParameterTypeDescription
x1Int32The x-coordinate of the starting point of the line.
y1Int32The y-coordinate of the starting point of the line.
x2Int32The x-coordinate of the endpoint of the line.
y2Int32The y-coordinate of the endpoint of the line.

Instance member AddLine(x1, y1, x2, y2)

Appends a line segment to this GraphicsPath.

ParameterTypeDescription
x1SingleThe x-coordinate of the starting point of the line.
y1SingleThe y-coordinate of the starting point of the line.
x2SingleThe x-coordinate of the endpoint of the line.
y2SingleThe y-coordinate of the endpoint of the line.

Instance member AddLine(pt1, pt2)

Appends a line segment to this GraphicsPath.

ParameterTypeDescription
pt1PointA Point that represents the starting point of the line.
pt2PointA Point that represents the endpoint of the line.

Instance member AddLine(pt1, pt2)

Appends a line segment to this GraphicsPath.

ParameterTypeDescription
pt1PointFA PointF that represents the starting point of the line.
pt2PointFA PointF that represents the endpoint of the line.

Instance member AddLines(points)

Appends a series of connected line segments to the end of this GraphicsPath.

ParameterTypeDescription
pointsPoint[]An array of Point structures that represents the points that define the line segments to add.

Instance member AddLines(points)

Appends a series of connected line segments to the end of this GraphicsPath.

ParameterTypeDescription
pointsPointF[]An array of PointF structures that represents the points that define the line segments to add.

Instance member AddPath(addingPath, connect)

Appends the specified GraphicsPath to this path.

ParameterTypeDescription
addingPathGraphicsPathThe GraphicsPath to add.
connectBooleanA Boolean value that specifies whether the first figure in the added path is part of the last figure in this path. A value of true specifies that (if possible) the first figure in the added path is part of the last figure in this path. A value of false specifies that the first figure in the added path is separate from the last figure in this path.

Instance member AddPie(rect, startAngle, sweepAngle)

Adds the outline of a pie shape to this path.

ParameterTypeDescription
rectRectangleA Rectangle that represents the bounding rectangle that defines the ellipse from which the pie is drawn.
startAngleSingleThe starting angle for the pie section, measured in degrees clockwise from the x-axis.
sweepAngleSingleThe angle between startAngle and the end of the pie section, measured in degrees clockwise from startAngle .

Instance member AddPie(x, y, width, height, startAngle, sweepAngle)

Adds the outline of a pie shape to this path.

ParameterTypeDescription
xInt32The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie is drawn.
yInt32The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie is drawn.
widthInt32The width of the bounding rectangle that defines the ellipse from which the pie is drawn.
heightInt32The height of the bounding rectangle that defines the ellipse from which the pie is drawn.
startAngleSingleThe starting angle for the pie section, measured in degrees clockwise from the x-axis.
sweepAngleSingleThe angle between startAngle and the end of the pie section, measured in degrees clockwise from startAngle .

Instance member AddPie(x, y, width, height, startAngle, sweepAngle)

Adds the outline of a pie shape to this path.

ParameterTypeDescription
xSingleThe x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie is drawn.
ySingleThe y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie is drawn.
widthSingleThe width of the bounding rectangle that defines the ellipse from which the pie is drawn.
heightSingleThe height of the bounding rectangle that defines the ellipse from which the pie is drawn.
startAngleSingleThe starting angle for the pie section, measured in degrees clockwise from the x-axis.
sweepAngleSingleThe angle between startAngle and the end of the pie section, measured in degrees clockwise from startAngle .

Instance member AddPolygon(points)

Adds a polygon to this path.

ParameterTypeDescription
pointsPoint[]An array of Point structures that defines the polygon to add.

Instance member AddPolygon(points)

Adds a polygon to this path.

ParameterTypeDescription
pointsPointF[]An array of PointF structures that defines the polygon to add.

Instance member AddRectangle(rect)

Adds a rectangle to this path.

ParameterTypeDescription
rectRectangleA Rectangle that represents the rectangle to add.

Instance member AddRectangle(rect)

Adds a rectangle to this path.

ParameterTypeDescription
rectRectangleFA RectangleF that represents the rectangle to add.

Instance member AddRectangles(rects)

Adds a series of rectangles to this path.

ParameterTypeDescription
rectsRectangle[]An array of Rectangle structures that represents the rectangles to add.

Instance member AddRectangles(rects)

Adds a series of rectangles to this path.

ParameterTypeDescription
rectsRectangleF[]An array of RectangleF structures that represents the rectangles to add.

Instance member AddString(s, family, style, emSize, origin, format)

Adds a text string to this path.

ParameterTypeDescription
sStringThe String to add.
familyFontFamilyA FontFamily that represents the name of the font with which the test is drawn.
styleInt32A FontStyle enumeration that represents style information about the text (bold, italic, and so on). This must be cast as an integer.
emSizeSingleThe height of the em square box that bounds the character.
originPointA Point that represents the point where the text starts.
formatStringFormatA StringFormat that specifies text formatting information, such as line spacing and alignment.

Instance member AddString(s, family, style, emSize, origin, format)

Adds a text string to this path.

ParameterTypeDescription
sStringThe String to add.
familyFontFamilyA FontFamily that represents the name of the font with which the test is drawn.
styleInt32A FontStyle enumeration that represents style information about the text (bold, italic, and so on). This must be cast as an integer.
emSizeSingleThe height of the em square box that bounds the character.
originPointFA PointF that represents the point where the text starts.
formatStringFormatA StringFormat that specifies text formatting information, such as line spacing and alignment.

Instance member AddString(s, family, style, emSize, layoutRect, format)

Adds a text string to this path.

ParameterTypeDescription
sStringThe String to add.
familyFontFamilyA FontFamily that represents the name of the font with which the test is drawn.
styleInt32A FontStyle enumeration that represents style information about the text (bold, italic, and so on). This must be cast as an integer.
emSizeSingleThe height of the em square box that bounds the character.
layoutRectRectangleA Rectangle that represents the rectangle that bounds the text.
formatStringFormatA StringFormat that specifies text formatting information, such as line spacing and alignment.

Instance member AddString(s, family, style, emSize, layoutRect, format)

Adds a text string to this path.

ParameterTypeDescription
sStringThe String to add.
familyFontFamilyA FontFamily that represents the name of the font with which the test is drawn.
styleInt32A FontStyle enumeration that represents style information about the text (bold, italic, and so on). This must be cast as an integer.
emSizeSingleThe height of the em square box that bounds the character.
layoutRectRectangleFA RectangleF that represents the rectangle that bounds the text.
formatStringFormatA StringFormat that specifies text formatting information, such as line spacing and alignment.

Instance member ClearMarkers()

Clears all markers from this path.

Instance member Clone()

Returns: Object.

Instance member CloseAllFigures()

Closes all open figures in this path and starts a new figure. It closes each open figure by connecting a line from its endpoint to its starting point.

Instance member CloseFigure()

Closes the current figure and starts a new figure. If the current figure contains a sequence of connected lines and curves, the method closes the loop by connecting a line from the endpoint to the starting point.

Instance member Dispose()

Protected member Finalize()

Finalizes an instance of the GraphicsPath class.

Instance member Flatten()

Converts each curve in this GraphicsPath into a sequence of connected line segments.

Instance member Flatten(matrix)

Converts each curve in this GraphicsPath into a sequence of connected line segments.

ParameterTypeDescription
matrixMatrixA Matrix by which to transform this GraphicsPath before flattening.

Instance member Flatten(matrix, flatness)

Converts each curve in this GraphicsPath into a sequence of connected line segments.

ParameterTypeDescription
matrixMatrixA Matrix by which to transform this GraphicsPath before flattening.
flatnessSingleSpecifies the maximum permitted error between the curve and its flattened approximation. A value of 0.25 is the default. Reducing the flatness value will increase the number of line segments in the approximation.

Instance member GetBounds()

Returns a rectangle that bounds this GraphicsPath.

Returns: RectangleF. RectangleF.

Instance member GetBounds(matrix)

Returns a rectangle that bounds this GraphicsPath.

ParameterTypeDescription
matrixMatrixThe Matrix that specifies a transformation to be applied to this path before the bounding rectangle is calculated. This path is not permanently transformed; the transformation is used only during the process of calculating the bounding rectangle.

Returns: RectangleF. RectangleF.

Instance member GetBounds(matrix, pen)

Returns a rectangle that bounds this GraphicsPath.

ParameterTypeDescription
matrixMatrixThe Matrix that specifies a transformation to be applied to this path before the bounding rectangle is calculated. This path is not permanently transformed; the transformation is used only during the process of calculating the bounding rectangle.
penPenThe Pen with which to draw the GraphicsPath.

Returns: RectangleF. RectangleF.

Instance member GetLastPoint()

Gets the last point in the PathPoints array of this GraphicsPath.

Returns: PointF. PointF.

Instance member IsVisible(point)

Indicates whether the specified point is contained within this GraphicsPath.

ParameterTypeDescription
pointPointA Point that represents the point to test.

Returns: Boolean. Returns true if the specified point is contained within this GraphicsPath; otherwise, false.

Instance member IsVisible(point)

Indicates whether the specified point is contained within this GraphicsPath.

ParameterTypeDescription
pointPointFA PointF that represents the point to test.

Returns: Boolean. Returns true if the specified point is contained within this GraphicsPath; otherwise, false.

Instance member Reset()

Empties the PathPoints and PathTypes arrays and sets the FillMode to Alternate.

Instance member Reverse()

Reverses the order of the points in this GraphicsPath.

Instance member SetMarkers()

Sets a marker on this GraphicsPath.

Instance member StartFigure()

Starts a new figure without closing the current figure. All subsequent points added to the path are added to this new figure.

Instance member Transform(matrix)

Applies a transform matrix to this GraphicsPath.

ParameterTypeDescription
matrixMatrixA Matrix that represents the transformation to apply.

Instance member Widen(pen)

Replaces this GraphicsPath with curves that enclose the area that is filled when this path is drawn by the specified pen.

ParameterTypeDescription
penPenA Pen that specifies the width between the original outline of the path and the new outline this method creates.

Instance member Widen(pen, matrix)

Replaces this GraphicsPath with curves that enclose the area that is filled when this path is drawn by the specified pen.

ParameterTypeDescription
penPenA Pen that specifies the width between the original outline of the path and the new outline this method creates.
matrixMatrixA Matrix that specifies a transform to apply to the path before widening.

Instance member Widen(pen, matrix, flatness)

Replaces this GraphicsPath with curves that enclose the area that is filled when this path is drawn by the specified pen.

ParameterTypeDescription
penPenA Pen that specifies the width between the original outline of the path and the new outline this method creates.
matrixMatrixA Matrix that specifies a transform to apply to the path before widening.
flatnessSingleA value that specifies the flatness for curves.