Table of Contents

Class PathBuilder

Namespace
SixLabors.ImageSharp.Drawing
Assembly
SixLabors.ImageSharp.Drawing.dll

Allow you to derivatively build shapes and paths.

public class PathBuilder
Inheritance
PathBuilder
Inherited Members

Constructors

PathBuilder()

Initializes a new instance of the PathBuilder class.

public PathBuilder()

PathBuilder(Matrix4x4)

Initializes a new instance of the PathBuilder class.

public PathBuilder(Matrix4x4 defaultTransform)

Parameters

defaultTransform Matrix4x4

The default transform.

Properties

Transform

Gets the current transformation matrix.

public Matrix4x4 Transform { get; }

Property Value

Matrix4x4

The current transformation matrix.

Remarks

Returns a copy of the matrix. Because Matrix4x4 is a value type, modifications to the returned value do not affect the internal state. To change the transform, call SetTransform(Matrix4x4).

Methods

AddArc(Point, int, int, int, int, int)

Adds an elliptical arc to the current figure.

public PathBuilder AddArc(Point center, int radiusX, int radiusY, int rotation, int startAngle, int sweepAngle)

Parameters

center Point

The center Point of the ellipse from which the arc is taken.

radiusX int

The x-radius of the ellipsis.

radiusY int

The y-radius of the ellipsis.

rotation int

The angle, in degrees, from the x-axis of the current coordinate system to the x-axis of the ellipse.

startAngle int

The start angle of the elliptical arc prior to the stretch and rotate operations. (0 is at the 3 o'clock position of the arc's circle).

sweepAngle int

The angle between startAngle and the end of the arc.

Returns

PathBuilder

The PathBuilder.

AddArc(PointF, float, float, float, bool, bool, PointF)

Adds an elliptical arc to the current figure. The arc curves from the startPoint to endPoint, choosing one of four possible routes: clockwise or counterclockwise, and smaller or larger.

The arc sweep is always less than 360 degrees. The method appends a line to the last point if either radii are zero, or if last point is equal to endPoint. In addition the method scales the radii to fit last point and endPoint if both are greater than zero but too small to describe an arc.

public PathBuilder AddArc(PointF startPoint, float radiusX, float radiusY, float rotation, bool largeArc, bool sweep, PointF endPoint)

Parameters

startPoint PointF

The start point of the arc.

radiusX float

The x-radius of the ellipsis.

radiusY float

The y-radius of the ellipsis.

rotation float

The rotation along the X-axis; measured in degrees clockwise.

largeArc bool

The large arc flag, and is false if an arc spanning less than or equal to 180 degrees is chosen, or true if an arc spanning greater than 180 degrees is chosen.

sweep bool

The sweep flag, and is false if the line joining center to arc sweeps through decreasing angles, or true if it sweeps through increasing angles.

endPoint PointF

The end point of the arc.

Returns

PathBuilder

The PathBuilder.

AddArc(PointF, float, float, float, float, float)

Adds an elliptical arc to the current figure.

public PathBuilder AddArc(PointF center, float radiusX, float radiusY, float rotation, float startAngle, float sweepAngle)

Parameters

center PointF

The center PointF of the ellipse from which the arc is taken.

radiusX float

The x-radius of the ellipsis.

radiusY float

The y-radius of the ellipsis.

rotation float

The angle, in degrees, from the x-axis of the current coordinate system to the x-axis of the ellipse.

startAngle float

The start angle of the elliptical arc prior to the stretch and rotate operations. (0 is at the 3 o'clock position of the arc's circle).

sweepAngle float

The angle between startAngle and the end of the arc.

Returns

PathBuilder

The PathBuilder.

AddArc(Rectangle, int, int, int)

Adds an elliptical arc to the current figure.

public PathBuilder AddArc(Rectangle rectangle, int rotation, int startAngle, int sweepAngle)

Parameters

rectangle Rectangle

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

rotation int

The angle, in degrees, from the x-axis of the current coordinate system to the x-axis of the ellipse.

startAngle int

The start angle of the elliptical arc prior to the stretch and rotate operations. (0 is at the 3 o'clock position of the arc's circle).

sweepAngle int

The angle between startAngle and the end of the arc.

Returns

PathBuilder

The PathBuilder.

AddArc(RectangleF, float, float, float)

Adds an elliptical arc to the current figure.

public PathBuilder AddArc(RectangleF rectangle, float rotation, float startAngle, float sweepAngle)

Parameters

rectangle RectangleF

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

