A function that receives a PathBuilder and uses its drawing commands to construct the shape.
PathBuilder Methods
Thepath parameter provides the following drawing commands:
Begins a new subpath at the given point.
Adds a straight line from the current point to the given point.
path.quadCurve(x, y, controlX, controlY)
(x: number, y: number, controlX: number, controlY: number) => void
Adds a quadratic Bezier curve to the given point with one control point.
path.curve(x, y, control1X, control1Y, control2X, control2Y)
(x: number, y: number, control1X: number, control1Y: number, control2X: number, control2Y: number) => void
Adds a cubic Bezier curve to the given point with two control points.
path.arc(props)
(props: { centerX: number; centerY: number; radius: number; startAngle: number; endAngle: number; clockwise?: boolean }) => void
Adds an arc. Angles are specified in degrees.
Adds a rectangle subpath.
path.addRoundedRect(props)
(props: { x: number; y: number; width: number; height: number; cornerWidth: number; cornerHeight: number }) => void
Adds a rounded rectangle subpath.
Adds an ellipse subpath inscribed in the given rectangle.
Adds a polyline from an array of
[x, y] coordinate pairs.Closes the current subpath by drawing a line back to the starting point.
Methods
Since Path returns a Shape, it supports the standard shape methods:Fills the path interior with a color, gradient, or other style.
Draws the path outline. Pass a Style for a 1-point stroke, or a StrokeOptions object (
{ style: Style, lineWidth?: number }) for custom width.Support
Usage
Triangle
Star shape
Curved line
Arc
Polyline chart
Notes
- Coordinates are relative to the Path’s own coordinate space. Use
.frame()to set the overall size. - Path returns a Shape, so it can be used anywhere shapes are accepted, including
.clipShape(),.background(), and.overlay(). - Multiple subpaths can be created by calling
move()multiple times within a single builder.
See Also
- Circle — circle shape
- Rectangle — rectangle shape
- RoundedRectangle — rounded rectangle shape