EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust
Merge main into M13.14
Brandon Thomas91bd8ca7c8e4
diff --cc crates/engine/src/lib.rsindex 9f0f63721,12076b2a1..4829395a9--- a/crates/engine/src/lib.rs+++ b/crates/engine/src/lib.rs@@@ -730,54 -714,19 +732,67 @@@ impl SessionOk((img.width, img.height, img.to_rgba8_over(c.background)))}+ /// A Project panel thumbnail of an item (a comp at `t`, footage at its first frame), longest+ /// side at most `max_side`, as a job that owns everything it reads: frontends run it off the+ /// UI thread (a big comp takes far longer than a frame). `None` for items without pixels.+ pub fn thumbnail_job(&self, item: ItemId, t: Tick, max_side: u32) -> Option<ThumbnailJob> {+ let it = self.project.item(item)?;+ let footage = self.footage.clone();+ match &it.kind {+ effectcraft_project::ItemKind::Comp(c) => {+ let (project, expr, cache) = (self.project.clone(), self.expr.clone(), self.layer_cache.clone());+ let long = c.width.max(c.height).max(1) as f64;+ let scale = if max_side == 0 { 1.0 } else { (max_side as f64 / long).min(1.0) };+ let opts = RenderOpts {+ scale,+ nested_switches: self.prefs.general.switches_affect_nested_comps,+ draft_shadows: self.prefs.three_d.realtime_shadows,+ ..Default::default()+ };+ let bg = c.background;+ Some(Box::new(move || {+ let mut r = Renderer::new(&project, footage.as_ref(), opts);+ r.expr = expr.as_deref();+ r.cache = Some(&cache);+ let img = r.comp_frame(item, t);+ Some((img.width, img.height, img.to_rgba8_over(bg)))+ }))+ }+ effectcraft_project::ItemKind::Footage(f) if f.has_video => {+ let f = f.clone();+ Some(Box::new(move || {+ let img = footage.frame(item, &f, Tick(0))?;+ // Point-sample down to at most `max_side` on the long side.+ let step = (img.width.max(img.height) as f32 / max_side.max(1) as f32).ceil().max(1.0) as u32;+ let (w, h) = (img.width.div_ceil(step), img.height.div_ceil(step));+ let full = img.to_rgba8();+ let mut px = Vec::with_capacity((w * h * 4) as usize);+ for y in 0..h {+ for x in 0..w {+ let i = (((y * step) * img.width + x * step) * 4) as usize;+ px.extend_from_slice(&full[i..i + 4]);+ }+ }+ Some((w, h, px))+ }))+ }+ _ => None,+ }+ }++ /// [`Session::render_rgba8`], or with `transparent` the frame's own straight alpha (what a+ /// render with RGB + Alpha channels writes) instead of compositing over the background.+ pub fn render_rgba8_alpha(&self, comp: ItemId, t: Tick, max_side: u32, transparent: bool) -> Result<(u32, u32, Vec<u8>)> {+ if !transparent {+ return self.render_rgba8(comp, t, max_side);+ }+ let c = self.project.comp(comp).ok_or(EngineError::NoComp)?;+ let long = c.width.max(c.height).max(1) as f64;+ let scale = if max_side == 0 { 1.0 } else { (max_side as f64 / long).min(1.0) };+ let img = self.render(comp, t, RenderOpts { scale, backend: effectcraft_render::Backend::Auto, ..Default::default() });+ Ok((img.width, img.height, img.to_rgba8()))+ }+/// Replace the whole project (open/new), resetting history and state.pub fn replace_project(&mut self, mut p: Project, path: Option<String>) {if self.stop_render()diff --cc docs/agents.mdindex e0395aae8,7985cf2ee..29fdf72b6--- a/docs/agents.md+++ b/docs/agents.md@@@ -57,11 -55,10 +57,12 @@@ The server speaks JSON-RPC 2.0 over std| `get_property {layer, path, comp?, time?}` | Value at a time, keyframes and expression. || `set_property {layer, path, value?, time?, expression?, comp?}` | Sets a static value. With `time` it sets a keyframe; with `expression` it sets an expression. || `add_keyframe {layer, path, time+value \| keys:[...], interpolation?}` | Adds keys, then optionally applies linear/bezier/hold/easyEase. |+| `list_effects {filter?}` | Effect ids, names, categories, GPU / 32-bpc support and parameters. |+| `add_effect {layer, effect, values?, comp?}` | Apply an effect and set its parameters in one call; returns the instance path (`effects/#n`) and its parameter paths. |- | `render_frame {comp?, time?, max_side?, path?, inline?}` | Returns a PNG image of a frame. |+ | `render_frame {comp?, time?, max_side?, path?, inline?, transparent?}` | Returns a PNG image of a frame; `transparent: true` keeps the alpha (as an RGB + Alpha render writes it) instead of compositing over the comp background. || `open_project {path \| demo \| new}` / `save_project {path?}` | Open and save files. || `undo {steps?}` / `redo {steps?}` | History. |+ | `batch {steps: [{command, params}], label?, atomic?}` | Several commands in one call and one undo step (`engine.batch`); `"$N.key"` in a param is step N's result (`"$1.layer"`). A failing step rolls the batch back and names the step. || *(bridge)* `screenshot {panel?, id?}`, `ui_inspect`, `ui_elements {prefix?}`, `ui_click`, `ui_drag`, `ui_key`, `ui_type`, `ui_set`, `control {method, params}` | Look at and operate the live window. |Layers are referenced by id (from `get_comp`), `"#n"` (1-based index from the top) or name. Comps are@@@ -82,26 -79,38 +83,58 @@@ instead of being ignored4. `execute_command {"command":"effect.apply","params":{"layer":2,"effect":"Gaussian Blur"}}`, then `set_property {"layer":2,"path":"effects/#1/blurriness","value":8}`5. `render_frame {"time":1.0}` lets you look at the result, and `save_project {"path":"intro.ecproj"}` saves it.+### Cookbook++Short recipes; every step is one tool call.++| Goal | Calls |+|---|---|+| Orient yourself | `get_state` → `get_project` → `get_comp {}` |+| Find the right command | `list_commands {"filter":"mask"}` → `describe_command {"command":"mask.new"}` (params + JSON Schema) |+| Title card | `execute_command comp.new {...}` → `execute_command layer.newText {"text":"Hi","size":120}` → `render_frame {"time":0}` |+| Animate | `add_keyframe {"layer":2,"path":"transform/scale","keys":[{"time":0,"value":[0,0]},{"time":0.5,"value":[100,100]}],"interpolation":"easyEase"}` |+| Effect with settings | `list_effects {"filter":"glow"}` → `add_effect {"layer":2,"effect":"Glow","values":{"threshold":40,"radius":30}}` → `set_property {"layer":2,"path":"effects/#1/intensity","value":2}` |+| Drive with an expression | `set_property {"layer":2,"path":"transform/rotation","expression":"time*90"}` |+| Inspect a layer | `get_layer {"layer":2,"flat":true}` (every property with its `path`, value, key count) |+| Check the result | `render_frame {"time":1.5,"max_side":640}`; in bridge mode `screenshot {"panel":"Timeline"}` |+| Undo a mistake | `undo {}`, or `history {}` then `history {"goto": n}` |+| Missing media after opening | `execute_command footage.check {"wait":true}` → `{checked, missing, probed}`; then `file.findMissing {"what":"footage"}` |+| Save | `save_project {"path":"out.ecproj"}` |++The desktop app checks footage in the background after every open (a "Checking footage" job in+the Progress panel, `jobs.list`); headless sessions run `footage.check` when they want it.+ ### Cookbook (from end-to-end QA)++ The scenarios in `crates/automation/tests/qa/` and `apps/effectcraft-cli/tests/qa_template.rs`+ build real projects through these interfaces; they are worked examples of everything below.++ * **Name things when you create them**: `layer.newText`, `layer.newShape`, `layer.newSolid`,+ `layer.newNull`, `layer.newCamera` and `layer.newLight` take `name`, so later calls can say+ `"layer": "Title"`. A reference that matches no layer is an error, never a silent no-op.+ * **Use the paths replies give you**: `effect.apply` returns `{effects: [uid], paths:+ ["effects/#2"]}`; `layer.addShapeItem {kind, group?: uid|path}` returns `{uid, path}` (e.g.+ `contents/group/contents/gfill`), ready for `set_property`. `@uid` works as a whole path.+ * **One call, one undo step**: `batch {"steps":[{"command":"layer.newShape","params":{"kind":"ellipse","name":"Ring"}},{"command":"layer.addShapeItem","params":{"layer":"$1.layer","kind":"trim"}},{"command":"prop.addKey","params":{"layer":"$1.layer","path":"transform/opacity","time":0,"value":0}}]}`+ (a string param that is exactly `"$N"` or `"$N.key"` is replaced; `$2.path` is the trim's path).+ * **Expressions**: `set_property`/`get_property` replies carry `evaluated` (what renders) next to+ `value` (the keyframed value) and `expressionError` when the expression fails.+ * **Easing with Keyframe Velocity**: select keys by path, `keys.select {"keys":[{"layer":"Ring","path":"contents/trim/end","time":0}]}`,+ then `keys.velocity {"outSpeed":0,"outInfluence":33.33}`.+ * **Gradients**: `set_property {"path":"contents/gfill/colors","value":["#0080ff","#ffff00"]}` or+ `{"colors":[[0,"#0080ff"],[1,[1,1,0]]],"opacities":[[0,1],[1,0.5]]}`.+ * **Image sequences** import at 30 fps (Settings ▸ Import); `file.interpretFootage {"items":[id],+ "frameRate":12}` conforms them (the item and layers that ran to its end get the new length).+ * **Masks**: `layer.addMask {layer, shape: rect|ellipse, rect}` first, then `layer.mask.set+ {field: feather|expansion|opacity, value}`.+ * **Renders**: `renderQueue.add {comp, format: h264|prores|webm|png…, channels: rgba,+ proresProfile: 4444, output}` then `renderQueue.render {"wait": true}`. Check a render by+ importing it (`file.import`, `file.newCompFromSelection`) and `render_frame {transparent: true}`+ for its alpha. (WebM VP9 alpha is written, but read back opaque for now.)+ * **Essential Graphics**: controls can be addressed by name (`essential.set {"layer":"#1",+ "control":"Title","value":"John Smith"}`); a command that targets an explicit `comp` runs even+ when the active comp would disable it (`essential.exportTemplate {"comp":"Lower Third", …}`).+ * **History**: Levels of Undo defaults to 32 (`prefs.set {"key":"general.undoLevels","value":99}`);+ `history` lists branches and `history {"goto": id}` jumps between them.### Motion tracking