rotation float

The angle, in degrees, from the x-axis of the current coordinate system to the x-axis of the ellipse.

startAngle float

The start angle of the elliptical arc prior to the stretch and rotate operations. (0 is at the 3 o'clock position of the arc's circle).

sweepAngle float

The angle between startAngle and the end of the arc.

Returns

PathBuilder

The PathBuilder.

AddArc(int, int, int, int, int, int, int)

Adds an elliptical arc to the current figure.

public PathBuilder AddArc(int x, int y, int radiusX, int radiusY, int rotation, int startAngle, int sweepAngle)

Parameters

x int

The x-coordinate of the center point of the ellipse from which the arc is taken.

y int

The y-coordinate of the center point of the ellipse from which the arc is taken.

radiusX int

The x-radius of the ellipsis.

radiusY int

The y-radius of the ellipsis.

rotation int

The angle, in degrees, from the x-axis of the current coordinate system to the x-axis of the ellipse.

startAngle int

The start angle of the elliptical arc prior to the stretch and rotate operations. (0 is at the 3 o'clock position of the arc's circle).

sweepAngle int

The angle between startAngle and the end of the arc.

Returns

PathBuilder

The PathBuilder.

AddArc(float, float, float, float, float, float, float)

Adds an elliptical arc to the current figure.

public PathBuilder AddArc(float x, float y, float radiusX, float radiusY, float rotation, float startAngle, float sweepAngle)

Parameters

x float

The x-coordinate of the center point of the ellipse from which the arc is taken.

y float

The y-coordinate of the center point of the ellipse from which the arc is taken.

radiusX float

The x-radius of the ellipsis.

radiusY float

The y-radius of the ellipsis.

rotation float

The angle, in degrees, from the x-axis of the current coordinate system to the x-axis of the ellipse.

startAngle float

The start angle of the elliptical arc prior to the stretch and rotate operations. (0 is at the 3 o'clock position of the arc's circle).

sweepAngle float

The angle between startAngle and the end of the arc.

Returns

PathBuilder

The PathBuilder.

AddCubicBezier(PointF, PointF, PointF, PointF)

Adds a cubic bezier curve to the current figure joining the startPoint point to the endPoint.

public PathBuilder AddCubicBezier(PointF startPoint, PointF controlPoint1, PointF controlPoint2, PointF endPoint)

Parameters

startPoint PointF

The start point.

controlPoint1 PointF

The control point1.

controlPoint2 PointF

The control point2.

endPoint PointF

The end point.

Returns

PathBuilder

The PathBuilder.

AddLine(PointF, PointF)

Adds the line connecting the current point to the new point.

public PathBuilder AddLine(PointF start, PointF end)

Parameters

start PointF

The start.

end PointF

The end.

Returns

PathBuilder

The PathBuilder.

AddLine(float, float, float, float)

Adds the line connecting the current point to the new point.

public PathBuilder AddLine(float x1, float y1, float x2, float y2)

Parameters

x1 float

The x1.

y1 float

The y1.

x2 float

The x2.

y2 float

The y2.

Returns

PathBuilder

The PathBuilder.

AddLines(params PointF[])

Adds a series of line segments connecting the current point to the new points.

public PathBuilder AddLines(params PointF[] points)

Parameters

points PointF[]

The points.

Returns

PathBuilder

The PathBuilder.

AddLines(IEnumerable<PointF>)

Adds a series of line segments connecting the current point to the new points.

public PathBuilder AddLines(IEnumerable<PointF> points)

Parameters

points IEnumerable<PointF>

The points.

Returns

PathBuilder

The PathBuilder.

AddPie(PointF, SizeF, float, float)

Adds a pie sector to the current path as a closed figure.

public PathBuilder AddPie(PointF center, SizeF radius, float startAngle, float sweepAngle)

Parameters

center PointF

The center point of the pie sector.

radius SizeF

The x and y radii of the pie ellipse.

startAngle float

The pie start angle in degrees.

sweepAngle float

The pie sweep angle in degrees.

Returns

PathBuilder

The PathBuilder.

AddPie(PointF, SizeF, float, float, float)

Adds a pie sector to the current path as a closed figure.

public PathBuilder AddPie(PointF center, SizeF radius, float rotation, float startAngle, float sweepAngle)

Parameters

center PointF

The center point of the pie sector.

radius SizeF

The x and y radii of the pie ellipse.

rotation float

The ellipse rotation in degrees.

startAngle float

The pie start angle in degrees.

