Skip to main content

Constructors

new

Methods

moveTo

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

lineTo

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

quadTo

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

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

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

Each entry is a PathCommand describing one segment or action in the path. Returns the number of commands in the path.

reset

Paths should not be reset 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 one path to another path with the given transform, when specified.

contours

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

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()