GraphicsPath

System.Drawing.Drawing2D.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

GraphicsPath()

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

GraphicsPath(fillMode)

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

Name
Type
Description

fillMode

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

GraphicsPath(pts, types)

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

Name
Type
Description

pts

An array of Point structures that defines the coordinates of the points that make up this GraphicsPath.

types

An array of PathPointType enumeration elements that specifies the type of each corresponding point in the pts array.

GraphicsPath(pts, types, fillMode)

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

Name
Type
Description

pts

An array of PointF structures that defines the coordinates of the points that make up this GraphicsPath.

types

An array of PathPointType enumeration elements that specifies the type of each corresponding point in the pts array.

fillMode

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

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.

Name
Type
Description

pts

An array of Point structures that defines the coordinates of the points that make up this GraphicsPath.

types

An array of PathPointType enumeration elements that specifies the type of each corresponding point in the pts array.

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.

Name
Type
Description

pts

An array of PointF structures that defines the coordinates of the points that make up this GraphicsPath.

types

An array of PathPointType enumeration elements that specifies the type of each corresponding point in the pts array.

fillMode

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

Properties

FillMode

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

PathData

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

PathPoints

PointF[]: Gets the points in the path.

PathTypes

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

PointCount

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

Methods

AddArc(rect, startAngle, sweepAngle)

Appends an elliptical arc to the current figure.

Parameter
Type
Description

rect

A RectangleF that represents the rectangular bounds of the ellipse from which the arc is taken.

startAngle

The starting angle of the arc, measured in degrees clockwise from the x-axis.

sweepAngle

The 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.

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

Appends an elliptical arc to the current figure.

Parameter
Type
Description

x

The x-coordinate of the upper-left corner of the rectangular region that defines the ellipse from which the arc is drawn.

y

The y-coordinate of the upper-left corner of the rectangular region that defines the ellipse from which the arc is drawn.

width

The width of the rectangular region that defines the ellipse from which the arc is drawn.

height

The height of the rectangular region that defines the ellipse from which the arc is drawn.

startAngle

The starting angle of the arc, measured in degrees clockwise from the x-axis.

sweepAngle

The angle between startAngle and the end of the arc.

AddArc(rect, startAngle, sweepAngle)

Appends an elliptical arc to the current figure.

Parameter
Type
Description

rect

A RectangleF that represents the rectangular bounds of the ellipse from which the arc is taken.

startAngle

The starting angle of the arc, measured in degrees clockwise from the x-axis.

sweepAngle

The 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.

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

Appends an elliptical arc to the current figure.

Parameter
Type
Description

x

The x-coordinate of the upper-left corner of the rectangular region that defines the ellipse from which the arc is drawn.

y

The y-coordinate of the upper-left corner of the rectangular region that defines the ellipse from which the arc is drawn.

width

The width of the rectangular region that defines the ellipse from which the arc is drawn.

height

The height of the rectangular region that defines the ellipse from which the arc is drawn.

startAngle

The starting angle of the arc, measured in degrees clockwise from the x-axis.

sweepAngle

The angle between startAngle and the end of the arc.

AddBezier(pt1, pt2, pt3, pt4)

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

Parameter
Type
Description

pt1

A Point that represents the starting point of the curve.

pt2

A Point that represents the first control point for the curve.

pt3

A Point that represents the second control point for the curve.

pt4

A 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.

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

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

Parameter
Type
Description

x1

The x-coordinate of the starting point of the curve.

y1

The y-coordinate of the starting point of the curve.

x2

The x-coordinate of the first control point for the curve.

y2

The y-coordinate of the first control point for the curve.

x3

The x-coordinate of the second control point for the curve.

y3

The y-coordinate of the second control point for the curve.

x4

The x-coordinate of the endpoint of the curve.

y4

The 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.

AddBezier(pt1, pt2, pt3, pt4)

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

Parameter
Type
Description

pt1

A PointF that represents the starting point of the curve.

pt2

A PointF that represents the first control point for the curve.

pt3

A PointF that represents the second control point for the curve.

pt4

A 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.

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

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

Parameter
Type
Description

x1

The x-coordinate of the starting point of the curve.

y1

The y-coordinate of the starting point of the curve.

x2

The x-coordinate of the first control point for the curve.

y2

The y-coordinate of the first control point for the curve.

x3

The x-coordinate of the second control point for the curve.

y3

The y-coordinate of the second control point for the curve.

x4

The x-coordinate of the endpoint of the curve.

y4

The 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.

AddBeziers(points)

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

Parameter
Type
Description

points

An array of Point structures that represents the points that define the curves.

AddBeziers(points)

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

Parameter
Type
Description

points

An array of PointF structures that represents the points that define the curves.

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.

Parameter
Type
Description

points

An array of Point structures that represents the points that define the curve.

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.

Parameter
Type
Description

points

An array of Point structures that represents the points that define the curve.

tension

A 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.

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.

Parameter
Type
Description

points

An array of Point structures that represents the points that define the curve.

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.

Parameter
Type
Description

points

An array of Point structures that represents the points that define the curve.

tension

A 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.

AddCurve(points)