sweepAngle float

The pie sweep angle in degrees.

Returns

PathBuilder

The PathBuilder.

AddPie(float, float, float, float, float, float)

Adds a pie sector to the current path as a closed figure.

public PathBuilder AddPie(float x, float y, float radiusX, float radiusY, float startAngle, float sweepAngle)

Parameters

x float

The x-coordinate of the pie center.

y float

The y-coordinate of the pie center.

radiusX float

The x-radius of the pie ellipse.

radiusY float

The y-radius of the pie ellipse.

startAngle float

The pie start angle in degrees.

sweepAngle float

The pie sweep angle in degrees.

Returns

PathBuilder

The PathBuilder.

AddPie(float, float, float, float, float, float, float)

Adds a pie sector to the current path as a closed figure.

public PathBuilder AddPie(float x, float y, float radiusX, float radiusY, float rotation, float startAngle, float sweepAngle)

Parameters

x float

The x-coordinate of the pie center.

y float

The y-coordinate of the pie center.

radiusX float

The x-radius of the pie ellipse.

radiusY float

The y-radius of the pie ellipse.

rotation float

The ellipse rotation in degrees.

startAngle float

The pie start angle in degrees.

sweepAngle float

The pie sweep angle in degrees.

Returns

PathBuilder

The PathBuilder.

AddPolygon(params PointF[])

Adds a polygon to the current path as a closed figure.

public PathBuilder AddPolygon(params PointF[] points)

Parameters

points PointF[]

The polygon vertices.

Returns

PathBuilder

The PathBuilder.

AddPolygon(IEnumerable<PointF>)

Adds a polygon to the current path as a closed figure.

public PathBuilder AddPolygon(IEnumerable<PointF> points)

Parameters

points IEnumerable<PointF>

The polygon vertices.

Returns

PathBuilder

The PathBuilder.

AddQuadraticBezier(PointF, PointF, PointF)

Adds a quadratic bezier curve to the current figure joining the startPoint point to the endPoint.

public PathBuilder AddQuadraticBezier(PointF startPoint, PointF controlPoint, PointF endPoint)

Parameters

startPoint PointF

The start point.

controlPoint PointF

The control point1.

endPoint PointF

The end point.

Returns

PathBuilder

The PathBuilder.

AddRectangle(Rectangle)

Adds a rectangle to the current path as a closed figure.

public PathBuilder AddRectangle(Rectangle rectangle)

Parameters

rectangle Rectangle

The rectangle bounds.

Returns

PathBuilder

The PathBuilder.

AddRectangle(RectangleF)

Adds a rectangle to the current path as a closed figure.

public PathBuilder AddRectangle(RectangleF rectangle)

Parameters

rectangle RectangleF

The rectangle bounds.

Returns

PathBuilder

The PathBuilder.

AddRectangle(float, float, float, float)

Adds a rectangle to the current path as a closed figure.

public PathBuilder AddRectangle(float x, float y, float width, float height)

Parameters

x float

The x-coordinate of the rectangle.

y float

The y-coordinate of the rectangle.

width float

The rectangle width.

height float

The rectangle height.

Returns

PathBuilder

The PathBuilder.

AddRegularPolygon(PointF, int, float)

Adds a regular polygon to the current path as a closed figure.

public PathBuilder AddRegularPolygon(PointF center, int vertices, float radius)

Parameters

center PointF

The center point of the polygon.

vertices int

The number of polygon vertices.

radius float

The polygon radius.

Returns

PathBuilder

The PathBuilder.

AddRegularPolygon(PointF, int, float, float)

Adds a regular polygon to the current path as a closed figure.

public PathBuilder AddRegularPolygon(PointF center, int vertices, float radius, float angle)

Parameters

center PointF

The center point of the polygon.

vertices int

The number of polygon vertices.

radius float

The polygon radius.

angle float

The polygon rotation angle in degrees.

Returns

PathBuilder

The PathBuilder.

AddRegularPolygon(float, float, int, float)

Adds a regular polygon to the current path as a closed figure.

public PathBuilder AddRegularPolygon(float x, float y, int vertices, float radius)

Parameters

x float

The x-coordinate of the polygon center.

y float

The y-coordinate of the polygon center.

vertices int

The number of polygon vertices.

radius float

The polygon radius.

Returns

PathBuilder

The PathBuilder.

AddRegularPolygon(float, float, int, float, float)

Adds a regular polygon to the current path as a closed figure.

public PathBuilder AddRegularPolygon(float x, float y, int vertices, float radius, float angle)

