Skip to main content

Constructors

new

new

Methods

moveTo

moveTo(self: Path, to: Vector) -> ()
Moves the current point to the specified location, starting a new contour.
path:moveTo(Vector.xy(0, 0))

lineTo

lineTo(self: Path, to: Vector) -> ()
Adds a straight line segment from the current point to the specified point.
path:lineTo(Vector.xy(10, 0))

quadTo

quadTo(self: Path, control: Vector, to: Vector) -> ()
Adds a quadratic Bézier curve from the current point to the specified point, using the control point to define the curve shape.
path:quadTo(
  Vector.xy(-50, -50), -- control point
  Vector.xy(0, 0)      -- end point
)

cubicTo

cubicTo(self: Path, controlOut: Vector, controlIn: Vector, to: Vector) -> ()
Adds a cubic Bézier curve from the current point to the specified point, using controlOut for the start tangent and controlIn for the end tangent.
path:cubicTo(
  Vector.xy(25, -40),  -- control point out
  Vector.xy(75, 40),   -- control point in
  Vector.xy(100, 0)    -- end point
)

close

close(self: Path) -> ()
Closes the current contour by adding a line segment from the current point back to the first point of the contour (the last moveTo).
-- Draw a rectangle
path:moveTo(Vector.xy(-10, -10))
path:lineTo(Vector.xy(10, -10))
path:lineTo(Vector.xy(10, 10))
path:lineTo(Vector.xy(-10, 10))
-- Close the path
path:close()

__len

__len() -> number
Each entry is a PathCommand describing one segment or action in the path. Returns the number of commands in the path.

reset

reset(self: Path) -> ()
Paths should not be reset, or mutated at all, while they are in flight for rendering. Only call reset on subsequent frames if you’ve called Renderer.drawPath with it.
path:reset()

add

add(self: Path, other: PathData, transform: Mat2D?) -> ()
Add one path to another path with the given transform, when specified.

contours

contours(self: Path) -> ContourMeasure?
Returns a ContourMeasure for the first contour in the path. A contour is a sequence of path segments between moveTo operations. Use the ‘next’ property on the returned ContourMeasure to iterate through subsequent contours. Returns nil if the path has no contours.

measure

measure(self: Path) -> PathMeasure
Returns a PathMeasure that measures the entire path across all contours. This provides the total length and allows operations on the path as a whole.
local pathLength = path:measure()