Adds a spline curve to the current figure.

Parameter
Type
Description

points

An array of PointF structures that represents the points that define the curve.

AddCurve(points)

Adds a spline curve to the current figure.

Parameter
Type
Description

points

An array of PointF structures that represents the points that define the curve.

AddCurve(points, tension)

Adds a spline curve to the current figure.

Parameter
Type
Description

points

An array of PointF structures that represents the points that define the curve.

tension

A value that specifies the amount that the curve bends between control points. Values greater than 1 produce unpredictable results.

AddCurve(points, tension)

Adds a spline curve to the current figure.

Parameter
Type
Description

points

An array of PointF structures that represents the points that define the curve.

tension

A value that specifies the amount that the curve bends between control points. Values greater than 1 produce unpredictable results.

AddCurve(points, offset, numberOfSegments, tension)

Adds a spline curve to the current figure.

Parameter
Type
Description

points

An array of Point structures that represents the points that define the curve.

offset

The index of the element in the points array that is used as the first point in the curve.

numberOfSegments

The number of segments used to draw the curve. A segment can be thought of as a line connecting two points.

tension

A value that specifies the amount that the curve bends between control points. Values greater than 1 produce unpredictable results.

AddCurve(points, offset, numberOfSegments, tension)

Adds a spline curve to the current figure.

Parameter
Type
Description

points

An array of PointF structures that represents the points that define the curve.

offset

The index of the element in the points array that is used as the first point in the curve.

numberOfSegments

The number of segments used to draw the curve. A segment can be thought of as a line connecting two points.

tension

A value that specifies the amount that the curve bends between control points. Values greater than 1 produce unpredictable results.

AddEllipse(x, y, width, height)

Adds an ellipse to the current path.

Parameter
Type
Description

x

The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.

y

The y-coordinate of the upper left corner of the bounding rectangle that defines the ellipse.

width

The width of the bounding rectangle that defines the ellipse.

height

The height of the bounding rectangle that defines the ellipse.

AddEllipse(x, y, width, height)

Adds an ellipse to the current path.

Parameter
Type
Description

x

The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse.

y

The y-coordinate of the upper left corner of the bounding rectangle that defines the ellipse.

width

The width of the bounding rectangle that defines the ellipse.

height

The height of the bounding rectangle that defines the ellipse.

AddEllipse(rect)

Adds an ellipse to the current path.

Parameter
Type
Description

rect

A Rectangle that represents the bounding rectangle that defines the ellipse.

AddEllipse(rect)

Adds an ellipse to the current path.

Parameter
Type
Description

rect

A RectangleF that represents the bounding rectangle that defines the ellipse.

AddLine(x1, y1, x2, y2)

Appends a line segment to this GraphicsPath.

Parameter
Type
Description

x1

The x-coordinate of the starting point of the line.

y1

The y-coordinate of the starting point of the line.

x2

The x-coordinate of the endpoint of the line.

y2

The y-coordinate of the endpoint of the line.

AddLine(x1, y1, x2, y2)

Appends a line segment to this GraphicsPath.

Parameter
Type
Description

x1

The x-coordinate of the starting point of the line.

y1

The y-coordinate of the starting point of the line.

x2

The x-coordinate of the endpoint of the line.

y2

The y-coordinate of the endpoint of the line.

AddLine(pt1, pt2)

Appends a line segment to this GraphicsPath.

Parameter
Type
Description

pt1

A Point that represents the starting point of the line.

pt2

A Point that represents the endpoint of the line.

AddLine(pt1, pt2)

Appends a line segment to this GraphicsPath.

Parameter
Type
Description

pt1

A PointF that represents the starting point of the line.

pt2

A PointF that represents the endpoint of the line.

AddLines(points)

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

Parameter
Type
Description

points

An array of Point structures that represents the points that define the line segments to add.

AddLines(points)

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

Parameter
Type
Description

points

An array of PointF structures that represents the points that define the line segments to add.

AddPath(addingPath, connect)

Appends the specified GraphicsPath to this path.

Parameter
Type
Description

addingPath

The GraphicsPath to add.

connect

A 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.

AddPie(rect, startAngle, sweepAngle)

Adds the outline of a pie shape to this path.

Parameter
Type
Description

rect

A Rectangle that represents the bounding rectangle that defines the ellipse from which the pie is drawn.

startAngle

The starting angle for the pie section, measured in degrees clockwise from the x-axis.

sweepAngle

The angle between startAngle and the end of the pie section, measured in degrees clockwise from startAngle .

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

Adds the outline of a pie shape to this path.

Parameter
Type
Description

x

The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie is drawn.

y

The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie is drawn.

width

The width of the bounding rectangle that defines the ellipse from which the pie is drawn.

height

The height of the bounding rectangle that defines the ellipse from which the pie is drawn.

startAngle

The starting angle for the pie section, measured in degrees clockwise from the x-axis.

sweepAngle

The angle between startAngle and the end of the pie section, measured in degrees clockwise from startAngle .

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

Adds the outline of a pie shape to this path.

Parameter
Type
Description

x

The x-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie is drawn.

y