Parameters

x float

The x-coordinate of the polygon center.

y float

The y-coordinate of the polygon center.

vertices int

The number of polygon vertices.

radius float

The polygon radius.

angle float

The polygon rotation angle in degrees.

Returns

PathBuilder

The PathBuilder.

AddRoundedRectangle(Rectangle, SizeF)

Adds a rounded rectangle to the current path as a closed figure.

public PathBuilder AddRoundedRectangle(Rectangle rectangle, SizeF radius)

Parameters

rectangle Rectangle

The rectangle bounds.

radius SizeF

The x and y radii of each corner.

Returns

PathBuilder

The PathBuilder.

AddRoundedRectangle(Rectangle, float)

Adds a rounded rectangle to the current path as a closed figure.

public PathBuilder AddRoundedRectangle(Rectangle rectangle, float radius)

Parameters

rectangle Rectangle

The rectangle bounds.

radius float

The x and y radius of each corner.

Returns

PathBuilder

The PathBuilder.

AddRoundedRectangle(RectangleF, SizeF)

Adds a rounded rectangle to the current path as a closed figure.

public PathBuilder AddRoundedRectangle(RectangleF rectangle, SizeF radius)

Parameters

rectangle RectangleF

The rectangle bounds.

radius SizeF

The x and y radii of each corner.

Returns

PathBuilder

The PathBuilder.

AddRoundedRectangle(RectangleF, float)

Adds a rounded rectangle to the current path as a closed figure.

public PathBuilder AddRoundedRectangle(RectangleF rectangle, float radius)

Parameters

rectangle RectangleF

The rectangle bounds.

radius float

The x and y radius of each corner.

Returns

PathBuilder

The PathBuilder.

AddRoundedRectangle(float, float, float, float, SizeF)

Adds a rounded rectangle to the current path as a closed figure.

public PathBuilder AddRoundedRectangle(float x, float y, float width, float height, SizeF radius)

Parameters

x float

The x-coordinate of the rectangle.

y float

The y-coordinate of the rectangle.

width float

The rectangle width.

height float

The rectangle height.

radius SizeF

The x and y radii of each corner.

Returns

PathBuilder

The PathBuilder.

AddRoundedRectangle(float, float, float, float, float)

Adds a rounded rectangle to the current path as a closed figure.

public PathBuilder AddRoundedRectangle(float x, float y, float width, float height, float radius)

Parameters

x float

The x-coordinate of the rectangle.

y float

The y-coordinate of the rectangle.

width float

The rectangle width.

height float

The rectangle height.

radius float

The x and y radius of each corner.

Returns

PathBuilder

The PathBuilder.

AddSegment(ILineSegment)

Adds the segment.

public PathBuilder AddSegment(ILineSegment segment)

Parameters

segment ILineSegment

The segment.

Returns

PathBuilder

The PathBuilder.

AddStar(PointF, int, float, float)

Adds a star to the current path as a closed figure.

public PathBuilder AddStar(PointF center, int prongs, float innerRadii, float outerRadii)

Parameters

center PointF

The center point of the star.

prongs int

The number of star prongs.

innerRadii float

The inner star radius.

outerRadii float

The outer star radius.

Returns

PathBuilder

The PathBuilder.

AddStar(PointF, int, float, float, float)

Adds a star to the current path as a closed figure.

public PathBuilder AddStar(PointF center, int prongs, float innerRadii, float outerRadii, float angle)

Parameters

center PointF

The center point of the star.

prongs int

The number of star prongs.

innerRadii float

The inner star radius.

outerRadii float

The outer star radius.

angle float

The star rotation angle in degrees.

Returns

PathBuilder

The PathBuilder.

AddStar(float, float, int, float, float)

Adds a star to the current path as a closed figure.

public PathBuilder AddStar(float x, float y, int prongs, float innerRadii, float outerRadii)

Parameters

x float

The x-coordinate of the star center.

y float

The y-coordinate of the star center.

prongs int

The number of star prongs.

innerRadii float

The inner star radius.

outerRadii float

The outer star radius.

Returns

PathBuilder

The PathBuilder.

AddStar(float, float, int, float, float, float)

Adds a star to the current path as a closed figure.

public PathBuilder AddStar(float x, float y, int prongs, float innerRadii, float outerRadii, float angle)

Parameters

x float

The x-coordinate of the star center.

y float

The y-coordinate of the star center.

prongs int

The number of star prongs.

innerRadii float

