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
defaultTransformMatrix4x4The 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
centerPointThe center Point of the ellipse from which the arc is taken.
radiusXintThe x-radius of the ellipsis.
radiusYintThe y-radius of the ellipsis.
rotationintThe angle, in degrees, from the x-axis of the current coordinate system to the x-axis of the ellipse.
startAngleintThe 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).
sweepAngleintThe angle between
startAngleand 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
startPointPointFThe start point of the arc.
radiusXfloatThe x-radius of the ellipsis.
radiusYfloatThe y-radius of the ellipsis.
rotationfloatThe rotation along the X-axis; measured in degrees clockwise.
largeArcboolThe 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.
sweepboolThe sweep flag, and is false if the line joining center to arc sweeps through decreasing angles, or true if it sweeps through increasing angles.
endPointPointFThe 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
centerPointFThe center PointF of the ellipse from which the arc is taken.
radiusXfloatThe x-radius of the ellipsis.
radiusYfloatThe y-radius of the ellipsis.
rotationfloatThe angle, in degrees, from the x-axis of the current coordinate system to the x-axis of the ellipse.
startAnglefloatThe 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).
sweepAnglefloatThe angle between
startAngleand 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
rectangleRectangleA Rectangle that represents the rectangular bounds of the ellipse from which the arc is taken.
rotationintThe angle, in degrees, from the x-axis of the current coordinate system to the x-axis of the ellipse.
startAngleintThe 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).
sweepAngleintThe angle between
startAngleand 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
rectangleRectangleFA RectangleF that represents the rectangular bounds of the ellipse from which the arc is taken.
rotationfloatThe angle, in degrees, from the x-axis of the current coordinate system to the x-axis of the ellipse.
startAnglefloatThe 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).
sweepAnglefloatThe angle between
startAngleand 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
xintThe x-coordinate of the center point of the ellipse from which the arc is taken.
yintThe y-coordinate of the center point of the ellipse from which the arc is taken.
radiusXintThe x-radius of the ellipsis.
radiusYintThe y-radius of the ellipsis.
rotationintThe angle, in degrees, from the x-axis of the current coordinate system to the x-axis of the ellipse.
startAngleintThe 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).
sweepAngleintThe angle between
startAngleand 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
xfloatThe x-coordinate of the center point of the ellipse from which the arc is taken.
yfloatThe y-coordinate of the center point of the ellipse from which the arc is taken.
radiusXfloatThe x-radius of the ellipsis.
radiusYfloatThe y-radius of the ellipsis.
rotationfloatThe angle, in degrees, from the x-axis of the current coordinate system to the x-axis of the ellipse.
startAnglefloatThe 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).
sweepAnglefloatThe angle between
startAngleand 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
startPointPointFThe start point.
controlPoint1PointFThe control point1.
controlPoint2PointFThe control point2.
endPointPointFThe 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
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
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
pointsPointF[]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
pointsIEnumerable<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
centerPointFThe center point of the pie sector.
radiusSizeFThe x and y radii of the pie ellipse.
startAnglefloatThe pie start angle in degrees.
sweepAnglefloatThe 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
centerPointFThe center point of the pie sector.
radiusSizeFThe x and y radii of the pie ellipse.
rotationfloatThe ellipse rotation in degrees.
startAnglefloatThe pie start angle in degrees.
sweepAnglefloatThe 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
xfloatThe x-coordinate of the pie center.
yfloatThe y-coordinate of the pie center.
radiusXfloatThe x-radius of the pie ellipse.
radiusYfloatThe y-radius of the pie ellipse.
startAnglefloatThe pie start angle in degrees.
sweepAnglefloatThe 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
xfloatThe x-coordinate of the pie center.
yfloatThe y-coordinate of the pie center.
radiusXfloatThe x-radius of the pie ellipse.
radiusYfloatThe y-radius of the pie ellipse.
rotationfloatThe ellipse rotation in degrees.
startAnglefloatThe pie start angle in degrees.
sweepAnglefloatThe 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
pointsPointF[]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
pointsIEnumerable<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
startPointPointFThe start point.
controlPointPointFThe control point1.
endPointPointFThe 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
rectangleRectangleThe 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
rectangleRectangleFThe 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
xfloatThe x-coordinate of the rectangle.
yfloatThe y-coordinate of the rectangle.
widthfloatThe rectangle width.
heightfloatThe 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
centerPointFThe center point of the polygon.
verticesintThe number of polygon vertices.
radiusfloatThe 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
centerPointFThe center point of the polygon.
verticesintThe number of polygon vertices.
radiusfloatThe polygon radius.
anglefloatThe 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
xfloatThe x-coordinate of the polygon center.
yfloatThe y-coordinate of the polygon center.
verticesintThe number of polygon vertices.
radiusfloatThe 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
xfloatThe x-coordinate of the polygon center.
yfloatThe y-coordinate of the polygon center.
verticesintThe number of polygon vertices.
radiusfloatThe polygon radius.
anglefloatThe 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
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
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
rectangleRectangleFThe rectangle bounds.
radiusSizeFThe 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
rectangleRectangleFThe rectangle bounds.
radiusfloatThe 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
xfloatThe x-coordinate of the rectangle.
yfloatThe y-coordinate of the rectangle.
widthfloatThe rectangle width.
heightfloatThe rectangle height.
radiusSizeFThe 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
xfloatThe x-coordinate of the rectangle.
yfloatThe y-coordinate of the rectangle.
widthfloatThe rectangle width.
heightfloatThe rectangle height.
radiusfloatThe x and y radius of each corner.
Returns
- PathBuilder
The PathBuilder.
AddSegment(ILineSegment)
Adds the segment.
public PathBuilder AddSegment(ILineSegment segment)
Parameters
segmentILineSegmentThe 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
centerPointFThe center point of the star.
prongsintThe number of star prongs.
innerRadiifloatThe inner star radius.
outerRadiifloatThe 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
centerPointFThe center point of the star.
prongsintThe number of star prongs.
innerRadiifloatThe inner star radius.
outerRadiifloatThe outer star radius.
anglefloatThe 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
xfloatThe x-coordinate of the star center.
yfloatThe y-coordinate of the star center.
prongsintThe number of star prongs.
innerRadiifloatThe inner star radius.
outerRadiifloatThe 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
xfloatThe x-coordinate of the star center.
yfloatThe y-coordinate of the star center.
prongsintThe number of star prongs.
innerRadiifloatThe inner star radius.
outerRadiifloatThe outer star radius.
anglefloatThe 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
radiusXfloatThe x-radius of the ellipsis.
radiusYfloatThe y-radius of the ellipsis.
rotationfloatThe rotation along the X-axis; measured in degrees clockwise.
largeArcboolThe 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.
sweepboolThe sweep flag, and is false if the line joining center to arc sweeps through decreasing angles, or true if it sweeps through increasing angles.
pointPointFThe 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
secondControlPointVector2The second control point.
thirdControlPointVector2The third control point.
pointVector2The 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
pointPointFThe 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
Returns
MoveTo(PointF)
Moves to current point to the supplied vector.
public PathBuilder MoveTo(PointF point)
Parameters
pointPointFThe point.
Returns
- PathBuilder
The PathBuilder.
MoveTo(float, float)
Moves to current point to the supplied vector.
public PathBuilder MoveTo(float x, float y)
Parameters
Returns
QuadraticBezierTo(Vector2, Vector2)
Draws a quadratic bezier from the current point to the point
public PathBuilder QuadraticBezierTo(Vector2 secondControlPoint, Vector2 point)
Parameters
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
originPointFThe 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
transformMatrix4x4The transform.
Returns
- PathBuilder
The PathBuilder.
StartFigure()
Starts a new figure but leaves the previous one open.
public PathBuilder StartFigure()
Returns
- PathBuilder
The PathBuilder.