Creating a Path Effect
Create a new script and select Path Effect as the type.Examples
Anatomy of a Path Effect Script
Methods
- init (optional) Called once when the path effect is created. Use this to set up initial state. Returns true if initialization succeeds.
- update (required)
The core method where path transformation happens. Receives the original
PathDataand returns a modified version. This is where you manipulate the path’s geometry. - advance (optional) Called every frame with elapsed time in seconds. Returns true to continue receiving advance calls. Useful for animated effects that change over time.
Working with PathData
PathData provides access to a path’s drawing commands (moveTo, lineTo, cubicTo, quadTo, close). You can:
- Read existing commands using indexing
- Get the command count with
#pathData - Create new paths and add commands
- Use measurement tools like
contours()andmeasure()for advanced operations
Add the Scripted Path Effect to a Stroke
Select or add a stroke to a shape:- Open the Options menu.
- Select the Effects Tab and click the ’+’ to add an effect.
- Find your effects under the Script Effects menu option.
- Any inputs you have defined will apepar and can be edited here.
