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:
| Type | Points | Description |
|---|---|---|
moveTo | 1 | 1 Vector (destination) |
lineTo | 1 | 1 Vector (endpoint) |
quadTo | 2 | 2 Vectors (control, endpoint) |
cubicTo | 3 | 3 Vectors (controlOut, controlIn, endpoint) |
close | 0 | No points |
Note: Points are
Vectorobjects accessed by index (e.g.,cmd[1]), not raw number pairs.
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, context): boolean
Called once when the effect is created.
function init(self: MyEffect, context: Context): boolean
-- Setup logic
return true -- Return true to keep effect active
end
update(self, pathData, node): PathData
Receives the original path data and the host node's read-only data, and returns a modified path.
function update(self: MyEffect, pathData: PathData, node: NodeReadData): PathData
-- Transform the path using node context
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
| Value | Description |
|---|---|
none | Placeholder (not normally encountered) |
moveTo | Move to a point without drawing |
lineTo | Draw a straight line |
quadTo | Quadratic Bezier curve |
cubicTo | Cubic Bezier curve |
close | Close the path |
See Also: PathCommand
Next Steps
- Continue to Data Values
- Need a refresher? Review Quick Reference