@pixerate/editor 0.80.0 → 0.81.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -3
- package/dist/agent/index.cjs +102 -6
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +4 -2
- package/dist/agent/index.d.ts +4 -2
- package/dist/agent/index.js +101 -5
- package/dist/agent/index.js.map +1 -1
- package/dist/{builtins-BKYlHH1s.d.ts → builtins-CV1fDj64.d.ts} +5 -1
- package/dist/{builtins-1kqwLUnb.d.cts → builtins-c4w0eAYl.d.cts} +5 -1
- package/dist/{chunk-2CJ3LPYQ.js → chunk-424H3P4I.js} +13 -295
- package/dist/chunk-424H3P4I.js.map +1 -0
- package/dist/{chunk-UN33YOXW.cjs → chunk-PA5S7KPC.cjs} +293 -2
- package/dist/chunk-PA5S7KPC.cjs.map +1 -0
- package/dist/{chunk-IB3ZHQAX.js → chunk-PTYWCFFW.js} +29 -4
- package/dist/chunk-PTYWCFFW.js.map +1 -0
- package/dist/{chunk-JQ3BB3E6.js → chunk-PXDEFEG2.js} +293 -2
- package/dist/chunk-PXDEFEG2.js.map +1 -0
- package/dist/{chunk-YU4WQE5M.cjs → chunk-TAPXWP2B.cjs} +95 -377
- package/dist/chunk-TAPXWP2B.cjs.map +1 -0
- package/dist/{chunk-HXDMZQTD.cjs → chunk-TPOT575P.cjs} +29 -4
- package/dist/{chunk-IB3ZHQAX.js.map → chunk-TPOT575P.cjs.map} +1 -1
- package/dist/commands/index.cjs +2 -2
- package/dist/commands/index.d.cts +1 -1
- package/dist/commands/index.d.ts +1 -1
- package/dist/commands/index.js +1 -1
- package/dist/generation/index.cjs +932 -791
- package/dist/generation/index.cjs.map +1 -1
- package/dist/generation/index.d.cts +266 -240
- package/dist/generation/index.d.ts +266 -240
- package/dist/generation/index.js +926 -785
- package/dist/generation/index.js.map +1 -1
- package/dist/image-editor/index.cjs +266 -2
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +12 -1
- package/dist/image-editor/index.d.ts +12 -1
- package/dist/image-editor/index.js +265 -1
- package/dist/image-editor/index.js.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +16 -16
- package/dist/spreadsheet/index.cjs +3 -3
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.js +16 -16
- package/package.json +2 -1
- package/skills/README.md +55 -0
- package/skills/pixerate-agent-tools/SKILL.md +75 -0
- package/skills/pixerate-animation-editor/SKILL.md +155 -0
- package/skills/pixerate-animation-editor/references/commands.md +123 -0
- package/skills/pixerate-canvas/SKILL.md +230 -0
- package/skills/pixerate-chart/SKILL.md +190 -0
- package/skills/pixerate-diagram/SKILL.md +134 -0
- package/skills/pixerate-generation/SKILL.md +109 -0
- package/skills/pixerate-image-editor/SKILL.md +139 -0
- package/skills/pixerate-parameters/SKILL.md +83 -0
- package/skills/pixerate-rich-text/SKILL.md +160 -0
- package/skills/pixerate-spreadsheet/SKILL.md +146 -0
- package/skills/pixerate-vector/SKILL.md +191 -0
- package/skills/pixerate-vector/references/commands.md +138 -0
- package/skills/pixerate-video-editor/SKILL.md +173 -0
- package/dist/chunk-2CJ3LPYQ.js.map +0 -1
- package/dist/chunk-HXDMZQTD.cjs.map +0 -1
- package/dist/chunk-JQ3BB3E6.js.map +0 -1
- package/dist/chunk-UN33YOXW.cjs.map +0 -1
- package/dist/chunk-YU4WQE5M.cjs.map +0 -1
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pixerate-animation-editor
|
|
3
|
+
description: How to author and edit vector animations (motion graphics, logo reveals, animated icons, explainer scenes, UI micro-interactions) in the Pixerate animation editor through its agent tools - artwork SVG with ids, shots of commands (enter, exit, draw, move, rotate, scale, fade, morph, Smart Animate match, follow a path, pulse, shake, wiggle), easing and springs, stagger, camera, beat and voiceover cues, drivers, reusable clips, checking, rendering frames and contact sheets, and exporting to Flair or Lottie. Use when animation tools such as get_animation, insert_shots or edit_animation are available, or when asked to animate, time, ease, stagger or export vector motion.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Pixerate animation editor
|
|
7
|
+
|
|
8
|
+
A scene is **artwork** (an SVG parsed into vector paths and groups, each with an id) plus an
|
|
9
|
+
ordered list of **shots**. A shot optionally moves the camera, plays its `run` of commands,
|
|
10
|
+
then holds (default 600 ms). Commands play one after another unless `"with": "previous"`;
|
|
11
|
+
each has a default length taken from the content (enter 600 ms, exit 450, move 700, draw
|
|
12
|
+
follows the path length), so leave `duration` out unless you mean to change the pace. Every
|
|
13
|
+
frame is a pure function of time.
|
|
14
|
+
|
|
15
|
+
Ids: element ids come from `get_animation` (`elements`) or `find_animation_elements`; shot ids
|
|
16
|
+
are ones you choose (`"intro"`); commands are addressed by shot id plus their index in the run.
|
|
17
|
+
Times are milliseconds, positions are document units of the artwork. Anything that enters
|
|
18
|
+
later is hidden until its `enter`; anything that never enters is visible from the start.
|
|
19
|
+
|
|
20
|
+
For errors, namespaced tool names and the generic command tools, see `pixerate-agent-tools`.
|
|
21
|
+
The full command vocabulary (every type, option and default) is in
|
|
22
|
+
[references/commands.md](references/commands.md).
|
|
23
|
+
|
|
24
|
+
## Working method
|
|
25
|
+
|
|
26
|
+
1. **Read.** `get_animation` for elements, shots with timing, clips, drivers and issues. If
|
|
27
|
+
there is no artwork, `set_animation_artwork_svg` first (give every element you will animate
|
|
28
|
+
an id), or start from `import_flair_effect` / `import_pptx_animation`. For outlined text,
|
|
29
|
+
`get_text_layout` shows the letter, word and line units.
|
|
30
|
+
2. **Plan shots, one idea each.** Write down what the viewer should notice in each shot and in
|
|
31
|
+
what order, then map each beat to a command. Hidden end states (morph / match targets,
|
|
32
|
+
follow paths) must exist in the artwork before you reference them.
|
|
33
|
+
3. **Write in batches.** `insert_shots` for whole shots; `edit_animation` for several related
|
|
34
|
+
edits as one undo step (`dry_run: true` first when unsure; `"$0.indexes[0]"` and
|
|
35
|
+
`"$last.shot"` refer to earlier ops). Refine with `add_commands`, `update_command`,
|
|
36
|
+
`move_command`, `delete_commands`. Use `write_animation` only to replace every shot.
|
|
37
|
+
4. **Fit and cue.** `fit_animation` to hit a length (keep shots whose pace matters). For music
|
|
38
|
+
or voiceover, `set_animation_settings` with `beat` or `narration`, read cues with
|
|
39
|
+
`get_timing_grid`, and give shots `"at": { "beat": n }` or `{ "word": i }`.
|
|
40
|
+
5. **Check.** `check_animation`; fix every error and warning (codes such as `too-fast`,
|
|
41
|
+
`overlap`, `out-of-frame`, `enter-visible`, `cue-missed`). Use `get_motion_path` for
|
|
42
|
+
spacing and arcs as numbers.
|
|
43
|
+
6. **Look.** `render_animation_frame` with `shot` + `at: "end"`, or `times` for a contact sheet,
|
|
44
|
+
plus `onion_skin` / `motion_paths` to see motion in one picture. Render after a batch, not
|
|
45
|
+
after every edit. `seek_animation` shows the person a moment.
|
|
46
|
+
7. **Export** when asked: `export_flair_motion`, `export_flair_effect` (after
|
|
47
|
+
`set_animation_controls`) or `export_lottie`; read the returned notes on what was sampled
|
|
48
|
+
or dropped.
|
|
49
|
+
|
|
50
|
+
## Best practices
|
|
51
|
+
|
|
52
|
+
- **One idea per shot, one focal motion at a time.** Stage the action so the eye knows where
|
|
53
|
+
to look; secondary elements move less, later, or not at all. Use the camera (`frame` a
|
|
54
|
+
node) to direct attention rather than moving everything.
|
|
55
|
+
- **Ease every change.** Arrivals ease out (decelerate into place; the default for `enter`),
|
|
56
|
+
exits ease in (`exit` with `ease: "ease-in"`), moves ease in-out (the default). Use `linear`
|
|
57
|
+
only for mechanical motion (a constant spin, a progress bar) or loops.
|
|
58
|
+
- **Timing by size and distance.** Small UI changes 150-300 ms, element entrances 300-600 ms,
|
|
59
|
+
large moves and camera moves 600-1200 ms. Nothing under 120 ms (`too-fast`). Big things
|
|
60
|
+
move slower than small things.
|
|
61
|
+
- **Anticipation and follow-through.** `ease-in-back` for a wind-up before a fast exit;
|
|
62
|
+
`pop`, `rise`, `ease-out-back` or a spring preset (`spring-gentle`, `spring-quick`) for
|
|
63
|
+
overshoot and settle on arrival. Use `spring-bouncy` sparingly; it reads as playful.
|
|
64
|
+
- **Overlapping action.** Stagger related items 40-120 ms (`stagger`, or `split` with
|
|
65
|
+
`cascade` for text) instead of moving them in lockstep; start secondary motion with
|
|
66
|
+
`"with": "previous"` plus a small `delay` so it trails the lead.
|
|
67
|
+
- **Arcs.** Natural movement curves: use `move` with `via` waypoints (one smooth path) instead
|
|
68
|
+
of chained moves that stop at each point, or `follow` a path node.
|
|
69
|
+
- **Hold long enough to read.** Leave each result on screen (shot `hold`, default 600 ms);
|
|
70
|
+
roughly 250 ms per word for text that must be read, longer for the final frame or logo.
|
|
71
|
+
- **Exaggeration with restraint.** Emphasis (`pulse`, `shake`, `teeter`, `color-pulse`) is for
|
|
72
|
+
one thing that needs attention, once; it returns to rest on its own.
|
|
73
|
+
- **Motion blur** only for genuinely fast motion (`motionBlur: { shutter: 180 }`); it affects the
|
|
74
|
+
stage and rendered frames, not Flair or Lottie exports.
|
|
75
|
+
- **Accessibility.** Avoid flashing: never more than three flashes a second (WCAG 2.3.1), so
|
|
76
|
+
keep `color-pulse` and fades on large areas slow and few. Avoid large-scale parallax, zooms
|
|
77
|
+
and spinning for essential UI motion; ship a reduced-motion alternative (the host should
|
|
78
|
+
swap in a fade or the end state under `prefers-reduced-motion`; this editor does not
|
|
79
|
+
generate one). Loops that run longer than 5 s need a way to pause (WCAG 2.2.2).
|
|
80
|
+
- **Interactive pieces.** For a button or toggle set `trigger` (`click`, `hover`, `press`,
|
|
81
|
+
`scroll`); for a click toggle, make the last shot restore the starting state.
|
|
82
|
+
|
|
83
|
+
## Tool reference
|
|
84
|
+
|
|
85
|
+
### Read
|
|
86
|
+
|
|
87
|
+
| Tool | Use it to |
|
|
88
|
+
| --- | --- |
|
|
89
|
+
| `get_animation` | Start here. Returns name, artwork size, length (ms), loop, elements (id, type, name, parent, bounds, solid paints, live effects with numeric params), every shot with each command's index, start, end and `flairPrimitive`, clips, drivers, controls and an issue summary, plus `readOnly` when edits are refused. `includeElements: false` (default true) skips the element list on large artwork. |
|
|
90
|
+
| `get_shot` | Read one shot as stored (`shot` id) with its start/end and each command's start/end in ms; cheaper than `get_animation` while refining one shot. |
|
|
91
|
+
| `find_animation_elements` | Find elements whose id or name contains `query` (case-insensitive; `limit` default 20, max 200) when the artwork is large. Returns id, type, name, parent, bounds, paints, effects. |
|
|
92
|
+
| `get_text_layout` | Before animating outlined text with `split`: returns the `group`'s lines, words and letter ids in reading order. Errors if the element is not a group of paths (convert text to outlines, one path a letter, and group it). |
|
|
93
|
+
| `get_motion_path` | Check spacing, arcs and landing points as numbers: samples a `node`'s centre (document units) from `from` to `to` ms every `step` ms (default 33, at most 400 samples), with where each moving change starts and ends. |
|
|
94
|
+
| `get_timing_grid` | List beats (number, ms, bar, beat in bar) and narration words (index, text, start, end) between `from` and `to` (`limit` default 200), and which shot plays at each, to choose `at` cues. Empty, with a hint, when no beat grid or narration is set. |
|
|
95
|
+
| `check_animation` | After every batch of writes. Lists issues with a code, severity, shot, command index, node ids, measured vs needed values and how to fix it. Fix errors and warnings; notes are advisory. |
|
|
96
|
+
| `render_animation_frame` | Look at the result: `time` (ms) or `shot` + `at` (`start`, `middle`, `end`; default end). `times` (2-16 moments) makes a labelled contact sheet (`columns` 1-8). `onion_skin` adds ghost frames (`before` default 2, `after` 0, `spacing` ms or `"commands"`); `motion_paths` (true or ids) draws travel paths. SVG by default; `format: "png"` only when the host can rasterize. |
|
|
97
|
+
| `export_flair_motion` | Get the scene as a Flair SvgMotion `{ svg, animate }` with hold, sampled-step count and notes. `fps` (default scene fps, else 30), `curves` and `behaviors` (default true), `flair` target version (default 0.39; older versions get springs, steps, behaviours and curves sampled). |
|
|
98
|
+
| `export_flair_effect` | Get a Flair catalog vector effect (`id` kebab-case, `name`, `description`, `category` default icon, `tags`, plus `curves` / `behaviors` / `flair` as above). Call `set_animation_controls` first so colours become `{{name: color}}` controls. |
|
|
99
|
+
| `export_lottie` | Get Lottie (Bodymovin v5) JSON for lottie-web and mobile players, with a marker per shot, `fps` (default scene fps, else 30), the sampled keyframe count and notes on what was not carried over (gradients, dashes, reveal clips, morphs that change point counts). |
|
|
100
|
+
|
|
101
|
+
### Write
|
|
102
|
+
|
|
103
|
+
| Tool | Use it to |
|
|
104
|
+
| --- | --- |
|
|
105
|
+
| `seek_animation` | Show the person a moment: `time` (ms) or the start of a `shot`, with `play` true or false. Does not change the scene. |
|
|
106
|
+
| `set_animation_artwork_svg` | Replace the artwork with a standalone `svg` (with a viewBox) as one undo step. Put an id on every element you will animate; refused if existing shots name ids the new artwork lacks. Returns the elements. |
|
|
107
|
+
| `import_pptx_animation` | Replace the whole scene with a PowerPoint slide's shapes and animation pane (`data` base64 .pptx, `slide` default 1): one shot per click, delays, repeats and acceleration kept; text, pictures and charts are left out with notes. Run with `dry_run: true` first. |
|
|
108
|
+
| `set_animation_drivers` | Replace all drivers (empty list clears): a target's `x`, `y`, `rotation`, `scaleX`, `scaleY` or `opacity` follows a source node's property as change · `factor` + `offset`, optionally `clamp`ed. For parallax, wheels that turn as they roll, shadows that fade as something rises. |
|
|
109
|
+
| `set_animation_clip` | Define, replace or (with `clip: null`) delete a named reusable clip whose `run` targets `"$"`; play it with a `play` command on any nodes. Prefer a clip over repeated identical commands. |
|
|
110
|
+
| `copy_animation` | Give the nodes in `to` every command that animates `from` (all shots or `shots`), each copy starting with its original, optionally `stagger`ed (ms). Quick for one-off duplication; use a clip for motion you will reuse. |
|
|
111
|
+
| `fit_animation` | Make the scene last `seconds` by setting shot `speed`, keeping proportions; shots in `keep` play as written. `dry_run: true` reports the new length and speeds first. |
|
|
112
|
+
| `import_flair_effect` | Replace the whole scene with a Flair vector `effect` or SvgMotion `motion` (give exactly one; optional `name`). Placeholders become colour controls; each Flair step becomes a shot. Use `dry_run: true` first. |
|
|
113
|
+
| `insert_shots` | Add one or more complete shots (`id`, `run`, optional `label`, `camera`, `hold`, `speed`, `at`) at position `at` (default the end). Returns every shot's timing and issues. |
|
|
114
|
+
| `update_shot` | Change one shot's `label`, `camera`, `run`, `hold`, `speed`, `at` or `id` via `set`, and clear `label`, `camera`, `hold`, `speed` or `at` via `remove`. |
|
|
115
|
+
| `delete_shots` | Remove shots by id (one undo step). |
|
|
116
|
+
| `move_shot` | Reorder a shot to index `to` (0 = first). |
|
|
117
|
+
| `add_commands` | Add commands to a shot's run at index `at` (default the end). Returns the indexes they got and their timing; use those indexes for later updates. |
|
|
118
|
+
| `update_command` | Change one command (by `shot` and `command` index): fields in `set` replace, names in `remove` clear (e.g. `"delay"`). Returns the command and its timing. |
|
|
119
|
+
| `delete_commands` | Remove commands from a shot by index; later commands move up, so re-read indexes afterwards. |
|
|
120
|
+
| `move_command` | Move one command to index `to` in its run; a `"with": "previous"` command then starts with its new neighbour. |
|
|
121
|
+
| `set_animation_settings` | Set `name`, `description`, `loop` (none, loop, ping-pong), `trigger` (click, hover, press, scroll, or null), export `fps` (default 30), scene `steps` (12 = on twos; null smooth), `motionBlur`, `beat` (`bpm`, `offset`, `meter`), `narration` word timings, or `target` length [min, max] seconds. |
|
|
122
|
+
| `set_animation_controls` | Set the colour controls (`name`, `type: "color"`, `default` #rrggbb used in the scene, `label`) and `presets` a Flair effect exposes. Replaces existing controls; an empty list clears. |
|
|
123
|
+
| `edit_animation` | Apply several ops (`set_settings`, `insert_shots`, `update_shot`, `delete_shots`, `move_shot`, `add_commands`, `update_command`, `move_command`, `delete_commands`, `set_controls`) as one all-or-nothing undo step; refer to earlier outcomes with `"$0.indexes[0]"`, `"$last.shot"`. `dry_run: true` validates without applying. The default for multi-step changes. |
|
|
124
|
+
| `write_animation` | Replace every shot (and optionally settings, controls, presets) while keeping the artwork. Only for a full rewrite; per-operation tools give better errors. |
|
|
125
|
+
| `undo_animation` | Undo your last edit (one tool call or one `edit_animation` batch). |
|
|
126
|
+
| `redo_animation` | Redo the edit you just undid. |
|
|
127
|
+
|
|
128
|
+
## Pitfalls
|
|
129
|
+
|
|
130
|
+
- **Unknown ids are refused** with a "did you mean" suggestion. Take ids from `get_animation` or
|
|
131
|
+
the elements `set_animation_artwork_svg` returns; never guess them.
|
|
132
|
+
- **`enter-visible`**: an element that enters while already showing blinks out first. Give an
|
|
133
|
+
element that should appear later an `enter` before anything else moves it; do not `enter` an
|
|
134
|
+
element that should be visible from the start. `exit-hidden` is the reverse: enter it first.
|
|
135
|
+
- **`overlap`**: two commands changing the same property at once; the later takes over. Sequence
|
|
136
|
+
them, or use `"blend": "add"` on move, rotate or scale to stack. Emphasis already stacks.
|
|
137
|
+
- **Reveals need a box**: `wipe`, `iris`, `split` on a lone straight line fade instead
|
|
138
|
+
(`reveal-no-box`); use `draw` / `undraw` for lines.
|
|
139
|
+
- **Morph and match targets stay hidden.** Draw the end state as a separate hidden node or group;
|
|
140
|
+
for `match`, parts the end state adds need a partner (same name) in the start group, or they
|
|
141
|
+
never appear (`match-unpaired`).
|
|
142
|
+
- **Draw a group one way.** Do not mix per-stroke drawing (`order`, `pace`, `comet`) with a plain
|
|
143
|
+
`draw` on the same group in one scene.
|
|
144
|
+
- **Indexes shift.** After `delete_commands` or `move_command`, indexes change; use what the write
|
|
145
|
+
returned or `get_shot` before the next index-based edit.
|
|
146
|
+
- **Springs set their own length.** Leave `duration` out with a spring; a short `duration` cuts it
|
|
147
|
+
off (`spring-cut-short`).
|
|
148
|
+
- **Click triggers** play nothing until the first click; each click plays the next shot. A
|
|
149
|
+
triggered scene ignores `loop` (`trigger-loop`), and clicks decide when shots start, so do not
|
|
150
|
+
give its shots `at` cues (`click-cue`).
|
|
151
|
+
- **Exports approximate.** Motion blur is never exported; Lottie drops gradients, dashes and reveal
|
|
152
|
+
clips; back eases on colours or opacity are sampled for Flair. Read the notes and tell the
|
|
153
|
+
user what changed.
|
|
154
|
+
- **Read-only**: when `get_animation` returns `readOnly`, write tools are hidden; read, render and
|
|
155
|
+
export still work. Tell the user rather than working around it.
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Animation command vocabulary
|
|
2
|
+
|
|
3
|
+
Every command is an object with a `type` and (except `wait`) `targets`: element ids from
|
|
4
|
+
`get_animation`. A group animates as one. Times are ms, distances document units, angles
|
|
5
|
+
degrees clockwise. Commands share names and defaults with Flair's motion primitives
|
|
6
|
+
(`get_animation` shows each command's `flairPrimitive`).
|
|
7
|
+
|
|
8
|
+
## Fields every command takes
|
|
9
|
+
|
|
10
|
+
- `targets`: element ids (at least one).
|
|
11
|
+
- `duration`: length per target. Leave it out: each type has a default (below) and `draw`
|
|
12
|
+
follows the path length. With `repeat`, it is one cycle.
|
|
13
|
+
- `delay`: wait before starting (default 0).
|
|
14
|
+
- `stagger`: start each further target this much later (default 0).
|
|
15
|
+
- `with`: `"after"` (default) starts when the commands before it finish; `"previous"` starts
|
|
16
|
+
together with the command before.
|
|
17
|
+
- `ease`: a preset (`linear`, `ease`, `ease-in`, `ease-out`, `ease-in-out`, `ease-in-back`,
|
|
18
|
+
`ease-out-back`, `ease-out-elastic`, `ease-in-elastic`, `ease-in-out-elastic`, `elastic`,
|
|
19
|
+
`spring`, `spring-gentle`, `spring-quick`, `spring-bouncy`, `spring-slow`, `hold`), or
|
|
20
|
+
`{ "type": "cubic-bezier", x1, y1, x2, y2 }`, `{ "type": "spring", stiffness (170),
|
|
21
|
+
damping (26), mass (1), velocity (0) }`, `{ "type": "elastic", amplitude (1), period (0.3),
|
|
22
|
+
mode (out | in | in-out) }`. Default: cubic ease-out for entrances, ease-in-out for moves.
|
|
23
|
+
A spring with no `duration` lasts until it settles.
|
|
24
|
+
- `note`: why the command is there, in a few words.
|
|
25
|
+
- `split`: `letter`, `word` or `line` for outlined text (a group of letter paths), staggered
|
|
26
|
+
40 / 120 / 300 ms per unit; `cascade`: `forward` (default), `backward`, `center`, `edges`,
|
|
27
|
+
`random` (deterministic).
|
|
28
|
+
- `repeat` (1-1000, not for enter or exit) and `repeatMode`: `loop` (default), `mirror`
|
|
29
|
+
(every other cycle backwards), `offset` (carry on: rotate by 90 with repeat 4 is a full turn).
|
|
30
|
+
- `steps`: hold poses on a grid of this many frames per second (12 = on twos).
|
|
31
|
+
|
|
32
|
+
## Default lengths (ms)
|
|
33
|
+
|
|
34
|
+
enter 600, exit 450, move 700 (+400 per `via` point), rotate 700, scale 500, fade 400,
|
|
35
|
+
style 500, morph 900, match 900, follow 1400, pulse 600, shake 500, teeter 600, wave 1000,
|
|
36
|
+
wiggle 1500, color-pulse 600, effect 900, play (the clip's own length). Shot hold 600,
|
|
37
|
+
camera move 1000.
|
|
38
|
+
|
|
39
|
+
## Entrances and exits
|
|
40
|
+
|
|
41
|
+
- `enter` brings hidden targets in. `style`:
|
|
42
|
+
- `fade` (default); `pop` (scales up past full size and settles; `scale` start, default 0.5);
|
|
43
|
+
`grow` (from nothing); `slide` (`direction` of travel, default up; `distance` default 40);
|
|
44
|
+
`draw` (outline drawn on, then the fill fades in); `zoom` (settles from larger; `scale`
|
|
45
|
+
default 1.6); `rise` (rises a short way, overshooting a touch; `distance` default 20).
|
|
46
|
+
- Reveals through a clip over the target's box: `wipe` (edge travels `direction`, default
|
|
47
|
+
right), `iris` (from the centre; `shape` circle or box), `split` (from a line through the
|
|
48
|
+
middle; `orientation` horizontal or vertical). Need a box with width and height.
|
|
49
|
+
- Drawing options for groups: `order` (`together` default, or `sequence`), `pace` (`time`
|
|
50
|
+
or `speed`), `align` (`start` / `end`, with speed), `sortBy` (`document` or `distance`,
|
|
51
|
+
with sequence), `origin` { x, y } for a radial reveal.
|
|
52
|
+
- `exit` takes targets out. `style`: `fade` (default), `shrink`, `slide` (default down,
|
|
53
|
+
`distance` 40), `undraw`, `wipe`. Same drawing options as enter.
|
|
54
|
+
|
|
55
|
+
## Pose and paint
|
|
56
|
+
|
|
57
|
+
- `move`: `by` { x, y } offset or `to` { x, y } for the centre. `via`: up to 64 waypoints the
|
|
58
|
+
centre passes through smoothly without overshoot; `pacing` `even` (default, steady speed)
|
|
59
|
+
or `equal` (same time per stretch). `blend` default replace.
|
|
60
|
+
- `rotate`: `by` degrees or `to` degrees from rest. `blend` default replace.
|
|
61
|
+
- `scale`: `to` a factor or { x, y } (required); `geometric: true` for an even-rate zoom.
|
|
62
|
+
- `fade`: `to` opacity 0-1 (required).
|
|
63
|
+
- `style`: blends solid `fill`, `stroke` (CSS colours, mixed in OKLab) and `strokeWidth`. On a
|
|
64
|
+
group it changes every path in it.
|
|
65
|
+
- `draw`: draws strokes to `to` (default 1) from `from` (default what is drawn now);
|
|
66
|
+
`comet`: a travelling stroke this fraction long that runs off the end. Drawing options as
|
|
67
|
+
enter.
|
|
68
|
+
|
|
69
|
+
## Shape change and paths
|
|
70
|
+
|
|
71
|
+
- `morph`: each target takes the shape and paint of node `into` (keep `into` hidden).
|
|
72
|
+
- `match` (Smart Animate): tweens a group into group `into`, part by part. Parts pair by name,
|
|
73
|
+
then by id with the group ids taken out (`card-a-title` and `card-b-title`), then by kind in
|
|
74
|
+
order. Unpaired parts fade out; parts of `into` with no partner never appear.
|
|
75
|
+
- `follow`: moves targets along path node `path` (it can be hidden), `from` / `to` fractions
|
|
76
|
+
(default 0 / 1); `rotate: true` turns with the path, and moves or shakes made meanwhile turn
|
|
77
|
+
with it.
|
|
78
|
+
|
|
79
|
+
## Emphasis (returns to rest; `blend` default add, so it stacks on other motion)
|
|
80
|
+
|
|
81
|
+
- `pulse`: scales up and back; `amount` extra scale (0.15), `count` (1).
|
|
82
|
+
- `shake`: side to side, settling; `amount` (8), `count` (3), `axis` horizontal or vertical.
|
|
83
|
+
- `teeter`: rocks about the centre; `angle` (8), `count` (3).
|
|
84
|
+
- `wave`: bobs without settling; `amount` (6), `count` (2).
|
|
85
|
+
- `wiggle`: smooth seeded noise; `amount` (6), `frequency` Hz (3), `octaves` (2), `rotate`
|
|
86
|
+
degrees (0), `seed` (default from the target id; the same seed wanders the same way).
|
|
87
|
+
- `color-pulse`: tints `fill` or `stroke` (`paint`) toward `color` (default #f59e0b) and back;
|
|
88
|
+
`count` (1).
|
|
89
|
+
|
|
90
|
+
`blend: "add"` on move, rotate or scale makes them a stacking layer too (what they add stays);
|
|
91
|
+
`blend: "replace"` on emphasis makes it take over instead.
|
|
92
|
+
|
|
93
|
+
## Other
|
|
94
|
+
|
|
95
|
+
- `effect`: tweens numeric `param` of live path effect `effect` (ids from the element's
|
|
96
|
+
`effects` in `get_animation`) `to` a value.
|
|
97
|
+
- `play`: plays clip `clip` (defined with `set_animation_clip`, commands targeting `"$"`) on
|
|
98
|
+
the targets; `speed` (0.05-20, default 1), `delay`, `stagger`, `with`. Clips cannot play clips.
|
|
99
|
+
- `wait`: waits `duration` ms (no targets).
|
|
100
|
+
|
|
101
|
+
## Shots
|
|
102
|
+
|
|
103
|
+
`{ id, run, label?, camera?, hold?, speed?, at? }`
|
|
104
|
+
|
|
105
|
+
- `id` matches `^[A-Za-z0-9_][\w.-]*$` and is unique.
|
|
106
|
+
- `camera`: `{ x, y, width, height }` or `{ frame: "<node id>", padding (24) }`, with `ms`
|
|
107
|
+
(default 1000), `ease`, `geometric`. The first shot cuts to its camera.
|
|
108
|
+
- `hold`: ms after the commands (default 600).
|
|
109
|
+
- `speed`: plays the whole shot this many times as fast (0.05-20; `fit_animation` sets it).
|
|
110
|
+
- `at`: `{ beat: n }` (2.5 is the "and" of beat 3), `{ word: i }` or `{ ms: t }`; the shot
|
|
111
|
+
before holds until the cue. Needs a `beat` grid or `narration` set with
|
|
112
|
+
`set_animation_settings`; `check_animation` reports `cue-missed` when the previous shot runs
|
|
113
|
+
past it.
|
|
114
|
+
|
|
115
|
+
## Drivers
|
|
116
|
+
|
|
117
|
+
`set_animation_drivers({ drivers: [{ target, property, source: { node, property }, factor (1),
|
|
118
|
+
offset (0), clamp: [min, max] }] })`, properties `x`, `y`, `rotation`, `scaleX`, `scaleY`,
|
|
119
|
+
`opacity`. The target's change from rest = source change · factor + offset, added to offsets
|
|
120
|
+
and turns, multiplied into scales and opacity, on top of the target's own commands. Examples:
|
|
121
|
+
parallax (`x` follows `x` · 0.5), a rolling wheel (`rotation` follows `x` · 360 / (2π · radius)),
|
|
122
|
+
a shadow that fades as a ball rises (`opacity` follows `y` · 0.005). Cycles are reported by
|
|
123
|
+
`check_animation` (`driver-cycle`).
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pixerate-canvas
|
|
3
|
+
description: How to build and edit a Pixerate design canvas or node graph through its agent tools - adding, connecting, updating and laying out nodes (canvas_add_node, canvas_layout), reading state with get_editor_state and looking at it with view_editor, reusable components with variants, instances and overrides (create_component, add_variant, set_instance_properties), align, distribute, lock and layer order, shape boolean operations (unite, subtract, offset path, outline stroke), auto layout frames, and keyframe animation with easing and CSS export. Use when working on a canvas, whiteboard, flow chart, node graph, frame, design system, component library, button variants, layout, alignment, z-order or a canvas animation in a Pixerate editor.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Pixerate canvas
|
|
7
|
+
|
|
8
|
+
The canvas is an xyflow (React Flow / SvelteFlow) graph: an array of **nodes** and **edges**.
|
|
9
|
+
A node is `{ id, type, position: { x, y }, width?, height?, parentId?, zIndex?, data }`; edges are
|
|
10
|
+
`{ id, source, target, label? }`. Everything a design feature knows lives in `node.data`, so it
|
|
11
|
+
survives copy, paste and JSON:
|
|
12
|
+
|
|
13
|
+
- `data.label` / `data.name`: text content and layer name. `data.shape`: a shape node
|
|
14
|
+
(`{ kind: rect | ellipse | polygon | star | path, fill, stroke, strokeWidth, ... }`).
|
|
15
|
+
- `data.layout`: an auto layout frame (`mode` horizontal / vertical / grid, `gap`, `padding`,
|
|
16
|
+
`alignMain`, `alignCross`, `sizing`); its children are the nodes whose `parentId` is the frame,
|
|
17
|
+
in node-array order. `data.childLayout`: a child's sizing (fixed / hug / fill) and constraints.
|
|
18
|
+
- `data.component` (a main component), `data.componentSet` (a set of variants),
|
|
19
|
+
`data.instance` (`{ componentId, properties }`) and `data.componentOverrides`.
|
|
20
|
+
- `data.locked`, `data.animation` (keyframe tracks), `data.tokenBindings` (design tokens).
|
|
21
|
+
|
|
22
|
+
Positions are in canvas (flow) units; a child's position is relative to its parent. Node ids come
|
|
23
|
+
from `get_editor_state`; component and set ids from `list_components`. Tools that take `ids` or
|
|
24
|
+
`id` default to the current selection when you leave them out, so pass ids explicitly unless you
|
|
25
|
+
just selected with `canvas_select`. See `pixerate-agent-tools` for namespacing, `run_commands`
|
|
26
|
+
batching and error codes.
|
|
27
|
+
|
|
28
|
+
## Working method
|
|
29
|
+
|
|
30
|
+
1. **Read.** `get_editor_state` with `includeDocument: false` returns `canvas.nodes` and
|
|
31
|
+
`canvas.edges`. For a design system also call `list_components`, and `inspect_instance` before
|
|
32
|
+
changing an instance.
|
|
33
|
+
2. **Plan the structure first**: which frames, which reusable components and variants, what
|
|
34
|
+
spacing scale. Build the main component once, then place instances; do not copy nodes by hand.
|
|
35
|
+
3. **Write.** Use the dedicated tools for graph edits (`canvas_add_node`, `canvas_connect`,
|
|
36
|
+
`canvas_update_node`) and components (`create_component`, `create_instance`, ...). Use
|
|
37
|
+
`run_commands` with `atomic: true` for arrange, shape and animation commands, and whenever
|
|
38
|
+
several steps should be one undo step (a param `"$0.ids[0]"` uses an id an earlier step returned).
|
|
39
|
+
4. **Tidy.** `canvas_layout` for graphs; `canvas.align*` / `canvas.distribute*` for designs;
|
|
40
|
+
layer order with `canvas.bringToFront` and friends; lock finished backgrounds with `canvas.lock`.
|
|
41
|
+
5. **Look.** `view_editor` (default viewport, JPEG, 1024 px) once a batch is done; use
|
|
42
|
+
`scope: "canvas"` for the whole drawing. Fix overlaps, misalignment and clipped text, then show
|
|
43
|
+
the user with `canvas_select` or `canvas_highlight`.
|
|
44
|
+
|
|
45
|
+
## Best practices
|
|
46
|
+
|
|
47
|
+
- **Design-system thinking.** Anything that appears twice should be a component: build one main,
|
|
48
|
+
`combine_as_variants` for states and sizes (`State=Default`, `State=Hover`, `Size=Small`), then
|
|
49
|
+
`create_instance` everywhere. Change the main to change every instance; use overrides only for
|
|
50
|
+
per-use content (label text, an icon swap). Name variant properties and values consistently
|
|
51
|
+
(Title Case property, short values) and keep combinations unique.
|
|
52
|
+
- **Name layers that must survive a variant switch** with a stable `data.name`. Matching falls
|
|
53
|
+
back to `data.label`, which for text is its content and differs between variants.
|
|
54
|
+
- **Use component properties, not detaching.** Switch variants and set text or boolean
|
|
55
|
+
properties with `set_instance_properties`; `swap_instance` for another component. Detach only
|
|
56
|
+
when the instance must stop following its main.
|
|
57
|
+
- **Spacing scale.** Pick a base unit (4 or 8) and use multiples for gaps and padding. Put rows
|
|
58
|
+
and stacks in auto layout frames (`data.layout`) instead of positioning children by hand, so
|
|
59
|
+
they reflow when content changes.
|
|
60
|
+
- **Alignment and distribution.** Align to a shared edge or centre, then distribute with equal
|
|
61
|
+
gaps; a design reads as ordered when edges line up. Lock a node you want as the anchor: locked
|
|
62
|
+
nodes never move but still count towards the selection bounds.
|
|
63
|
+
- **Layering.** Backgrounds at the back, content above, overlays on top. Use the restack
|
|
64
|
+
commands; they set `zIndex` per sibling group and never reorder the array.
|
|
65
|
+
- **Graph layout.** Lay flows out in one direction (`LR` for pipelines, `TB` for hierarchies),
|
|
66
|
+
keep edges short, label edges only when the relationship is not obvious.
|
|
67
|
+
- **Motion.** Use ease-out (or `ease-out-back` for a little overshoot) for things arriving,
|
|
68
|
+
ease-in for things leaving, ease-in-out for moves between two resting places, and `linear` only
|
|
69
|
+
for continuous motion such as rotation. Keep UI transitions around 150 to 400 ms and entrances
|
|
70
|
+
under about 600 ms; stagger related elements by 30 to 80 ms with `delay` rather than moving
|
|
71
|
+
everything at once. Animate `opacity`, `x`, `y`, `scale` and `rotation`; colour tweens
|
|
72
|
+
interpolate in OKLab.
|
|
73
|
+
|
|
74
|
+
## Tool reference
|
|
75
|
+
|
|
76
|
+
### Read
|
|
77
|
+
|
|
78
|
+
| Tool | Use it to |
|
|
79
|
+
| --- | --- |
|
|
80
|
+
| `get_editor_state` | Read the canvas graph (`canvas.nodes`, `canvas.edges`) and, by default, the prompt document too. Pass `includeDocument: false` on a canvas-only task to keep the result small, `includeCanvas: false` for only the prompt. Call it first and again after edits made by the user. |
|
|
81
|
+
| `view_editor` | Get an image of the editor: `scope` `viewport` (default) or `canvas` (the whole drawing's bounds), `format` `jpeg` (default) or `png`, `maxEdge` in pixels (default 1024). Use it after a batch to judge overlap, balance and legibility; agent cursors are left out. |
|
|
82
|
+
| `list_components` | List main components (id, name, variant values, instance count) and component sets with their variant options. Call it before `create_instance`, `swap_instance` or any variant tool to get ids and the exact property names and values. |
|
|
83
|
+
| `inspect_instance` | Describe one instance (or a layer inside it; default the first selected node): its main, variant, component property values with types, and per-layer overrides. Call it before `set_instance_properties` or `reset_overrides` so you use the right property names and override groups. |
|
|
84
|
+
|
|
85
|
+
### Write: graph
|
|
86
|
+
|
|
87
|
+
| Tool | Use it to |
|
|
88
|
+
| --- | --- |
|
|
89
|
+
| `canvas_add_node` | Add a node: `node` (`id` optional and must be unused, `type` registered by the host, `data`, `position`, `width`, `height`, `parentId` for a frame). Leave `position` out to auto-place it without overlaps beside `nearNodeId` on `side` (default `right`), which also connects an edge from that node, or beside the last node. Returns the new node id and edge id. |
|
|
90
|
+
| `canvas_connect` | Add an edge from `source` to `target` (two different existing nodes), with an optional `label`. Returns the edge id. |
|
|
91
|
+
| `canvas_update_node` | Merge fields into a node's `data` (for example `{ "label": "Checkout" }`). Treat the merge as shallow: pass nested objects such as `shape` or `layout` whole. It does not move or resize nodes. |
|
|
92
|
+
| `canvas_remove_nodes` | Delete nodes and their edges; every id must exist. Destructive: confirm with the user before removing content they made. |
|
|
93
|
+
| `canvas_layout` | Arrange the graph automatically: `direction` `LR` (default), `TB`, `RL` or `BT`. `incremental` (default true) keeps nodes that already have a position; pass `false` to re-lay everything. Nodes at exactly (0, 0) count as unplaced. |
|
|
94
|
+
| `canvas_select` | Replace the selection (an empty list clears it). Use it to show the user a result and to target commands that act on the selection. |
|
|
95
|
+
| `canvas_highlight` | Flash nodes to point the user at them: `color` (default `#3b82f6`), `durationMs` (default 2000, max 60000). Changes nothing. |
|
|
96
|
+
|
|
97
|
+
### Write: components
|
|
98
|
+
|
|
99
|
+
These are strict-schema tools. Each returns `{ ids }` of what it created or changed, or fails with
|
|
100
|
+
the reason (for example a variant combination that already exists, or a cycle).
|
|
101
|
+
|
|
102
|
+
| Tool | Use it to |
|
|
103
|
+
| --- | --- |
|
|
104
|
+
| `create_component` | Turn one frame-like node (`ids`) into a main component, or wrap several sibling layers in a new component frame. Returns the component id. |
|
|
105
|
+
| `combine_as_variants` | Wrap sibling components in a component set. Names already in `Property=Value` form become variant values; others get `Property 1=Default`, `Variant2`, ... Rename afterwards with `rename_variant_property` / `rename_variant_value`. |
|
|
106
|
+
| `create_instance` | Place an instance of `componentId` (a component, or a set's default variant), optionally inside frame `parentId`, at `x` / `y` (canvas coordinates, or relative to the parent), with `properties` (variant and component property values). Returns the instance id. |
|
|
107
|
+
| `set_instance_properties` | Set property values on instances (`ids`): a variant property switches the variant (compatible overrides kept), a boolean toggles a layer, a text property sets text, an instance-swap property takes a component id. Get names from `inspect_instance`. |
|
|
108
|
+
| `swap_instance` | Make instances show another component (`componentId`), keeping overrides on layers whose names match. |
|
|
109
|
+
| `reset_overrides` | Reset overrides of a whole instance (default), of one layer (pass the layer as `id`), or one `group` such as `data.label` or `shape.fill`. Destructive. |
|
|
110
|
+
| `push_overrides` | Copy an instance's overrides to its main component, and so to every other instance. Destructive for other instances' look: use it only when the user wants the change everywhere. |
|
|
111
|
+
| `detach_instance` | Turn instances into plain frames that keep their look and stop following the main. Destructive; prefer properties or `swap_instance`. |
|
|
112
|
+
| `go_to_main_component` | Select an instance's main component and get its id, to edit the main itself. |
|
|
113
|
+
| `restore_main_component` | Recreate a deleted main component from one of its instances (its old id comes back, so other instances re-link). |
|
|
114
|
+
| `add_variant` | Add a variant to set `setId` by duplicating `from` (default the set's default variant) with new `variant` values such as `{ "State": "Hover" }`; unnamed properties keep the source's values, a new property name is added to every variant as `Default`. `x` / `y` are optional (default next to the source). Without values the next `VariantN` is used. |
|
|
115
|
+
| `remove_variant` | Remove variant `id` from its set (never the last one); its instances switch to the closest remaining variant, keeping overrides. Destructive. |
|
|
116
|
+
| `set_variant_properties` | Merge `values` into variant `id`'s property values. A combination another variant has is refused. |
|
|
117
|
+
| `rename_variant_property` | Rename property `name` to `newName` across a set; instances keep their variant. |
|
|
118
|
+
| `rename_variant_value` | Rename `value` of `property` to `newValue` across a set; instances keep their variant. |
|
|
119
|
+
|
|
120
|
+
## Commands
|
|
121
|
+
|
|
122
|
+
Run these through `run_command` / `run_commands`. Each takes `ids` (default: the selection) unless
|
|
123
|
+
noted, is one undo step, and reports in `list_commands` why it cannot run.
|
|
124
|
+
|
|
125
|
+
### Arrange
|
|
126
|
+
|
|
127
|
+
| Command | Use it to |
|
|
128
|
+
| --- | --- |
|
|
129
|
+
| `canvas.alignLeft` | Align the left edges of two or more nodes to the selection bounds. |
|
|
130
|
+
| `canvas.alignCenter` | Align horizontal centres (a vertical centre line). |
|
|
131
|
+
| `canvas.alignRight` | Align right edges. |
|
|
132
|
+
| `canvas.alignTop` | Align top edges. |
|
|
133
|
+
| `canvas.alignMiddle` | Align vertical centres (a horizontal centre line). |
|
|
134
|
+
| `canvas.alignBottom` | Align bottom edges. |
|
|
135
|
+
| `canvas.distributeHorizontal` | Give three or more nodes equal horizontal gaps; the outermost stay put. |
|
|
136
|
+
| `canvas.distributeVertical` | Give three or more nodes equal vertical gaps. |
|
|
137
|
+
| `canvas.lock` | Lock nodes: they cannot be moved, resized, restacked, deleted or combined, but stay selectable and act as alignment anchors. |
|
|
138
|
+
| `canvas.unlock` | Unlock nodes, restoring their previous drag and delete flags. |
|
|
139
|
+
| `canvas.bringForward` | Move nodes one step up among their siblings (past the next overlapping sibling). |
|
|
140
|
+
| `canvas.sendBackward` | Move nodes one step down among their siblings. |
|
|
141
|
+
| `canvas.bringToFront` | Put nodes on top of their siblings. |
|
|
142
|
+
| `canvas.sendToBack` | Put nodes below their siblings (backgrounds). |
|
|
143
|
+
|
|
144
|
+
### Shapes
|
|
145
|
+
|
|
146
|
+
These act on shape nodes (`data.shape`) and replace their inputs with a new `path` shape (curves
|
|
147
|
+
are kept exactly). They need unlocked shapes; other selected nodes are ignored.
|
|
148
|
+
|
|
149
|
+
| Command | Use it to |
|
|
150
|
+
| --- | --- |
|
|
151
|
+
| `canvas.unite` | Merge two or more shapes into one outline. |
|
|
152
|
+
| `canvas.intersect` | Keep only the area all shapes share; refused when they do not overlap. |
|
|
153
|
+
| `canvas.subtract` | Cut every other shape out of the back-most one (stacking order decides which is the base). |
|
|
154
|
+
| `canvas.exclude` | Keep the areas covered an odd number of times (XOR). |
|
|
155
|
+
| `canvas.divide` | Split overlapping shapes into one shape per region, each painted like the top shape covering it. |
|
|
156
|
+
| `canvas.offsetPath` | Grow (`distance` > 0) or shrink (< 0) shapes by `distance` canvas units (default 10), with `join` `miter` (default), `round` or `bevel` and `miterLimit` (default 4). |
|
|
157
|
+
| `canvas.outlineStroke` | Turn shapes' strokes into filled shapes: `join` (default miter), `cap` `butt` (default), `round` or `square`, `miterLimit` (default 4). The fill stays as a separate shape below. |
|
|
158
|
+
|
|
159
|
+
### Components (command form)
|
|
160
|
+
|
|
161
|
+
The same operations as the component tools, for command palettes and `run_commands` batches.
|
|
162
|
+
Prefer the dedicated tool for a single operation: its schema is strict and its errors precise. Use
|
|
163
|
+
the command when you need it inside an atomic batch with arrange or animation steps, or when the
|
|
164
|
+
host registered only commands.
|
|
165
|
+
|
|
166
|
+
| Command | Use it to |
|
|
167
|
+
| --- | --- |
|
|
168
|
+
| `canvas.listComponents` | Read-only; same result as `list_components`. |
|
|
169
|
+
| `canvas.inspectInstance` | Read-only; same as `inspect_instance` (`id`). |
|
|
170
|
+
| `canvas.createComponent` | Same as `create_component` (`ids`). |
|
|
171
|
+
| `canvas.combineAsVariants` | Same as `combine_as_variants` (`ids`). |
|
|
172
|
+
| `canvas.createInstance` | Same as `create_instance` (`componentId`, `parentId`, `x`, `y`, `properties`). |
|
|
173
|
+
| `canvas.setInstanceProperties` | Same as `set_instance_properties` (`properties`, `ids`). |
|
|
174
|
+
| `canvas.swapInstance` | Same as `swap_instance` (`componentId`, `ids`). |
|
|
175
|
+
| `canvas.resetOverrides` | Same as `reset_overrides` (`id`, `group`). |
|
|
176
|
+
| `canvas.pushOverrides` | Same as `push_overrides` (`id`). |
|
|
177
|
+
| `canvas.detachInstance` | Same as `detach_instance` (`ids`). |
|
|
178
|
+
| `canvas.goToMainComponent` | Same as `go_to_main_component` (`id`). |
|
|
179
|
+
| `canvas.restoreMainComponent` | Same as `restore_main_component` (`id`). |
|
|
180
|
+
| `canvas.addVariant` | Same as `add_variant` (`setId`, `from`, `variant`, `x`, `y`). |
|
|
181
|
+
| `canvas.removeVariant` | Same as `remove_variant` (`id`). |
|
|
182
|
+
| `canvas.setVariantProperties` | Same as `set_variant_properties` (`values`, `id`). |
|
|
183
|
+
| `canvas.renameVariantProperty` | Same as `rename_variant_property` (`name`, `newName`, `setId`). |
|
|
184
|
+
| `canvas.renameVariantValue` | Same as `rename_variant_value` (`property`, `value`, `newValue`, `setId`). |
|
|
185
|
+
|
|
186
|
+
### Animation
|
|
187
|
+
|
|
188
|
+
A node's animation is a set of property tracks of keyframes `{ time (ms), value, easing }`; the
|
|
189
|
+
easing applies to the segment leaving a keyframe. Animatable properties: `x`, `y`, `width`,
|
|
190
|
+
`height`, `rotation` (degrees), `scale`, `opacity` (0 to 1), `fill`, `stroke`, `strokeWidth`,
|
|
191
|
+
`cornerRadius`, `motionPath` (0 to 1). Easings: `linear`, `ease`, `ease-in`, `ease-out`,
|
|
192
|
+
`ease-in-out`, `ease-in-back`, `ease-out-back`, `spring`, `hold`, or `cubic-bezier(x1, y1, x2, y2)`.
|
|
193
|
+
|
|
194
|
+
| Command | Use it to |
|
|
195
|
+
| --- | --- |
|
|
196
|
+
| `canvas.animation.animateNode` | The main authoring command: animate `nodeId` from `from` (default: its current values) to `to` over `duration` ms (default 1000), starting at `delay` ms (default 0), with `easing`. Stagger several nodes with increasing `delay` in one atomic `run_commands`. |
|
|
197
|
+
| `canvas.animation.addKeyframe` | Key nodes (`ids`, default selected) at `time` ms (default the playhead): the listed `properties`, else their animated ones, else `x` and `y`. Set the node's values first, then key. |
|
|
198
|
+
| `canvas.animation.setEasing` | Set `easing` on the segments leaving the selected keyframes. Needs a keyframe selection. |
|
|
199
|
+
| `canvas.animation.deleteKeyframes` | Delete the selected keyframes. Needs a keyframe selection. |
|
|
200
|
+
| `canvas.animation.seek` | Move the playhead to `time` ms (required). Returns the time. |
|
|
201
|
+
| `canvas.animation.play` | Start playback (refused when already playing). |
|
|
202
|
+
| `canvas.animation.pause` | Pause playback (refused when not playing). |
|
|
203
|
+
| `canvas.animation.togglePlay` | Play or pause; returns `playing` and `time`. |
|
|
204
|
+
| `canvas.animation.stop` | Stop and return to the start. |
|
|
205
|
+
| `canvas.animation.toggleRecord` | Toggle record mode, in which changing any property at the playhead keys it. Returns `recording`; turn it off when done. |
|
|
206
|
+
| `canvas.animation.nextKeyframe` | Jump the playhead to the next keyframe. |
|
|
207
|
+
| `canvas.animation.previousKeyframe` | Jump the playhead to the previous keyframe. |
|
|
208
|
+
| `canvas.animation.exportCss` | Read-only: CSS `@keyframes` for `nodeId`'s animation, as `{ css, exact }`. `exact: false` means some tracks were sampled (OKLab colour tweens, `x` / `y` with different timing, motion paths). |
|
|
209
|
+
|
|
210
|
+
## Pitfalls
|
|
211
|
+
|
|
212
|
+
- `canvas_*` tools validate ids against the current state; an "Unknown node id" error means call
|
|
213
|
+
`get_editor_state` again, not guess.
|
|
214
|
+
- `canvas_add_node` with `nearNodeId` also adds an edge from that node. Pass an explicit
|
|
215
|
+
`position` (and no `nearNodeId`) for a free-standing design element.
|
|
216
|
+
- `canvas_update_node` changes `data` only. Move nodes with layout, align or distribute commands,
|
|
217
|
+
or by the host's own means; do not expect `position` inside `data` to move anything.
|
|
218
|
+
- Align needs at least two nodes and distribute at least three; locked nodes never move. Shape
|
|
219
|
+
booleans refuse locked shapes and empty results, and edges attached to consumed shapes are left
|
|
220
|
+
dangling: reconnect or remove them.
|
|
221
|
+
- Subtract uses stacking order (back-most is the base), not selection order; restack first.
|
|
222
|
+
- Instances never gain or lose layers. Deleting a layer inside an instance hides it; nodes added
|
|
223
|
+
inside an instance move out of it. Edit the main to change structure.
|
|
224
|
+
- `push_overrides`, `detach_instance`, `remove_variant` and `reset_overrides` change other
|
|
225
|
+
instances or discard work; ask before using them on the user's design.
|
|
226
|
+
- Variant edits refuse a combination another variant already has, empty names, and names
|
|
227
|
+
containing `,` or `=`.
|
|
228
|
+
- An instance cannot be placed inside a component it contains (cycle); place it outside.
|
|
229
|
+
- Animation times are milliseconds; `rotation` is degrees and `opacity` 0 to 1 (token bindings use
|
|
230
|
+
percent for opacity, animation does not).
|