The inner star radius.

outerRadii float

The outer star radius.

angle float

The star rotation angle in degrees.

Returns

PathBuilder

The PathBuilder.

ArcTo(float, float, float, bool, bool, PointF)

Adds an elliptical arc to the current figure. The arc curves from the last point to point, choosing one of four possible routes: clockwise or counterclockwise, and smaller or larger.

The arc sweep is always less than 360 degrees. The method appends a line to the last point if either radii are zero, or if last point is equal to point. In addition the method scales the radii to fit last point and point if both are greater than zero but too small to describe an arc.

public PathBuilder ArcTo(float radiusX, float radiusY, float rotation, bool largeArc, bool sweep, PointF point)

Parameters

radiusX float

The x-radius of the ellipsis.

radiusY float

The y-radius of the ellipsis.

rotation float

The rotation along the X-axis; measured in degrees clockwise.

largeArc bool

The large arc flag, and is false if an arc spanning less than or equal to 180 degrees is chosen, or true if an arc spanning greater than 180 degrees is chosen.

sweep bool

The sweep flag, and is false if the line joining center to arc sweeps through decreasing angles, or true if it sweeps through increasing angles.

point PointF

The end point of the arc.

Returns

PathBuilder

The PathBuilder.

Build()

Builds a complex polygon from the current working set of working operations.

public IPath Build()

Returns

IPath

The current set of operations as a complex polygon

Clear()

Clears all drawn paths, Leaving any applied transforms.

[MemberNotNull("currentFigure")]
public void Clear()

CloseAllFigures()

Closes the current figure.

public PathBuilder CloseAllFigures()

Returns

PathBuilder

The PathBuilder.

CloseFigure()

Closes the current figure.

public PathBuilder CloseFigure()

Returns

PathBuilder

The PathBuilder.

CubicBezierTo(Vector2, Vector2, Vector2)

Draws a quadratic bezier from the current point to the point

public PathBuilder CubicBezierTo(Vector2 secondControlPoint, Vector2 thirdControlPoint, Vector2 point)

Parameters

secondControlPoint Vector2

The second control point.

thirdControlPoint Vector2

The third control point.

point Vector2

The point.

Returns

PathBuilder

The PathBuilder.

LineTo(PointF)

Draws the line connecting the current the current point to the new point.

public PathBuilder LineTo(PointF point)

Parameters

point PointF

The point.

Returns

PathBuilder

The PathBuilder.

LineTo(float, float)

Draws the line connecting the current the current point to the new point.

public PathBuilder LineTo(float x, float y)

Parameters

x float

The x.

y float

The y.

Returns

PathBuilder

The PathBuilder

MoveTo(PointF)

Moves to current point to the supplied vector.

public PathBuilder MoveTo(PointF point)

Parameters

point PointF

The point.

Returns

PathBuilder

The PathBuilder.

MoveTo(float, float)

Moves to current point to the supplied vector.

public PathBuilder MoveTo(float x, float y)

Parameters

x float

The x-coordinate.

y float

The y-coordinate.

Returns

PathBuilder

The PathBuilder

QuadraticBezierTo(Vector2, Vector2)

Draws a quadratic bezier from the current point to the point

public PathBuilder QuadraticBezierTo(Vector2 secondControlPoint, Vector2 point)

Parameters

secondControlPoint Vector2

The second control point.

point Vector2

The point.

Returns

PathBuilder

The PathBuilder.

Reset()

Resets this instance, clearing any drawn paths and resetting any transforms.

public PathBuilder Reset()

Returns

PathBuilder

The PathBuilder.

ResetOrigin()

Resets the origin to the default.

public PathBuilder ResetOrigin()

Returns

PathBuilder

The PathBuilder.

ResetTransform()

Resets the transform to the default.

public PathBuilder ResetTransform()

Returns

PathBuilder

The PathBuilder.

SetOrigin(PointF)

Sets the origin all subsequent point should be relative to.

public PathBuilder SetOrigin(PointF origin)

Parameters

origin PointF

The origin.

Returns

PathBuilder

The PathBuilder.

SetTransform(Matrix4x4)

Sets the translation to be applied to all items to follow being applied to the PathBuilder.

public PathBuilder SetTransform(Matrix4x4 transform)

Parameters

transform Matrix4x4

The transform.

Returns

PathBuilder

The PathBuilder.

StartFigure()

Starts a new figure but leaves the previous one open.

public PathBuilder StartFigure()

Returns

PathBuilder

The PathBuilder.