GraphicsPath

Defines primitives that can be used to draw or fill a path on a Graphics object
Remarks: This is a thin wrapper around the IGraphicsPath interface, which is created via Create().

Constructors

GraphicsPath

#
public GraphicsPath()
Initializes a new instance of the GraphicsPath class

GraphicsPath

#
public GraphicsPath(IGraphicsPath handler)
Initializes a new instance of the GraphicsPath class.

Properties

CurrentPoint

#
public PointF CurrentPoint { get; }
Gets the current point
Remarks: If the current figure in the path is not closed, and StartFigure() is not called, the next segment will be connected from this point to its start point.
The current point
CurrentPoint

FillMode

#
public FillMode FillMode { get; set; }
Sets a value indicating how this graphics path should be filled.

Instantiator

#
public static Func<IGraphicsPath> Instantiator { get; }
obsolete: Use Create() instead
Creates a delegate that can be used to create instances of the IGraphicsPath with little overhead
Remarks: This is useful when creating a very large number of graphics path objects

IsEmpty

#
public bool IsEmpty { get; }
Gets a value indicating that this graphics path is empty and has no segments

Methods

AddArc

#
public void AddArc(float x, float y, float width, float height, float startAngle, float sweepAngle)
Adds an arc into the specified rectangle
Remarks: If the current figure is not closed, it will connect with the start of the arc. The current position will be moved to the ending point of the arc
x (float)The x coordinate of the upper left of the arc
y (float)The y coordinate of the upper left of the arc
width (float)Width of the rectangle containing the arc
height (float)Height of the rectangle containing the arc
startAngle (float)Start angle to begin the arc, in degrees
sweepAngle (float)Sweep angle (positive or negative) to specify how long the arc is, in degrees
AddArc

AddBezier

#
public void AddBezier(PointF start, PointF control1, PointF control2, PointF end)
Adds a bezier curve to the path with two control points
Remarks: If the current figure is not closed, it will connect with the start of the bezier curve. The current position will be moved to the end point.
start (PointF)Starting point of the bezier curve
control1 (PointF)First control point of the curve
control2 (PointF)Second control point of the curve
end (PointF)Ending point of the bezier curve
AddBezier

AddCurve

#
public void AddCurve(IEnumerable<PointF> points, float tension = 0.5)
Adds a curve that intersects with the specified points to the path
Remarks: Each point in the list will fall on the line based on the tension parameter
points (IEnumerable<PointF>)Points to calculate the curve
tension (float = 0.5)Tension between points in the curve. Should be between 0 (no curve) and 1 (more curve)
AddCurve

AddEllipse

#
public void AddEllipse(float x, float y, float width, float height)
Adds an ellipse to the path
Remarks: Rectangles are separate figures and will not connect to the current or next figure in the path. The starting point of the path will no longer be set after this call.
x (float)X co-ordinate of the top left of the ellipse
y (float)Y co-ordinate of the top left of the ellipse's bounding rectangle
width (float)Width of the rectangle
height (float)Height of the rectangle
AddEllipse

AddLine

#
public void AddLine(float startX, float startY, float endX, float endY)
Adds a line to the path with the specified start and end points
Remarks: If the current figure is not closed, it will connect with the start of this line. The current position will be moved to the specified end location.
startX (float)X co-ordinate of the starting point
startY (float)Y co-ordinate of the starting point
endX (float)X co-ordinate of the end point
endY (float)Y co-ordinate of the end point
AddLine

AddLines

#
public void AddLines(IEnumerable<PointF> points)
Adds lines to each of the specified points to the path
Remarks: If the current figure is not closed, it will connect with the first point specified. The current position will be moved to the last point specified
points (IEnumerable<PointF>)Points for each part of the line
AddLines

AddPath

#
public void AddPath(IGraphicsPath path, bool connect = false)
Adds the specified path to the current path, optionally connecting the current figure to the start of the path
Remarks: The connect parameter only specifies that the path should be connected to the current path at the beginning. The end of the specified path will always be connected to the next segment added to this path, unlesss CloseFigure() or StartFigure() are called after this.
path (IGraphicsPath)Child path to add to this instance
connect (bool = false)True to connect the current figure to the first figure of the specified path, if it is not closed
AddPath

AddRectangle

#
public void AddRectangle(float x, float y, float width, float height)
Adds a rectangle to the path
Remarks: Rectangles are separate figures and will not connect to the current or next figure in the path. The starting point of the path will no longer be set after this call.
x (float)X co-ordinate of the top left of the rectangle
y (float)Y co-ordinate of the top left of the rectangle
width (float)Width of the rectangle
height (float)Height of the rectangle
AddRectangle

CloseFigure

#
public void CloseFigure()
Closes the current figure by connecting a line to the beginning of the figure
Remarks: This will also make the next segment added to the path start independently from the last figure. To start a new figure without closing the current one, use StartFigure()
CloseFigure

Create

#
public static IGraphicsPath Create()
Creates a new instance of the IGraphicsPath for the specified generator

Dispose

#
protected virtual void Dispose(bool disposing)
Disposes the graphics path
disposing (bool)If set to true dispose was called explicitly, otherwise specify false if calling from a finalizer

FillContains

#
public bool FillContains(PointF point)
Gets a value indicating that the specified point is contained by the path when filled
point (PointF)Point to test
true if the path contains the point when filled, false otherwise
FillContains

GetRoundRect

#
public static IGraphicsPath GetRoundRect(RectangleF rectangle, float nwRadius, float neRadius, float seRadius, float swRadius)
Creates a rounded rectangle using the specified corner radius
rectangle (RectangleF)Rectangle to round
nwRadius (float)Radius of the north east corner
neRadius (float)Radius of the north west corner
seRadius (float)Radius of the south east corner
swRadius (float)Radius of the south west corner
GraphicsPath with the lines of the rounded rectangle ready to be painted

GetRoundRect

#
public static IGraphicsPath GetRoundRect(RectangleF rectangle, float radius)
Creates a rounded rectangle using the specified corner radius
rectangle (RectangleF)Rectangle to round
radius (float)Radius for all corners
The round rect.
GraphicsPath with the lines of the rounded rectangle ready to be painted

LineTo

#
public void LineTo(float x, float y)
Adds a line from the current position to the specified location
x (float)X co-ordinate to draw the line to
y (float)Y co-ordinate to draw the line to
LineTo

MoveTo

#
public void MoveTo(float x, float y)
Moves the current position to the specified location without adding anything to the path

StartFigure

#
public void StartFigure()
Starts a new figure without closing the current figure
Remarks: This will make the next segment added to the path independent (unconnected) to the last segment.
StartFigure

StrokeContains

#
public bool StrokeContains(Pen pen, PointF point)
Gets a value indicating that the spedified point is on the path when stroked with the specified pen
pen (Pen)Pen to test the stroke with
point (PointF)Point to test
true if the point is on the path when stroked with the specified pen, false otherwise
StrokeContains

Transform

#
public void Transform(IMatrix matrix)
Transforms the points in the path with the specified matrix