Skip to main content

Path Effects

APIs for path commands and scripted path effects.


PathCommand

A single drawing instruction inside a Path.

Attributes

command.type

The command type. Type: CommandType (read-only)

Methods

Length (#)

Returns the number of points in the command.

local pointCount = #command

Point counts by type:

TypePoints
moveTo2
lineTo2
quadTo4
cubicTo6
close0

See Also: CommandType, PathData


PathData

Indexed collection of PathCommand objects. Behaves like an array and supports ipairs iteration.

Methods

Length (#)

Returns the number of commands in the path.

local count = #pathData

pathData:contours()

Returns a ContourMeasure for the first contour. Returns nil if no contours exist.

pathData:contours(): ContourMeasure?

pathData:measure()

Returns a PathMeasure for the entire path.

pathData:measure(): PathMeasure

Example: Iterating Commands

for i, command in ipairs(pathData) do
print(command.type, #command, "points")
end

See Also: PathCommand, ContourMeasure


PathEffect

Scripted effect applied to a path. Use for custom path transformations.

Protocol Methods

init(self): boolean

Called once when the effect is created.

function init(self: MyEffect): boolean
-- Setup logic
return true -- Return true to keep effect active
end

update(self, pathData): PathData

Receives the original path data and returns a modified path.

function update(self: MyEffect, pathData: PathData): PathData
-- Transform the path
return modifiedPathData
end

advance(self, seconds): boolean

Optional per-frame update.

function advance(self: MyEffect, seconds: number): boolean
-- Animation logic
return true -- Continue receiving advance calls
end

See Also: PathData, PathMeasure


CommandType

Enum describing path drawing command types.

Values

ValueDescription
nonePlaceholder (not normally encountered)
moveToMove to a point without drawing
lineToDraw a straight line
quadToQuadratic Bezier curve
cubicToCubic Bezier curve
closeClose the path

See Also: PathCommand

Next Steps