The y-coordinate of the upper-left corner of the bounding rectangle that defines the ellipse from which the pie is drawn.

width

The width of the bounding rectangle that defines the ellipse from which the pie is drawn.

height

The height of the bounding rectangle that defines the ellipse from which the pie is drawn.

startAngle

The starting angle for the pie section, measured in degrees clockwise from the x-axis.

sweepAngle

The angle between startAngle and the end of the pie section, measured in degrees clockwise from startAngle .

AddPolygon(points)

Adds a polygon to this path.

Parameter
Type
Description

points

An array of Point structures that defines the polygon to add.

AddPolygon(points)

Adds a polygon to this path.

Parameter
Type
Description

points

An array of PointF structures that defines the polygon to add.

AddRectangle(rect)

Adds a rectangle to this path.

Parameter
Type
Description

rect

A Rectangle that represents the rectangle to add.

AddRectangle(rect)

Adds a rectangle to this path.

Parameter
Type
Description

rect

A RectangleF that represents the rectangle to add.

AddRectangles(rects)

Adds a series of rectangles to this path.

Parameter
Type
Description

rects

An array of Rectangle structures that represents the rectangles to add.

AddRectangles(rects)

Adds a series of rectangles to this path.

Parameter
Type
Description

rects

An array of RectangleF structures that represents the rectangles to add.

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

Adds a text string to this path.

Parameter
Type
Description

s

The String to add.

family

A FontFamily that represents the name of the font with which the test is drawn.

style

A FontStyle enumeration that represents style information about the text (bold, italic, and so on). This must be cast as an integer.

emSize

The height of the em square box that bounds the character.

origin

A Point that represents the point where the text starts.

format

A StringFormat that specifies text formatting information, such as line spacing and alignment.

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

Adds a text string to this path.

Parameter
Type
Description

s

The String to add.

family

A FontFamily that represents the name of the font with which the test is drawn.

style

A FontStyle enumeration that represents style information about the text (bold, italic, and so on). This must be cast as an integer.

emSize

The height of the em square box that bounds the character.

origin

A PointF that represents the point where the text starts.

format

A StringFormat that specifies text formatting information, such as line spacing and alignment.

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

Adds a text string to this path.

Parameter
Type
Description

s

The String to add.

family

A FontFamily that represents the name of the font with which the test is drawn.

style

A FontStyle enumeration that represents style information about the text (bold, italic, and so on). This must be cast as an integer.

emSize

The height of the em square box that bounds the character.

layoutRect

A Rectangle that represents the rectangle that bounds the text.

format

A StringFormat that specifies text formatting information, such as line spacing and alignment.

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

Adds a text string to this path.

Parameter
Type
Description

s

The String to add.

family

A FontFamily that represents the name of the font with which the test is drawn.

style

A FontStyle enumeration that represents style information about the text (bold, italic, and so on). This must be cast as an integer.

emSize

The height of the em square box that bounds the character.

layoutRect

A RectangleF that represents the rectangle that bounds the text.

format

A StringFormat that specifies text formatting information, such as line spacing and alignment.

ClearMarkers()

Clears all markers from this path.

Clone()

Returns: Object.

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.

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.

Dispose()

Finalize()

Finalizes an instance of the GraphicsPath class.

Flatten()

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

Flatten(matrix)

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

Parameter
Type
Description

matrix

A Matrix by which to transform this GraphicsPath before flattening.

Flatten(matrix, flatness)

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

Parameter
Type
Description

matrix

A Matrix by which to transform this GraphicsPath before flattening.

flatness

Specifies 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.

GetBounds()

Returns a rectangle that bounds this GraphicsPath.

Returns: RectangleF. RectangleF.

GetBounds(matrix)

Returns a rectangle that bounds this GraphicsPath.

Parameter
Type
Description

matrix

The 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.

GetBounds(matrix, pen)

Returns a rectangle that bounds this GraphicsPath.

Parameter
Type
Description

matrix

The 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.

pen

The Pen with which to draw the GraphicsPath.

Returns: RectangleF. RectangleF.

GetLastPoint()

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

Returns: PointF. PointF.

IsVisible(point)

Indicates whether the specified point is contained within this GraphicsPath.

Parameter
Type
Description

point

A Point that represents the point to test.

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

IsVisible(point)

Indicates whether the specified point is contained within this GraphicsPath.

Parameter
Type
Description

point

A PointF that represents the point to test.

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

Reset()

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

Reverse()

Reverses the order of the points in this GraphicsPath.

SetMarkers()

Sets a marker on this GraphicsPath.

StartFigure()

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

Transform(matrix)

Applies a transform matrix to this GraphicsPath.

Parameter
Type
Description

matrix

A Matrix that represents the transformation to apply.

Widen(pen)

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

Parameter
Type
Description

pen

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

Widen(pen, matrix)

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

Parameter
Type
Description

pen

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

matrix

A Matrix that specifies a transform to apply to the path before widening.

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.

Parameter
Type
Description

pen

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

matrix

A Matrix that specifies a transform to apply to the path before widening.

flatness

A value that specifies the flatness for curves.

Last updated

Was this helpful?