From a8ed8ca7749643887394363789b269ea47f78a07 Mon Sep 17 00:00:00 2001 From: jayzed80 Date: Sat, 31 Oct 2026 09:45:18 +0000 Subject: [PATCH 01/72] fix(effects): parse_cube rejects a hostile LUT_3D_SIZE before cubing it --- crates/effects/src/utility.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/effects/src/utility.rs b/crates/effects/src/utility.rs index e41b42e99..17f0a243b 100644 --- a/crates/effects/src/utility.rs +++ b/crates/effects/src/utility.rs @@ -202,9 +202,12 @@ pub fn parse_cube(text: &str) -> Option { _ => rows.push(three(&mut it)?), } } + if lut.n3 > 256 { + return None; + } let need1 = lut.n1; let need3 = lut.n3 * lut.n3 * lut.n3; - if (lut.n1 == 0 && lut.n3 == 0) || lut.n1 == 1 || lut.n3 == 1 || rows.len() != need1 + need3 || lut.n3 > 256 { + if (lut.n1 == 0 && lut.n3 == 0) || lut.n1 == 1 || lut.n3 == 1 || Some(rows.len()) != need1.checked_add(need3) { return None; } lut.d1 = rows[..need1].to_vec(); @@ -464,6 +467,10 @@ mod tests { fn bad_cube_is_passthrough() { assert!(parse_cube("LUT_3D_SIZE 2\n0 0 0\n1 1 1\n").is_none()); assert!(parse_cube("LUT_3D_SIZE 2\n0 0 zz\n").is_none()); + // A hostile size must be rejected, not overflow `n3^3` or `n1 + n3^3`. + assert!(parse_cube("LUT_3D_SIZE 4294967296\n0 0 0\n").is_none()); + assert!(parse_cube(&format!("LUT_3D_SIZE {}\n0 0 0\n", usize::MAX)).is_none()); + assert!(parse_cube(&format!("LUT_1D_SIZE {}\nLUT_3D_SIZE 2\n0 0 0\n", usize::MAX)).is_none()); let img = test_img(); let out = run("ec.utility.applylut", &[("lut", Value::Str("LUT_3D_SIZE 3\n0 0 0\n".into()))], img.clone()); assert_eq!(out.img, img); From bad3e7c2320d5f8aa8608d3dc725ed301b3ed366 Mon Sep 17 00:00:00 2001 From: jayzed80 Date: Sat, 31 Oct 2026 09:45:18 +0000 Subject: [PATCH 02/72] fix(effects): parse_cube rejects a hostile LUT_3D_SIZE before cubing it Co-Authored-By: Claude Sonnet 5.5 --- crates/effects/src/utility.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/effects/src/utility.rs b/crates/effects/src/utility.rs index e87c6d3ff..b38ded8db 100644 --- a/crates/effects/src/utility.rs +++ b/crates/effects/src/utility.rs @@ -215,9 +215,12 @@ pub fn parse_cube(text: &str) -> Option { _ => rows.push(three(&mut it)?), } } + if lut.n3 > 256 { + return None; + } let need1 = lut.n1; let need3 = lut.n3 * lut.n3 * lut.n3; - if (lut.n1 == 0 && lut.n3 == 0) || lut.n1 == 1 || lut.n3 == 1 || rows.len() != need1 + need3 || lut.n3 > 256 { + if (lut.n1 == 0 && lut.n3 == 0) || lut.n1 == 1 || lut.n3 == 1 || Some(rows.len()) != need1.checked_add(need3) { return None; } lut.d1 = rows[..need1].to_vec(); @@ -477,6 +480,10 @@ mod tests { fn bad_cube_is_passthrough() { assert!(parse_cube("LUT_3D_SIZE 2\n0 0 0\n1 1 1\n").is_none()); assert!(parse_cube("LUT_3D_SIZE 2\n0 0 zz\n").is_none()); + // A hostile size must be rejected, not overflow `n3^3` or `n1 + n3^3`. + assert!(parse_cube("LUT_3D_SIZE 4294967296\n0 0 0\n").is_none()); + assert!(parse_cube(&format!("LUT_3D_SIZE {}\n0 0 0\n", usize::MAX)).is_none()); + assert!(parse_cube(&format!("LUT_1D_SIZE {}\nLUT_3D_SIZE 2\n0 0 0\n", usize::MAX)).is_none()); let img = test_img(); let out = run("ec.utility.applylut", &[("lut", Value::Str("LUT_3D_SIZE 3\n0 0 0\n".into()))], img.clone()); assert_eq!(out.img, img); From 26dc7b3a5e6a40e13c83665dffaf5fc41aedf7bf Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sat, 7 Nov 2026 12:40:04 +0100 Subject: [PATCH 03/72] CC Ball Action: add Coloring, Shading, Scatter Motion, Displace and Displace Property (#3197) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After Effects 24.2 reworked CC Ball Action's controls. EffectCraft now lists them in After Effects' order with its defaults: Grid Spacing (5), Ball Size (100), Coloring (Medium), Shading (-75), Scatter, Scatter Motion, Displace, Displace Property (Brightness), Twist Angle, Twist Property, Rotation Axis, Rotation. Grid Spacing and Ball Size used to default to 4 and 40; saved projects keep their values. - Shading scales the balls' light and shine. -75 is the lit sphere as before, 0 draws flat balls in the layer's colour, larger magnitudes shade more, and the sign mirrors the light's direction. The value is clamped to -100..100 (an assumed range) so huge values stay finite on the GPU. Values other than -75 and 0 use a new sprite shape (Shape::Ball), drawn the same way on the CPU and the GPU. - Coloring is an approximation: Crisp takes the nearest pixel, Medium keeps EffectCraft's earlier smooth sample (for compatibility), Smooth averages 16 samples over the ball's cell. - Scatter Motion is treated as the renamed Instability State, since 24.2 shows no Instability State. Old projects are upgraded through PARAM_ID_ALIASES. - Displace and Displace Property (Red, Green, Blue, Brightness, Saturation, RGB, Radius, Diamond, Spherize) move each ball towards or away from the camera. The scale, direction, pivot and range, and what Radius, Diamond and Spherize compute, are EffectCraft's own choice pending a comparison with After Effects. Displace is clamped to -1000..1000. With the old Grid Spacing and Ball Size, every CC Ball Action golden hash is unchanged, so the new controls at their defaults draw what was drawn before. Only the golden cases that use the default Grid Spacing and Ball Size were reblessed. CC Ball Action has no .aep mapping yet. Sources (behaviour and public descriptions only): - After Effects February 2024 (24.2) feature summary: "Ball Action: Rearranged effect controls with new controls, such as Displacement, Shading, and Coloring" https://helpx.adobe.com/ae_en/after-effects/using/whats-new/2024-2.html - The After Effects screenshot in #3197: control order and defaults. - 163.com, "Ae 效果详解:CC Ball Action": option lists, defaults, and that Shading 0 is flat https://www.163.com/dy/article/JOICG6E10536FE6V.html - Adobe community, "CC Ball Action is broken in update 24.4": the Coloring options Crisp, Medium and Smooth - Mike Murphy, "How To Use CC Ball Action": Shading 0 with Displace on Brightness https://mikemurphy.ai/tutorials/ccballaction/ Fixes #3197 --- crates/effects/src/migrate.rs | 3 + crates/effects/src/sim/sprites.rs | 22 ++++ crates/effects/src/sim2/pixels.rs | 118 +++++++++++++++++- crates/effects/src/sim2/registry.rs | 21 +++- crates/effects/src/sim2/tests.rs | 132 +++++++++++++++++++++ crates/effects/tests/it/particle_golden.rs | 42 +++---- crates/gpu/src/fx_sim.rs | 2 + crates/gpu/src/shaders/fx_sim.wgsl | 21 ++++ crates/gpu/src/tests/fx_particles.rs | 17 ++- docs/effects.md | 4 +- 10 files changed, 347 insertions(+), 35 deletions(-) diff --git a/crates/effects/src/migrate.rs b/crates/effects/src/migrate.rs index 59daca49d..6529e658d 100644 --- a/crates/effects/src/migrate.rs +++ b/crates/effects/src/migrate.rs @@ -44,6 +44,9 @@ pub const PARAM_ID_ALIASES: &[(&str, &str, &str)] = &[ ("ec.key.innerouter", "additionalBackground", "additionalBackground/background1"), // Generate: Radio Waves' growth speed was called Velocity; Velocity now moves the wave. ("ec.generate.radiowaves", "velocity", "waveMotion/expansion"), + // Simulation: CC Ball Action's Instability State is treated as the control After Effects + // 24.2 calls Scatter Motion (#3197; an assumption: 24.2 shows no Instability State). + ("ec.sim.ccballaction", "instabilityState", "scatterMotion"), ]; /// Popup option labels renamed since they were first saved: diff --git a/crates/effects/src/sim/sprites.rs b/crates/effects/src/sim/sprites.rs index 55ba594b4..031bee978 100644 --- a/crates/effects/src/sim/sprites.rs +++ b/crates/effects/src/sim/sprites.rs @@ -93,6 +93,10 @@ pub enum Shape { Disc, /// Lit sphere (upper-left light, specular). Sphere, + /// CC Ball Action's ball: [`Shape::Sphere`]'s light and shine scaled by `|shade|` (1 is the + /// sphere's look, 0 a flat disc; callers keep it finite, the GPU draws the same); a negative + /// `shade` mirrors the light's direction (lit from the lower right). + Ball { shade: f32 }, /// Disc fading linearly to its rim. Faded, /// Thin ring with a highlight. @@ -277,6 +281,24 @@ fn sprite_shade(s: &Sprite, x: f32, y: f32) -> Option { rgb = [rgb[0] * k + spec, rgb[1] * k + spec, rgb[2] * k + spec]; cv } + Shape::Ball { shade } => { + let d = (dx * dx + dy * dy).sqrt(); + let cv = aa(r - d); + if cv <= 0.0 { + return None; + } + let (nx, ny) = (dx / r, dy / r); + let nz = (1.0 - nx * nx - ny * ny).max(0.0).sqrt(); + let m = if shade < 0.0 { -1.0 } else { 1.0 }; + let (lx, ly, lz) = (-0.48 * m, -0.58 * m, 0.66); + let diff = (nx * lx + ny * ly + nz * lz).max(0.0); + let rz = 2.0 * diff * nz - lz; + let st = shade.abs(); + let spec = rz.max(0.0).powi(20) * 0.6 * st; + let k = (1.0 - st * 0.8 * (1.0 - diff)).max(0.0); + rgb = [rgb[0] * k + spec, rgb[1] * k + spec, rgb[2] * k + spec]; + cv + } Shape::Bubble => { let d = (dx * dx + dy * dy).sqrt() / r; if d > 1.0 + 1.0 / r { diff --git a/crates/effects/src/sim2/pixels.rs b/crates/effects/src/sim2/pixels.rs index 2cda428db..4fed8da59 100644 --- a/crates/effects/src/sim2/pixels.rs +++ b/crates/effects/src/sim2/pixels.rs @@ -4,10 +4,91 @@ use super::{Acc, Buf, EffectCtx, IntoParallelIterator, ParallelIterator, Post, S // ------------------------------------------------------------------ CC Ball Action +/// CC Ball Action's Coloring: how a ball takes its colour from the layer under its grid cell. +/// An approximation: After Effects' own meaning is not published beyond "how smooth the +/// balls look". Crisp takes the nearest pixel, Medium keeps EffectCraft's earlier smooth +/// sample at the cell centre (for compatibility), Smooth averages 16 samples over the cell. +pub(super) const BALL_COLORING: &[&str] = &["Crisp", "Medium", "Smooth"]; +pub(super) const BALL_COLORING_MEDIUM: u32 = 1; +/// CC Ball Action's default Shading: the lit sphere (`Shape::Sphere`); 0 draws flat discs. +pub(super) const BALL_SHADING_DEFAULT: f64 = -75.0; +/// CC Ball Action's Displace Property: what pushes a ball towards (high values) or away from +/// (low values) the camera. The option names come from public descriptions; what Radius, +/// Diamond and Spherize compute here is an assumption pending a comparison with After Effects. +pub(super) const BALL_DISPLACE_PROPERTIES: &[&str] = &["Red", "Green", "Blue", "Brightness", "Saturation", "RGB", "Radius", "Diamond", "Spherize"]; +pub(super) const BALL_DISPLACE_BRIGHTNESS: u32 = 3; + pub(super) fn ball_action(ctx: &EffectCtx, b: Buf) -> Buf { ball_action_plan(ctx, &b).finish(b) } +/// A parameter's number, or `default` when the instance does not carry it. +fn f_or(ctx: &EffectCtx, id: &str, default: f64) -> f64 { + ctx.params.values.get(id).map(|v| v.as_f64()).unwrap_or(default) +} + +/// The layer's straight colour and alpha for the ball of the grid cell centred on (`sx`, `sy`) +/// (buffer pixels, cell `cell` buffer pixels wide), by Coloring `coloring`. +fn ball_color(src: &effectcraft_raster::Image, sx: f64, sy: f64, cell: f64, coloring: u32) -> ([f32; 3], f32) { + match coloring { + // Crisp: the pixel under the cell centre. + 0 => unpremul(src.get(sx.floor() as i64, sy.floor() as i64)), + // Smooth: the cell's average (4 × 4 samples, premultiplied). + 2 => { + const N: u32 = 4; + let mut acc = [0.0f32; 4]; + for j in 0..N { + for i in 0..N { + let ox = (f64::from(i) + 0.5) / f64::from(N) - 0.5; + let oy = (f64::from(j) + 0.5) / f64::from(N) - 0.5; + let p = src.sample_bilinear(sx + ox * cell, sy + oy * cell); + for (a, v) in acc.iter_mut().zip(p) { + *a += v; + } + } + } + let n = (N * N) as f32; + unpremul([acc[0] / n, acc[1] / n, acc[2] / n, acc[3] / n]) + } + // Medium: a smooth sample at the cell centre. + _ => unpremul(src.sample_bilinear(sx, sy)), + } +} + +/// CC Ball Action's Displace Property `prop` (0..1) for a ball of straight colour `c` at +/// (`gx`, `gy`) on a `lw` × `lh` layer (`maxr`: half its diagonal). Assumed meanings (not +/// compared with After Effects yet): Radius, Diamond and Spherize are shapes that peak at the +/// layer centre. +fn ball_displace_value(prop: u32, c: [f32; 3], gx: f32, gy: f32, lw: f32, lh: f32, maxr: f32) -> f32 { + let (cx, cy) = (lw * 0.5, lh * 0.5); + let v = match prop { + 0 => c[0], + 1 => c[1], + 2 => c[2], + // Brightness: the brightest channel (HSB brightness). + 3 => c[0].max(c[1]).max(c[2]), + // Saturation: HSB saturation. + 4 => { + let mx = c[0].max(c[1]).max(c[2]); + let mn = c[0].min(c[1]).min(c[2]); + if mx > 0.0 { (mx - mn) / mx } else { 0.0 } + } + // RGB: the channels' mean. + 5 => (c[0] + c[1] + c[2]) / 3.0, + // Radius: high at the centre, low at the corners. + 6 => 1.0 - (gx - cx).hypot(gy - cy) / maxr.max(1.0), + // Diamond: high at the centre, falling linearly to the edge midpoints' diamond. + 7 => 1.0 - ((gx - cx).abs() / cx.max(0.5) + (gy - cy).abs() / cy.max(0.5)) * 0.5, + // Spherize: a hemisphere over the largest centred circle. + _ => { + let rr = cx.min(cy).max(0.5); + let d = (gx - cx).hypot(gy - cy) / rr; + (1.0 - d * d).max(0.0).sqrt() + } + }; + if v.is_finite() { v.clamp(0.0, 1.0) } else { 0.0 } +} + /// CC Ball Action's balls (far to near), coloured by the layer's pixels. fn ball_action_plan(ctx: &EffectCtx, b: &Buf) -> SpritePlan { let pr = ctx.params; @@ -18,7 +99,29 @@ fn ball_action_plan(ctx: &EffectCtx, b: &Buf) -> SpritePlan { let twist = pr.f("twistAngle").to_radians(); let spacing = pr.f("gridSpacing").max(1.0) as f32; let size = pr.f("ballSize") as f32 / 100.0; - let instab = pr.f("instabilityState").to_radians() as f32; + // Scatter Motion, treated as the renamed Instability State (an assumption: After Effects + // 24.2 shows Scatter Motion and no Instability State): turns each ball's scatter direction. + let instab = pr.f("scatterMotion").to_radians() as f32; + let coloring = pr.values.get("coloring").map(|v| v.as_enum()).unwrap_or(BALL_COLORING_MEDIUM); + let shading = f_or(ctx, "shading", BALL_SHADING_DEFAULT); + // Shading: -75 is the lit sphere as it always was, 0 flat discs; the magnitude scales the + // light and shine (strength 1 at 75) and the sign mirrors the light's direction (positive + // lights the balls from the lower right). How this compares with After Effects' sign + // (described as concave versus convex) is unverified, as is the -100..100 range. + let shape = if shading == BALL_SHADING_DEFAULT || !shading.is_finite() { + Shape::Sphere + } else if shading == 0.0 { + Shape::Disc + } else { + // Clamped: a huge value would reach the GPU as an infinite strength (and NaN colours). + Shape::Ball { shade: (-shading.clamp(-100.0, 100.0) / 75.0) as f32 } + }; + // Displace: pushes each ball along z by its Displace Property (high values towards the + // camera, pivoting at the property's middle value); 100 moves the extremes by half the + // layer's diagonal. Scale, direction, pivot and range are EffectCraft's own choice, + // pending a comparison with After Effects. Clamped so huge values stay finite. + let displace = pr.f("displace").clamp(-1000.0, 1000.0) as f32; + let displace_prop = pr.values.get("displaceProperty").map(|v| v.as_enum()).unwrap_or(BALL_DISPLACE_BRIGHTNESS); let seed = ctx.seed.wrapping_mul(0x2545f491); let (lw, lh) = (ctx.layer_size[0] as f32, ctx.layer_size[1] as f32); let s = b.scale as f32; @@ -43,7 +146,7 @@ fn ball_action_plan(ctx: &EffectCtx, b: &Buf) -> SpritePlan { let gx = (i % nx) as f32 * spacing + spacing * 0.5; let gy = (i / nx) as f32 * spacing + spacing * 0.5; let (sx, sy) = b.to_px([gx as f64, gy as f64]); - let (c, a) = unpremul(src.sample_bilinear(sx, sy)); + let (c, a) = ball_color(src, sx, sy, f64::from(spacing * s), coloring); if a <= 0.0 || size <= 0.0 { return None; } @@ -54,11 +157,16 @@ fn ball_action_plan(ctx: &EffectCtx, b: &Buf) -> SpritePlan { _ => crate::util::rgb3([c[0], c[1], c[2], 0.0]).iter().sum::() / 3.0, } as f64; let ang = rot + twist * tp; - // Scatter: random 3D offsets whose direction drifts with the instability state. + // Scatter: random 3D offsets whose direction drifts with Scatter Motion. let ph = h(i, 1, seed) * std::f32::consts::TAU + instab; let sc = scatter * h(i, 2, seed); let off = [(sc * ph.cos()) as f64, (sc * ph.sin()) as f64, (scatter * hs(i, 3, seed)) as f64]; - let p0 = [gx as f64 - cx + off[0], gy as f64 - cy + off[1], off[2]]; + let mut p0 = [gx as f64 - cx + off[0], gy as f64 - cy + off[1], off[2]]; + // Only when set, so Displace 0 leaves every depth (and the far-to-near order) as is. + if displace != 0.0 && displace.is_finite() { + let v = ball_displace_value(displace_prop, c, gx, gy, lw, lh, maxr); + p0[2] -= f64::from(displace / 100.0 * (v - 0.5) * 2.0 * maxr); + } let m = rot_axis(ax, ang); let q: [f64; 3] = std::array::from_fn(|k| m[k][0] * p0[0] + m[k][1] * p0[1] + m[k][2] * p0[2]); if d + q[2] <= d * 0.05 { @@ -67,7 +175,7 @@ fn ball_action_plan(ctx: &EffectCtx, b: &Buf) -> SpritePlan { let persp = d / (d + q[2]); let (bx, by) = b.to_px([cx + q[0] * persp, cy + q[1] * persp]); let r = spacing * 0.5 * size * persp as f32 * s; - Some((q[2], Sprite::new(bx as f32, by as f32, r, [c[0], c[1], c[2], a], Shape::Sphere))) + Some((q[2], Sprite::new(bx as f32, by as f32, r, [c[0], c[1], c[2], a], shape))) }) .collect(); balls.sort_by(|a, b| b.0.total_cmp(&a.0)); diff --git a/crates/effects/src/sim2/registry.rs b/crates/effects/src/sim2/registry.rs index 333916a16..28eb8e808 100644 --- a/crates/effects/src/sim2/registry.rs +++ b/crates/effects/src/sim2/registry.rs @@ -1,5 +1,7 @@ use super::foam::{FOAM_TEXTURES, foam}; -use super::pixels::{ball_action, pixel_polly, scatterize}; +use super::pixels::{ + BALL_COLORING, BALL_COLORING_MEDIUM, BALL_DISPLACE_BRIGHTNESS, BALL_DISPLACE_PROPERTIES, BALL_SHADING_DEFAULT, ball_action, pixel_polly, scatterize, +}; use super::shatter::{CD_PROPS, CD_SOURCES, SHATTER_PATTERNS, SHATTER_TEXTURE_MODES, card_dance, shatter}; use super::surfaces::{caustics, wave_world}; use super::{EffectSpec, ParamUi, Value, col, num, p, pct, popup, pt, slider, spec}; @@ -80,15 +82,22 @@ pub fn specs() -> Vec { spec( "ec.sim.ccballaction", "CC Ball Action", + // After Effects' order and defaults since 24.2 (#3197). Scatter Motion is treated as + // the renamed Instability State (an assumption, `migrate::PARAM_ID_ALIASES`). The + // Shading range is not published; -100..100 is an assumption. vec![ + p("gridSpacing", "Grid Spacing", num(5.0), slider(1.0, 200.0, 1.0, 50.0, 0)), + p("ballSize", "Ball Size", num(100.0), slider(0.0, 400.0, 0.0, 200.0, 1)), + p("coloring", "Coloring", Value::Enum(BALL_COLORING_MEDIUM), popup(BALL_COLORING)), + p("shading", "Shading", num(BALL_SHADING_DEFAULT), slider(-100.0, 100.0, -100.0, 100.0, 1)), p("scatter", "Scatter", num(0.0), slider(0.0, 2000.0, 0.0, 300.0, 1)), + p("scatterMotion", "Scatter Motion", num(0.0), ParamUi::Angle), + p("displace", "Displace", num(0.0), slider(-1000.0, 1000.0, 0.0, 100.0, 1)), + p("displaceProperty", "Displace Property", Value::Enum(BALL_DISPLACE_BRIGHTNESS), popup(BALL_DISPLACE_PROPERTIES)), + p("twistAngle", "Twist Angle", num(0.0), ParamUi::Angle), + p("twistProperty", "Twist Property", Value::Enum(0), popup(&["X Axis", "Y Axis", "Radius", "Brightness"])), p("rotationAxis", "Rotation Axis", Value::Enum(0), popup(&["X Axis", "Y Axis", "Z Axis", "XY Axis", "XZ Axis", "YZ Axis", "XYZ Axis"])), p("rotation", "Rotation", num(0.0), ParamUi::Angle), - p("twistProperty", "Twist Property", Value::Enum(0), popup(&["X Axis", "Y Axis", "Radius", "Brightness"])), - p("twistAngle", "Twist Angle", num(0.0), ParamUi::Angle), - p("gridSpacing", "Grid Spacing", num(4.0), slider(1.0, 200.0, 1.0, 50.0, 0)), - p("ballSize", "Ball Size", num(40.0), slider(0.0, 400.0, 0.0, 200.0, 1)), - p("instabilityState", "Instability State", num(0.0), ParamUi::Angle), ], ball_action, ), diff --git a/crates/effects/src/sim2/tests.rs b/crates/effects/src/sim2/tests.rs index 2ef35b122..6ad6eb21c 100644 --- a/crates/effects/src/sim2/tests.rs +++ b/crates/effects/src/sim2/tests.rs @@ -46,6 +46,138 @@ fn ball_action_draws_balls() { assert!(sum_diff(&a, &sc) > 1.0); } +/// #3197: CC Ball Action has After Effects' controls (since 24.2), in its order, with its +/// defaults: Coloring, Shading, Scatter Motion (formerly Instability State), Displace and +/// Displace Property were missing. +#[test] +fn ball_action_has_after_effects_controls() { + let spec = crate::find("ec.sim.ccballaction").unwrap(); + let names: Vec<&str> = spec.params.iter().map(|p| p.name).collect(); + assert_eq!( + names, + [ + "Grid Spacing", + "Ball Size", + "Coloring", + "Shading", + "Scatter", + "Scatter Motion", + "Displace", + "Displace Property", + "Twist Angle", + "Twist Property", + "Rotation Axis", + "Rotation" + ] + ); + let sp = |id: &str| spec.params.iter().find(|p| p.id == id).unwrap_or_else(|| panic!("no {id}")); + assert_eq!(sp("gridSpacing").default, num(5.0)); + assert_eq!(sp("ballSize").default, num(100.0)); + assert_eq!(sp("coloring").default, Value::Enum(1)); + assert_eq!(sp("coloring").ui, ParamUi::Popup { options: vec!["Crisp".into(), "Medium".into(), "Smooth".into()] }); + assert_eq!(sp("shading").default, num(-75.0)); + assert!(matches!(sp("shading").ui, ParamUi::Slider { min, max, .. } if min <= -100.0 && max >= 100.0)); + assert_eq!(sp("scatterMotion").default, num(0.0)); + assert_eq!(sp("scatterMotion").ui, ParamUi::Angle); + assert_eq!(sp("displace").default, num(0.0)); + let ParamUi::Popup { options } = &sp("displaceProperty").ui else { panic!("Displace Property is a popup") }; + let Value::Enum(d) = sp("displaceProperty").default else { panic!("Displace Property defaults to an option") }; + assert_eq!(options.get(d as usize).map(String::as_str), Some("Brightness")); + // Old projects' Instability State becomes Scatter Motion through `PARAM_ID_ALIASES`; the + // engine test `opening_an_old_project_upgrades_effect_instances` covers every alias. +} + +/// #3197: the new controls at After Effects' defaults draw exactly what CC Ball Action drew +/// before (the lit sphere, a smooth colour sample, no displacement). +#[test] +fn ball_action_new_controls_at_defaults_keep_the_render() { + let base = [("ballSize", num(80.0)), ("scatter", num(6.0)), ("rotationAxis", Value::Enum(1)), ("rotation", num(25.0))]; + let a = run("ec.sim.ccballaction", &base, ramp(32, 32), 0.0); + let mut explicit = base.to_vec(); + explicit.extend([ + ("coloring", Value::Enum(1)), + ("shading", num(-75.0)), + ("scatterMotion", num(0.0)), + ("displace", num(0.0)), + ("displaceProperty", Value::Enum(3)), + ]); + assert_eq!(a, run("ec.sim.ccballaction", &explicit, ramp(32, 32), 0.0)); +} + +/// #3197: Shading 0 removes the built-in light: every ball is the layer's flat colour. The +/// default (-75) shades it; a smaller magnitude shades less, a positive value lights the balls +/// from the other side. +#[test] +fn ball_action_shading_zero_is_flat() { + let c = [0.6, 0.3, 0.2, 1.0]; + let shade = |v: f64| run("ec.sim.ccballaction", &[("ballSize", num(100.0)), ("gridSpacing", num(8.0)), ("shading", num(v))], Image::filled(32, 32, c), 0.0); + let flat = shade(0.0); + let covered: Vec<&[f32; 4]> = flat.data.iter().filter(|p| p[3] > 0.999).collect(); + assert!(!covered.is_empty(), "balls drawn"); + for p in &covered { + for k in 0..3 { + assert!((p[k] / p[3] - c[k]).abs() < 1e-4, "flat colour: {p:?}"); + } + } + let lit = shade(-75.0); + assert!(lit.data.iter().any(|p| p[3] > 0.999 && (0..3).any(|k| (p[k] / p[3] - c[k]).abs() > 0.05)), "the default shading lights and darkens the balls"); + let soft = shade(-30.0); + assert!(sum_diff(&flat, &soft) > 0.1 && sum_diff(&flat, &soft) < sum_diff(&flat, &lit), "less shading, closer to flat"); + assert!(sum_diff(&shade(75.0), &lit) > 1.0, "the sign moves the light"); +} + +/// #3197: Coloring Crisp takes the pixel under each ball's cell centre; Medium samples +/// smoothly between pixels. Grid Spacing 4 puts the cell centres on pixel corners (with the +/// default 5 they fall on pixel centres, where Medium's sample equals Crisp's). +#[test] +fn ball_action_coloring_crisp_takes_the_pixel() { + let mut src = Image::new(32, 32); + for y in 0..32u32 { + for x in 0..32u32 { + src.set(x, y, [x as f32 / 32.0, y as f32 / 32.0, ((x * 7 + y * 3) % 5) as f32 / 4.0, 1.0]); + } + } + let col = |m: u32| { + let v = [("gridSpacing", num(4.0)), ("ballSize", num(100.0)), ("shading", num(0.0)), ("coloring", Value::Enum(m))]; + run("ec.sim.ccballaction", &v, src.clone(), 0.0) + }; + let crisp = col(0); + // Flat, opaque balls of radius 2 centred on (4i + 2, 4j + 2): the pixel to the lower right + // of each centre is fully covered by its ball alone. + for j in 0..8i64 { + for i in 0..8i64 { + let (x, y) = (4 * i + 2, 4 * j + 2); + let (got, want) = (crisp.get(x, y), src.get(x, y)); + assert!((0..4).all(|k| (got[k] - want[k]).abs() < 1e-5), "ball ({i}, {j}): {got:?} vs the pixel {want:?}"); + } + } + assert!(sum_diff(&crisp, &col(1)) > 1.0, "medium blends the pixels"); +} + +/// #3197: a huge Shading (typed or from an expression) is clamped, so the balls stay finite. +#[test] +fn ball_action_huge_shading_stays_finite() { + for v in [1e45, -1e45, f64::MAX] { + let o = run("ec.sim.ccballaction", &[("gridSpacing", num(8.0)), ("shading", num(v))], ramp(32, 32), 0.0); + assert!(o.data.iter().all(|p| p.iter().all(|c| c.is_finite())), "shading {v}"); + assert!(o.data.iter().any(|p| p[3] > 0.0), "shading {v}: balls drawn"); + } +} + +/// #3197: Displace pushes the balls along z by the chosen property (Radius: the centre comes +/// towards the camera and grows); 0 leaves them in the layer's plane. +#[test] +fn ball_action_displace_moves_balls_in_depth() { + let flat = run("ec.sim.ccballaction", &[("ballSize", num(80.0))], ramp(32, 32), 0.0); + let d = run("ec.sim.ccballaction", &[("ballSize", num(80.0)), ("displace", num(60.0)), ("displaceProperty", Value::Enum(6))], ramp(32, 32), 0.0); + assert_eq!(d, run("ec.sim.ccballaction", &[("ballSize", num(80.0)), ("displace", num(60.0)), ("displaceProperty", Value::Enum(6))], ramp(32, 32), 0.0)); + assert!(sum_diff(&flat, &d) > 1.0); + for prop in 0..9 { + let o = run("ec.sim.ccballaction", &[("ballSize", num(80.0)), ("displace", num(400.0)), ("displaceProperty", Value::Enum(prop))], ramp(32, 32), 0.0); + assert!(o.data.iter().all(|p| p.iter().all(|v| v.is_finite())), "property {prop}"); + } +} + #[test] fn pixel_polly_breaks_after_start() { let v = [("forceCenter", pt(16.0, 16.0)), ("gridSpacing", num(4.0))]; diff --git a/crates/effects/tests/it/particle_golden.rs b/crates/effects/tests/it/particle_golden.rs index 0dbf19d76..5d0b255b1 100644 --- a/crates/effects/tests/it/particle_golden.rs +++ b/crates/effects/tests/it/particle_golden.rs @@ -192,7 +192,7 @@ fn cases() -> Vec<(&'static str, Vec)> { vec![ vec![], vec![("scatter", n(20.0)), ("rotationAxis", e(6)), ("rotation", n(40.0)), ("twistProperty", e(3)), ("twistAngle", n(90.0))], - vec![("gridSpacing", n(2.0)), ("ballSize", n(80.0)), ("instabilityState", n(45.0)), ("twistProperty", e(2)), ("twistAngle", n(30.0))], + vec![("gridSpacing", n(2.0)), ("ballSize", n(80.0)), ("scatterMotion", n(45.0)), ("twistProperty", e(2)), ("twistAngle", n(30.0))], ], ), ( @@ -538,26 +538,26 @@ const GOLDEN: &[(&str, u64)] = &[ ("ec.sim.particleplayground/8/32bpc/t1.5", 0xb5b7f0281f26baad), ("ec.sim.particleplayground/8/32bpc/t0.8", 0x8b6934363ef4dcfd), ("ec.sim.particleplayground/8/32bpc/t2.2", 0x0a31c17e8e34b9f5), - ("ec.sim.ccballaction/0/8bpc/t0.5", 0x12698ec8353be38c), - ("ec.sim.ccballaction/0/8bpc/t1.5", 0x12698ec8353be38c), - ("ec.sim.ccballaction/0/8bpc/t0.8", 0x12698ec8353be38c), - ("ec.sim.ccballaction/0/8bpc/t2.2", 0x12698ec8353be38c), - ("ec.sim.ccballaction/0/32bpc/t0.5", 0x3fb733487e120261), - ("ec.sim.ccballaction/0/32bpc/t1.5", 0x3fb733487e120261), - ("ec.sim.ccballaction/0/32bpc/t0.8", 0x3fb733487e120261), - ("ec.sim.ccballaction/0/32bpc/t2.2", 0x3fb733487e120261), - ("ec.sim.ccballaction/0/8bpc/half/t0.5", 0x4946070917cc0945), - ("ec.sim.ccballaction/0/8bpc/half/t1.5", 0x4946070917cc0945), - ("ec.sim.ccballaction/0/8bpc/half/t0.8", 0x4946070917cc0945), - ("ec.sim.ccballaction/0/8bpc/half/t2.2", 0x4946070917cc0945), - ("ec.sim.ccballaction/1/8bpc/t0.5", 0xf34b3be38a4dd468), - ("ec.sim.ccballaction/1/8bpc/t1.5", 0xf34b3be38a4dd468), - ("ec.sim.ccballaction/1/8bpc/t0.8", 0xf34b3be38a4dd468), - ("ec.sim.ccballaction/1/8bpc/t2.2", 0xf34b3be38a4dd468), - ("ec.sim.ccballaction/1/32bpc/t0.5", 0x503b7238edf2912c), - ("ec.sim.ccballaction/1/32bpc/t1.5", 0x503b7238edf2912c), - ("ec.sim.ccballaction/1/32bpc/t0.8", 0x503b7238edf2912c), - ("ec.sim.ccballaction/1/32bpc/t2.2", 0x503b7238edf2912c), + ("ec.sim.ccballaction/0/8bpc/t0.5", 0x5f7401d3d1e5a513), + ("ec.sim.ccballaction/0/8bpc/t1.5", 0x5f7401d3d1e5a513), + ("ec.sim.ccballaction/0/8bpc/t0.8", 0x5f7401d3d1e5a513), + ("ec.sim.ccballaction/0/8bpc/t2.2", 0x5f7401d3d1e5a513), + ("ec.sim.ccballaction/0/32bpc/t0.5", 0x9cf15a7756ab88ed), + ("ec.sim.ccballaction/0/32bpc/t1.5", 0x9cf15a7756ab88ed), + ("ec.sim.ccballaction/0/32bpc/t0.8", 0x9cf15a7756ab88ed), + ("ec.sim.ccballaction/0/32bpc/t2.2", 0x9cf15a7756ab88ed), + ("ec.sim.ccballaction/0/8bpc/half/t0.5", 0xe2e3a624434f8e88), + ("ec.sim.ccballaction/0/8bpc/half/t1.5", 0xe2e3a624434f8e88), + ("ec.sim.ccballaction/0/8bpc/half/t0.8", 0xe2e3a624434f8e88), + ("ec.sim.ccballaction/0/8bpc/half/t2.2", 0xe2e3a624434f8e88), + ("ec.sim.ccballaction/1/8bpc/t0.5", 0x07382912d068a625), + ("ec.sim.ccballaction/1/8bpc/t1.5", 0x07382912d068a625), + ("ec.sim.ccballaction/1/8bpc/t0.8", 0x07382912d068a625), + ("ec.sim.ccballaction/1/8bpc/t2.2", 0x07382912d068a625), + ("ec.sim.ccballaction/1/32bpc/t0.5", 0xa1e843936e72815f), + ("ec.sim.ccballaction/1/32bpc/t1.5", 0xa1e843936e72815f), + ("ec.sim.ccballaction/1/32bpc/t0.8", 0xa1e843936e72815f), + ("ec.sim.ccballaction/1/32bpc/t2.2", 0xa1e843936e72815f), ("ec.sim.ccballaction/2/8bpc/t0.5", 0x0b6bf26753ee4582), ("ec.sim.ccballaction/2/8bpc/t1.5", 0x0b6bf26753ee4582), ("ec.sim.ccballaction/2/8bpc/t0.8", 0x0b6bf26753ee4582), diff --git a/crates/gpu/src/fx_sim.rs b/crates/gpu/src/fx_sim.rs index 944ca6c07..a3f0f7a0c 100644 --- a/crates/gpu/src/fx_sim.rs +++ b/crates/gpu/src/fx_sim.rs @@ -228,6 +228,8 @@ pub(crate) fn sprite_layer(e: &mut Enc, src: &GpuImage, plan: &SpritePlan) -> Op Shape::Square => (6.0, 0.0, 0.0), Shape::Tri => (7.0, 0.0, 0.0), Shape::Line { dx, dy } => (8.0, dx, dy), + // The strength rides in the (otherwise unused) first segment slot. + Shape::Ball { shade } => (9.0, shade, 0.0), }; let mut rec = [kind, s.x, s.y, s.r, s.c[0], s.c[1], s.c[2], s.c[3], s.rot, dx, dy, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]; match plan.tints.get(i).copied().unwrap_or(Tint::Fixed) { diff --git a/crates/gpu/src/shaders/fx_sim.wgsl b/crates/gpu/src/shaders/fx_sim.wgsl index 7deeac048..cf4a14a03 100644 --- a/crates/gpu/src/shaders/fx_sim.wgsl +++ b/crates/gpu/src/shaders/fx_sim.wgsl @@ -145,6 +145,27 @@ fn fxm_sprite(at: u32, x: f32, y: f32) -> FxmShade { } cov = fxm_aa(m); } + // sim::Shape::Ball (CC Ball Action's Shading): the sphere's light and shine scaled by + // |shade| (data[at + 9]), lit from the lower right when shade < 0. + case 9u: { + let d = sqrt(dx * dx + dy * dy); + let cv = fxm_aa(r - d); + if (cv <= 0.0) { + return fxm_none(); + } + let shade = data[at + 9u]; + let nx = dx / r; + let ny = dy / r; + let nz = sqrt(max(1.0 - nx * nx - ny * ny, 0.0)); + let m = select(1.0, -1.0, shade < 0.0); + let diff = max(nx * (-0.48 * m) + ny * (-0.58 * m) + nz * 0.66, 0.0); + let rz = 2.0 * diff * nz - 0.66; + let st = abs(shade); + let spec = powz(max(rz, 0.0), 20.0) * 0.6 * st; + let k = max(1.0 - st * 0.8 * (1.0 - diff), 0.0); + rgb = rgb * k + spec; + cov = cv; + } default: { let lx = data[at + 9u]; let ly = data[at + 10u]; diff --git a/crates/gpu/src/tests/fx_particles.rs b/crates/gpu/src/tests/fx_particles.rs index e8c3a7ce6..a4d531a37 100644 --- a/crates/gpu/src/tests/fx_particles.rs +++ b/crates/gpu/src/tests/fx_particles.rs @@ -141,7 +141,22 @@ fn ball_action_pixel_polly_scatterize() { 0.0, 0.0, ); - case("ec.sim.ccballaction", &[("gridSpacing", n(2.0)), ("ballSize", n(80.0)), ("instabilityState", n(45.0)), ("twistProperty", e(2))], 0.0, 0.0); + case("ec.sim.ccballaction", &[("gridSpacing", n(2.0)), ("ballSize", n(80.0)), ("scatterMotion", n(45.0)), ("twistProperty", e(2))], 0.0, 0.0); + // #3197: Shading (flat, weaker, stronger, lit from the other side), Coloring, Displace. + for shading in [0.0, -30.0, -100.0, 60.0, 1e45] { + case("ec.sim.ccballaction", &[("ballSize", n(80.0)), ("shading", n(shading))], 0.0, 0.0); + } + for coloring in [0, 2] { + case("ec.sim.ccballaction", &[("ballSize", n(80.0)), ("coloring", e(coloring))], 0.0, 0.0); + } + for prop in [3, 6, 8] { + case( + "ec.sim.ccballaction", + &[("ballSize", n(80.0)), ("rotationAxis", e(1)), ("rotation", n(30.0)), ("displace", n(40.0)), ("displaceProperty", e(prop))], + 0.0, + 0.0, + ); + } for object in 0..4 { case("ec.sim.ccpixelpolly", &[("object", e(object)), ("gridSpacing", n(6.0))], 0.6, 0.0); } diff --git a/docs/effects.md b/docs/effects.md index d9f726481..130d00a90 100644 --- a/docs/effects.md +++ b/docs/effects.md @@ -3,7 +3,7 @@ -EffectCraft ships 308 effects with 2988 parameters in total, grouped into the same categories as the Effects & Presets panel. Every effect is our own implementation, written from public behaviour descriptions and standard image-processing literature. Parameter names, order, popup options, units, defaults and ranges follow the reference application so that projects, expressions and muscle memory carry over. +EffectCraft ships 308 effects with 2992 parameters in total, grouped into the same categories as the Effects & Presets panel. Every effect is our own implementation, written from public behaviour descriptions and standard image-processing literature. Parameter names, order, popup options, units, defaults and ranges follow the reference application so that projects, expressions and muscle memory carry over. - **GPU**: 280 effects also run on the GPU compositor with identical results. - **32**: 308 effects process 32-bit float (HDR, overbright) pixels without clamping. @@ -319,7 +319,7 @@ Effects are addressed by id (`ec..`) or display name in commands | Effect | Id | Params | GPU | 32 | Status | |---|---|---:|:-:|:-:|---| -| CC Ball Action | `ec.sim.ccballaction` | 8 | GPU | 32 | Implemented | +| CC Ball Action | `ec.sim.ccballaction` | 12 | GPU | 32 | Implemented | | CC Bubbles | `ec.sim.ccbubbles` | 7 | GPU | 32 | Implemented | | CC Drizzle | `ec.sim.ccdrizzle` | 14 | GPU | 32 | Implemented | | CC Hair | `ec.sim.cchair` | 20 | GPU | 32 | Implemented | From a2728fbf094d79ef92d164b2769228dc938487b2 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sat, 7 Nov 2026 15:29:46 +0100 Subject: [PATCH 04/72] Timeline waveform: draw what the mix plays for reversed layers and Backwards (#3238) A time-reversed layer (negative stretch) is silent in the audio mix, but the Timeline drew its waveform; with the Backwards audio effect the mix plays the layer's [in, out) span reversed, but the waveform was drawn forwards. The render crate now exposes the mix's rules as stretch_is_mixed and plays_backwards, and the mix uses them. The waveform uses the same rules, decided once per layer: only the baselines for a layer the mix leaves silent, and comp time mirrored over [in, out) under Backwards, as the mix maps it. Columns are limited to [in, out) so an edge column draws no audio past the out point. Fixes #3238 --- crates/render/src/audio.rs | 15 ++- crates/ui-egui/src/panels/waveform.rs | 177 ++++++++++++++++++++++++-- 2 files changed, 180 insertions(+), 12 deletions(-) diff --git a/crates/render/src/audio.rs b/crates/render/src/audio.rs index e2861340c..b715c5efe 100644 --- a/crates/render/src/audio.rs +++ b/crates/render/src/audio.rs @@ -66,6 +66,17 @@ fn generates(l: &Layer) -> bool { audio_effect_groups(l).any(|(id, _)| audio_fx::generates_audio(id)) } +/// Does the mix play the layer at its time stretch? Reversed layers (negative stretch) are +/// silent for now; the Timeline waveform shares this rule so it draws what is heard. +pub fn stretch_is_mixed(l: &Layer) -> bool { + l.stretch > 0.0 +} + +/// Does an enabled audio effect (Backwards) play the layer's [in, out) span reversed? +pub fn plays_backwards(l: &Layer) -> bool { + audio_effect_groups(l).any(|(id, _)| audio_fx::reverses(id)) +} + /// Does the layer contribute to the mix (Audio switch on and something to hear)? pub fn audible(project: &Project, l: &Layer) -> bool { l.switches.audio @@ -210,7 +221,7 @@ impl MixEnv<'_> { if fx.is_empty() { return self.layer_raw(l, i0, n, false); } - let reversed = fx.iter().any(|(id, _, _)| audio_fx::reverses(id)); + let reversed = plays_backwards(l); let pre_s: f64 = fx.iter().map(|(id, _, p)| audio_fx::preroll(id, p)).sum(); let pre = (pre_s * self.rate as f64).ceil() as usize; let b0 = i0 - pre as i64; @@ -291,7 +302,7 @@ fn mix_into(sources: &AudioSources<'_>, comp_id: ItemId, start: Tick, out: &mut let any_solo = comp.layers.iter().any(|l| l.switches.solo && audible(project, l)); let s0 = start.to_units_floor(rate as i64); for l in &comp.layers { - if !audible(project, l) || (any_solo && !l.switches.solo) || l.stretch <= 0.0 { + if !audible(project, l) || (any_solo && !l.switches.solo) || !stretch_is_mixed(l) { continue; } // Sample range of the block that falls inside the layer's [in, out). diff --git a/crates/ui-egui/src/panels/waveform.rs b/crates/ui-egui/src/panels/waveform.rs index 4e355f951..aa4c218e5 100644 --- a/crates/ui-egui/src/panels/waveform.rs +++ b/crates/ui-egui/src/panels/waveform.rs @@ -8,7 +8,7 @@ use std::collections::HashMap; use std::sync::{Arc, Mutex}; use effectcraft_engine::project::{ItemId, ItemKind, Layer, LayerSource, Project, Property}; -use effectcraft_engine::render::audio::db_to_gain; +use effectcraft_engine::render::audio::{self, db_to_gain}; use effectcraft_engine::time::Tick; use egui::{Color32, Painter, Rect, Stroke, pos2}; @@ -39,6 +39,39 @@ pub fn audio_item(project: &Project, l: &Layer) -> Option { } } +/// How the layer plays its audio, as far as its waveform goes: `None` when it is silent +/// (reversed, see [`audio::stretch_is_mixed`]), else whether the Backwards effect plays its +/// [in, out) span mirrored ([`audio::plays_backwards`]). The Audio switch and solo are not +/// followed: a muted layer still shows its waveform. +fn played(layer: &Layer) -> Option { + audio::stretch_is_mixed(layer).then(|| audio::plays_backwards(layer)) +} + +/// The summary bins under the Timeline column for comp times `ta .. tb` (seconds, limited to +/// the layer's [in, out) span), as the layer plays them: mirrored over that span when `mirror` +/// (see [`played`]), so the first column shows the last samples. +fn column_bins<'a>(layer: &Layer, s: &'a Summary, ta: f64, tb: f64, mirror: bool) -> Option<&'a [[f32; 4]]> { + let (i, o) = (layer.in_point.seconds(), layer.out_point.seconds()); + let (ta, tb) = (ta.max(i).min(o), tb.max(i).min(o)); + if tb <= ta { + return None; + } + let span = i + o; + let src = |t: f64| { + let t = if mirror { span - t } else { t }; + layer.layer_time(Tick::from_seconds_f64(t)).seconds() * s.bins_per_sec as f64 + }; + let (u, v) = (src(ta), src(tb)); + let n = s.peaks.len() as i64; + let ba = u.min(v).floor() as i64; + let bb = (u.max(v).ceil() as i64).max(ba.saturating_add(1)); + let (ba, bb) = (ba.clamp(0, n), bb.clamp(0, n)); + if ba >= bb { + return None; + } + s.peaks.get(ba as usize..bb as usize) +} + /// The summary for `item`, starting its computation on first request. pub fn summary(app: &EffectcraftApp, ctx: &egui::Context, item: ItemId) -> Option> { let mut m = app.waveforms.map.lock().ok()?; @@ -88,27 +121,23 @@ fn level_gains(levels: Option<&Property>, t: Tick) -> [f32; 2] { } /// Draw `layer`'s waveform in `rect` (left channel above right), columns mapped through the -/// timeline's time map and the layer's time mapping, limited to its [in, out) span. +/// timeline's time map and the layer's time mapping, limited to its [in, out) span and drawn as +/// the layer plays (see [`played`]): only the baselines for a silent layer. pub(crate) fn draw(p: &Painter, rect: Rect, tm: &TMap, layer: &Layer, s: &Summary, color: Color32) { let mid = [rect.min.y + rect.height() * 0.25, rect.min.y + rect.height() * 0.75]; let half = rect.height() * 0.25 - 1.0; let x0 = tm.x(layer.in_point.seconds()).max(rect.min.x).floor() as i32; let x1 = tm.x(layer.out_point.seconds()).min(rect.max.x).ceil() as i32; - let n = s.peaks.len() as i64; let levels = layer.props.sub("audio").and_then(|g| g.get("levels")); for c in 0..2 { p.line_segment([pos2(x0 as f32, mid[c]), pos2(x1 as f32, mid[c])], Stroke::new(1.0, color.gamma_multiply(0.5))); } + let Some(mirror) = played(layer) else { return }; for x in x0..x1 { let (ta, tb) = (tm.t(x as f32), tm.t(x as f32 + 1.0)); - let src = |t: f64| layer.layer_time(Tick::from_seconds_f64(t)).seconds() * s.bins_per_sec as f64; - let (ba, bb) = (src(ta).floor() as i64, src(tb).ceil() as i64); - let (ba, bb) = (ba.min(bb).clamp(0, n), ba.max(bb).max(ba + 1).clamp(0, n)); - if ba >= bb { - continue; - } + let Some(bins) = column_bins(layer, s, ta, tb, mirror) else { continue }; let mut agg = [0.0f32; 4]; - for b in &s.peaks[ba as usize..bb as usize] { + for b in bins { agg[0] = agg[0].min(b[0]); agg[1] = agg[1].max(b[1]); agg[2] = agg[2].min(b[2]); @@ -137,3 +166,131 @@ mod tests { assert_eq!(level_gains(None, Tick::ZERO), [1.0, 1.0]); } } + +#[cfg(test)] +mod played_tests { + use super::*; + use effectcraft_engine::color::Label; + use effectcraft_engine::project::{Comp, Footage, FootageKind, GroupKind, build}; + use effectcraft_engine::render::audio::{footage_peaks, mix_comp}; + use effectcraft_engine::render::{FootageSource, Image}; + use effectcraft_engine::time::FrameRate; + + /// Footage audio equal to its source time (seconds) on both channels over [0, 2) s. + struct Ramp; + impl FootageSource for Ramp { + fn frame(&self, _: ItemId, _: &Footage, _: Tick) -> Option> { + None + } + fn audio(&self, _: ItemId, _: &Footage, start: Tick, frames: usize, rate: u32) -> Option> { + let t0 = start.seconds(); + Some( + (0..frames) + .flat_map(|k| { + let t = t0 + k as f64 / rate as f64; + let v = if (0.0..2.0).contains(&t) { t as f32 } else { 0.0 }; + [v, v] + }) + .collect(), + ) + } + } + + /// A project with a 2 s ramp clip and a comp holding one layer of it (start and in 0 s, + /// out 1 s) changed by `edit`, and the clip's peak summary. + fn setup(edit: &dyn Fn(&mut Layer)) -> (Project, ItemId, Layer, Summary) { + let mut p = Project::default(); + let f = Footage { + path: "ramp.wav".into(), + kind: FootageKind::Audio, + has_audio: true, + frame_rate: FrameRate::new(25, 1), + duration: Tick::from_seconds_f64(2.0), + ..Default::default() + }; + let fid = p.add_item("ramp.wav", Label::SeaFoam, None, ItemKind::Footage(f.clone())); + let mut comp = Comp::new(64, 64, FrameRate::new(25, 1), Tick::from_seconds_f64(2.0)); + let mut l = build::layer(&mut p, &comp, "a", LayerSource::Footage { item: fid }, (0, 0), None); + (l.start_time, l.in_point, l.out_point) = (Tick::ZERO, Tick::ZERO, Tick::from_seconds_f64(1.0)); + edit(&mut l); + comp.layers = vec![l.clone()].into(); + let cid = p.add_item("C", Label::Sandstone, None, ItemKind::Comp(comp.into())); + let peaks = footage_peaks(&Ramp, fid, &f, f.duration, BINS_PER_SEC); + (p, cid, l, Summary { bins_per_sec: BINS_PER_SEC, peaks }) + } + + fn add_backwards(l: &mut Layer, enabled: bool) { + let mut n = 1_000_000; + let mut g = build::Ids(&mut n).group("backwards", "Backwards"); + g.kind = GroupKind::Effect { effect: "ec.audio.backwards".into() }; + g.enabled = enabled; + l.props.group_mut("effects").expect("effects group").children.push(g.into()); + } + + /// The loudest left-channel peak drawn in the column for comp times `ta .. tb`. + fn drawn(l: &Layer, s: &Summary, ta: f64, tb: f64) -> Option { + played(l).and_then(|mirror| column_bins(l, s, ta, tb, mirror)).map(|bins| bins.iter().fold(f32::MIN, |m, b| m.max(b[1]))) + } + + /// The left-channel sample the mix plays at comp time `t`. + fn heard(p: &Project, cid: ItemId, t: f64) -> f32 { + mix_comp(p, &Ramp, None, cid, Tick::from_seconds_f64(t), 1, 8000).first().copied().unwrap_or(f32::NAN) + } + + /// #3238: a time-reversed layer (Time-Reverse Layer: stretch -100 %, start time at its out + /// point) is silent in the mix, so the Timeline draws no waveform columns for it. + #[test] + fn a_reversed_layer_draws_no_waveform_as_the_mix_is_silent() { + let (p, cid, l, s) = setup(&|l| { + l.stretch = -100.0; + l.start_time = Tick::from_seconds_f64(1.0); + }); + for k in 0..200 { + let (ta, tb) = (k as f64 / 200.0, (k + 1) as f64 / 200.0); + assert_eq!(drawn(&l, &s, ta, tb), None, "column at {ta} s"); + } + for t in [0.1, 0.5, 0.9] { + assert_eq!(heard(&p, cid, t), 0.0, "the mix plays the reversed layer at {t} s"); + } + } + + /// #3238: with the Backwards audio effect the first column shows the clip's last samples + /// and the last column its first, matching what the mix plays there. + #[test] + fn backwards_draws_the_waveform_mirrored_as_the_mix_plays_it() { + let (p, cid, l, s) = setup(&|l| add_backwards(l, true)); + let first = drawn(&l, &s, 0.0, 0.005).expect("first column"); + let h = heard(&p, cid, 0.0); + assert!(first > 0.98, "first column draws {first}, not the clip's last samples"); + assert!((first - h).abs() < 0.01, "first column {first}, heard {h}"); + let last = drawn(&l, &s, 0.995, 1.0).expect("last column"); + let h = heard(&p, cid, 0.995); + assert!(last < 0.02, "last column draws {last}, not the clip's first samples"); + assert!((last - h).abs() < 0.01, "last column {last}, heard {h}"); + } + + /// No Backwards effect, a disabled one, or the layer's Effects switch off: the mix plays + /// forwards, and so the waveform is drawn. + #[test] + fn without_an_active_backwards_effect_the_waveform_runs_forwards() { + let edits: [(&str, &dyn Fn(&mut Layer)); 3] = [ + ("no effect", &|_| {}), + ("effect disabled", &|l| add_backwards(l, false)), + ("effects switch off", &|l| { + add_backwards(l, true); + l.switches.effects = false; + }), + ]; + for (name, edit) in edits { + let (p, cid, l, s) = setup(edit); + let first = drawn(&l, &s, 0.0, 0.005).expect("first column"); + let h = heard(&p, cid, 0.004); + assert!(first < 0.02, "{name}: first column draws {first}"); + assert!((first - h).abs() < 0.01, "{name}: first column {first}, heard {h}"); + // A column reaching past the out point draws only up to it. + let edge = drawn(&l, &s, 0.998, 1.003).expect("edge column"); + assert!(edge < 1.001, "{name}: the edge column draws {edge}, past the out point"); + assert_eq!(drawn(&l, &s, 1.0, 1.005), None, "{name}: a column after the out point"); + } + } +} From f0ab5f107fb671146f5b68242dbe6d7f1d759843 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Mon, 9 Nov 2026 22:16:24 +0100 Subject: [PATCH 05/72] Opening an old project: a renamed effect parameter keeps its place among the parameters (#3197) Ball Grid's Instability State becomes Scatter Motion; it used to move to the end, after the new controls, so an expression reading the parameter by index (the 8th) read Coloring afterwards. A parameter renamed within its own group is now renamed where it is; new parameters are still added after it. --- crates/effects/src/migrate.rs | 43 +++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/crates/effects/src/migrate.rs b/crates/effects/src/migrate.rs index 6529e658d..ccd3d11b1 100644 --- a/crates/effects/src/migrate.rs +++ b/crates/effects/src/migrate.rs @@ -192,6 +192,14 @@ fn take_at(g: &mut PropGroup, id: &str) -> Option { } } +/// The position of the property at spec id `id` (`a/b/param`) among its siblings. +fn index_at(g: &PropGroup, id: &str) -> Option { + match id.split_once('/') { + None => g.children.iter().position(|c| matches!(c, Node::Prop(p) if p.match_id == id)), + Some((first, rest)) => index_at(g.sub(first)?, rest), + } +} + fn prop_at<'a>(g: &'a mut PropGroup, id: &str) -> Option<&'a mut Property> { match id.split_once('/') { None => g.get_mut(id), @@ -279,6 +287,12 @@ pub fn upgrade_instance(spec: &EffectSpec, g: &mut PropGroup, ids: &mut Ids, lay // before it moved into a twirl-down group. let found = prop_at(g, ps.id).is_some(); if !found { + // A parameter renamed within its group keeps its place, so expressions that address + // it by index still read it. + let slot = PARAM_ID_ALIASES + .iter() + .filter(|(e, old, new)| *e == spec.id && *new == ps.id && old.rsplit_once('/').map(|(p, _)| p) == new.rsplit_once('/').map(|(p, _)| p)) + .find_map(|(_, old, _)| index_at(g, old)); let moved = PARAM_ID_ALIASES.iter().filter(|(e, _, new)| *e == spec.id && *new == ps.id).find_map(|(_, old, _)| take_at(g, old)).or_else(|| { let leaf = ps.id.rsplit('/').next().unwrap_or(ps.id); // Not when the top-level leaf is an old id of another parameter (Radio @@ -300,9 +314,13 @@ pub fn upgrade_instance(spec: &EffectSpec, g: &mut PropGroup, ids: &mut Ids, lay pr } }; + let at = |sub: &mut PropGroup| match slot { + Some(i) if i <= sub.children.len() => sub.children.insert(i, pr.into()), + _ => sub.children.push(pr.into()), + }; match path.and_then(|path| group_at(g, ids, path)) { - Some(sub) => sub.children.push(pr.into()), - None => g.children.push(pr.into()), + Some(sub) => at(sub), + None => at(g), } } if let Some(pr) = prop_at(g, ps.id) { @@ -584,6 +602,27 @@ mod tests { assert_eq!((&pr.ui, &pr.value), (&ParamUi::Point, &Value::Vec2([20.0, -5.0]))); } + /// #3197 review: an old CC Ball Action saved Instability State as its 8th property; renamed to + /// Scatter Motion it keeps that place, so an expression that reads `effect(..)(8)` still gets + /// the same control (new controls are appended after it). + #[test] + fn upgrade_renames_a_param_in_place_and_keeps_its_index() { + let spec = find("ec.sim.ccballaction").unwrap(); + let mut next = 1; + let mut g = instantiate(spec, &mut Ids(&mut next), "Ball Grid", [100.0, 50.0]); + // The layout an earlier version saved: eight parameters, Instability State last. + let old = ["scatter", "rotationAxis", "rotation", "twistProperty", "twistAngle", "gridSpacing", "ballSize", "scatterMotion"]; + let mut kept: Vec = old.iter().map(|id| take_prop(&mut g, id).unwrap()).collect(); + g.children.clear(); + kept[7].match_id = "instabilityState".into(); + kept[7].value = Value::Scalar(33.0); + g.children.extend(kept.into_iter().map(Node::from)); + assert!(upgrade_instance(spec, &mut g, &mut Ids(&mut next), [100.0, 50.0])); + let ids: Vec<&str> = g.children.iter().take(8).map(|c| c.match_id()).collect(); + assert_eq!(ids, ["scatter", "rotationAxis", "rotation", "twistProperty", "twistAngle", "gridSpacing", "ballSize", "scatterMotion"]); + assert_eq!(g.get("scatterMotion").unwrap().value, Value::Scalar(33.0)); + } + #[test] fn upgrade_moves_params_into_twirl_down_groups() { let spec = find(crate::warp_stab::ID).unwrap(); From ff245aabc74885ac58260ee6e99470dba7762276 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Tue, 10 Nov 2026 22:12:13 +0100 Subject: [PATCH 06/72] Expressions: a renamed effect parameter keeps answering to its old name (#3197) Old projects can name CC Ball Action's Instability State in an expression. The name now resolves to Scatter Motion, through the same alias table the project migration uses, and only after every current name has been tried. --- crates/effects/src/catalog.rs | 2 +- crates/expr/Cargo.toml | 2 +- crates/expr/src/host.rs | 17 ++++++- crates/expr/src/tests.rs | 83 +++++++++++++++++++++++++++++++++++ docs/effects.md | 2 +- 5 files changed, 102 insertions(+), 4 deletions(-) diff --git a/crates/effects/src/catalog.rs b/crates/effects/src/catalog.rs index 7fcb024bf..c7eecaaf3 100644 --- a/crates/effects/src/catalog.rs +++ b/crates/effects/src/catalog.rs @@ -147,7 +147,7 @@ pub fn effects_markdown() -> String { - **Status**: {} implemented in full, {partial} partial (what is missing is listed).\n\n", r.len() - partial )); - s.push_str("Effects are addressed by id (`ec..`) or display name in commands, scripts and the control channel, and every parameter by its id (`effects/#1/blurriness`).\n\n"); + s.push_str("Effects are addressed by id (`ec..`) or display name in commands, scripts and the control channel, and every parameter by its id (`effects/#1/blurriness`). A parameter that was renamed keeps its old name working in expressions of older projects: `effect(\"CC Ball Action\")(\"Instability State\")` still reads Scatter Motion.\n\n"); for cat in CATEGORIES { let list: Vec<_> = r.iter().filter(|e| e.category == *cat).collect(); if list.is_empty() { diff --git a/crates/expr/Cargo.toml b/crates/expr/Cargo.toml index 6f157698b..a0cb29945 100644 --- a/crates/expr/Cargo.toml +++ b/crates/expr/Cargo.toml @@ -11,6 +11,7 @@ workspace = true [dependencies] effectcraft-time = { workspace = true } +effectcraft-effects = { workspace = true } effectcraft-geom = { workspace = true } effectcraft-keyframe = { workspace = true } serde_json = { workspace = true } @@ -25,5 +26,4 @@ boa_engine = { workspace = true, features = ["js"] } [dev-dependencies] effectcraft-color = { workspace = true } -effectcraft-effects = { workspace = true } effectcraft-text = { workspace = true } diff --git a/crates/expr/src/host.rs b/crates/expr/src/host.rs index 43400ea1d..52dca5823 100644 --- a/crates/expr/src/host.rs +++ b/crates/expr/src/host.rs @@ -7,9 +7,10 @@ //! the answers and runs the script again. Expressions are pure functions of these answers, so //! re-running is exact, and the runtime stays free of borrowed state. +use effectcraft_effects::migrate::PARAM_ID_ALIASES; use effectcraft_geom::{Mat3, Mat4}; use effectcraft_keyframe::Value; -use effectcraft_project::{Comp, ItemId, ItemKind, Layer, LayerId, LayerSource, Node, PropGroup, Property}; +use effectcraft_project::{Comp, GroupKind, ItemId, ItemKind, Layer, LayerId, LayerSource, Node, PropGroup, Property}; use effectcraft_render::EvalCtx; use effectcraft_time::Tick; @@ -283,10 +284,24 @@ fn find_child<'g>(g: &'g PropGroup, key: &Key) -> Option<&'g Node> { .find(|n| n.match_id() == m) .or_else(|| g.children.iter().find(|n| n.name().eq_ignore_ascii_case(name))) .or_else(|| g.children.iter().find(|n| compact(n.name()) == c || compact(n.match_id()) == c)) + // Last, so a legacy name never shadows a current one. + .or_else(|| legacy_effect_child(g, &c)) } } } +/// A parameter of an effect instance addressed by a name it had when the project was saved +/// ([`PARAM_ID_ALIASES`]): `effect("CC Ball Action")("Instability State")` keeps reading the +/// parameter that is now Scatter Motion. `c` is the compacted (lowercase, no spaces) name. Only +/// renames inside the instance's own top-level group count; moves into twirl-downs do not. +fn legacy_effect_child<'g>(g: &'g PropGroup, c: &str) -> Option<&'g Node> { + let GroupKind::Effect { effect } = &g.kind else { return None }; + PARAM_ID_ALIASES + .iter() + .filter(|(e, old, new)| e == effect && !old.contains('/') && !new.contains('/') && compact(old) == c) + .find_map(|(_, _, new)| g.children.iter().find(|n| n.match_id() == *new)) +} + impl<'a> Resolver<'a> { fn comp(&self, c: u64) -> Option<&'a Comp> { if c == self.ctx.comp_id.0 { Some(self.ctx.comp) } else { self.ctx.project.comp(ItemId(c)) } diff --git a/crates/expr/src/tests.rs b/crates/expr/src/tests.rs index 050a5a550..22ce60ca0 100644 --- a/crates/expr/src/tests.rs +++ b/crates/expr/src/tests.rs @@ -2070,3 +2070,86 @@ fn bench_evaluation() { println!("BENCH {best:>9} ns/eval {label} (min of 3 x {iters})"); } } + +/// Layer A with an old-format CC Ball Action: Scatter Motion saved as `instabilityState` +/// ("Instability State"), opened through the migration (#3197). Scatter Motion is 37 and keyed +/// 10 at 0 s, 50 at 2 s. +fn old_ball_action() -> Fx { + let mut f = fx(); + let spec = effectcraft_effects::find("ec.sim.ccballaction").unwrap(); + let mut g = group_push(&mut f.p, |ids| effectcraft_effects::instantiate(spec, ids, "CC Ball Action", [20.0, 20.0])); + let sm = g.prop_mut("scatterMotion").unwrap(); + sm.value = Value::Scalar(37.0); + sm.keys = vec![Keyframe::new(Tick::ZERO, Value::Scalar(10.0)), Keyframe::new(secs(2.0), Value::Scalar(50.0))]; + sm.match_id = "instabilityState".into(); + sm.name = "Instability State".into(); + let mut next = f.p.next_id; + assert!(effectcraft_effects::migrate::upgrade_instance(spec, &mut g, &mut Ids(&mut next), [20.0, 20.0])); + f.p.next_id = next; + assert!(g.prop("scatterMotion").is_some(), "the migration renamed the parameter"); + f.p.comp_mut(f.cid).unwrap().layers[0].props.sub_mut("effects").unwrap().children.push(g.into()); + f +} + +#[test] +fn old_parameter_names_still_resolve_in_expressions() { + let f = old_ball_action(); + for name in ["Instability State", "instabilityState", "instability state", "InstabilityState"] { + // Keyframes still apply: the keyed value at 0 s, not the stored 37. + assert_close!(f.num(&format!("effect('CC Ball Action')('{name}')"), 0.0), 10.0); + assert_close!(f.num(&format!("effect('CC Ball Action')('{name}')"), 2.0), 50.0); + assert_close!(f.num(&format!("effect('CC Ball Action')('{name}').valueAtTime(2)"), 0.0), 50.0); + } + // Current names read the same property, unchanged. + for name in ["Scatter Motion", "scatterMotion"] { + assert_close!(f.num(&format!("effect('CC Ball Action')('{name}')"), 0.0), 10.0); + } +} + +#[test] +fn old_parameter_name_follows_the_parameter_expression() { + let mut f = old_ball_action(); + let p = f.p.comp_mut(f.cid).unwrap().layers[0].props.prop_mut("effects/#2/scatterMotion"); + let p = match p { + Some(p) => p, + None => panic!("scatterMotion at effects/#2"), + }; + p.expr = Some(Expression { text: "123".into(), enabled: true }); + assert_close!(f.num("effect('CC Ball Action')('Instability State')", 0.0), 123.0); +} + +#[test] +fn unknown_parameter_names_still_fail() { + let f = old_ball_action(); + assert!(f.ev(f.a, ROT, "effect('CC Ball Action')('No Such Thing')", 0.0).is_err()); + // Old names only exist on the effect they were renamed on. + assert!(f.ev(f.a, ROT, "effect('Slider Control')('Instability State')", 0.0).is_err()); +} + +/// Every in-group rename in the alias table keeps resolving by its old id and display name. +#[test] +fn every_in_group_alias_resolves_by_its_old_name() { + let mut n = 0; + for (effect, old, new) in effectcraft_effects::migrate::PARAM_ID_ALIASES { + if old.contains('/') || new.contains('/') { + continue; + } + let Some(spec) = effectcraft_effects::find(effect) else { continue }; + let mut f = fx(); + let g = group_push(&mut f.p, |ids| effectcraft_effects::instantiate(spec, ids, "Probe", [20.0, 20.0])); + f.p.comp_mut(f.cid).unwrap().layers[0].props.sub_mut("effects").unwrap().children.push(g.into()); + let (new_name, kind) = { + let l = &f.p.comp(f.cid).unwrap().layers[0]; + let p = l.props.prop(&format!("effects/#2/{new}")).unwrap(); + (p.name.clone(), p.value.clone()) + }; + if !matches!(kind, Value::Scalar(_)) { + continue; + } + let a = f.ev(f.a, ROT, &format!("effect('Probe')('{old}')"), 0.0).unwrap(); + let b = f.ev(f.a, ROT, &format!("effect('Probe')('{new_name}')"), 0.0).unwrap(); + assert_eq!(a, b, "{effect}: {old}"); + n += 1; + } + assert!(n >= 1); +} diff --git a/docs/effects.md b/docs/effects.md index 83ee80223..903d26113 100644 --- a/docs/effects.md +++ b/docs/effects.md @@ -9,7 +9,7 @@ EffectCraft ships 308 effects with 2992 parameters in total, grouped into the sa - **32**: 308 effects process 32-bit float (HDR, overbright) pixels without clamping. - **Status**: 308 implemented in full, 0 partial (what is missing is listed). -Effects are addressed by id (`ec..`) or display name in commands, scripts and the control channel, and every parameter by its id (`effects/#1/blurriness`). +Effects are addressed by id (`ec..`) or display name in commands, scripts and the control channel, and every parameter by its id (`effects/#1/blurriness`). A parameter that was renamed keeps its old name working in expressions of older projects: `effect("CC Ball Action")("Instability State")` still reads Scatter Motion. ## 3D Channel From cf94d1a9809b96d4eede176733f85e4a234a46fd Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sat, 14 Nov 2026 18:50:35 +0100 Subject: [PATCH 07/72] ui-egui tests: the file.import dialog answers carry paths as Ok, as DialogAnswer.paths is a Result now (#3304 met the tests of #3103 on main) --- crates/ui-egui/src/menus/tests.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/menus/tests.rs b/crates/ui-egui/src/menus/tests.rs index 0acab9ef9..8c5091691 100644 --- a/crates/ui-egui/src/menus/tests.rs +++ b/crates/ui-egui/src/menus/tests.rs @@ -823,7 +823,7 @@ fn import_file_dialog_offers_and_imports_after_effects_projects() { assert!(many && exts.iter().any(|e| e == "aep") && exts.iter().any(|e| e == "aepx"), "{exts:?}"); assert!(exts.iter().any(|e| e == "png"), "footage too"); - super::frontend::dialog_answered(&mut app, crate::DialogAnswer { command: "file.import".into(), key: "paths", params: json!({}), paths: vec![aep] }); + super::frontend::dialog_answered(&mut app, crate::DialogAnswer { command: "file.import".into(), key: "paths", params: json!({}), paths: Ok(vec![aep]) }); let comp = app.session.project.item(app.session.active_comp_id().expect("a composition is open")).unwrap(); assert_eq!(comp.name, "Intro"); assert_eq!(app.session.project.item(comp.parent.expect("in a folder")).unwrap().name, "Intro.aep"); @@ -884,7 +884,10 @@ fn picked_projects_report_every_error() { std::fs::write(&aep, b"not an aep").unwrap(); std::fs::write(&ecproj, b"not a project").unwrap(); let paths = vec![aep.to_string_lossy().to_string(), ecproj.to_string_lossy().to_string()]; - super::frontend::dialog_answered(&mut app, crate::DialogAnswer { command: "file.import".into(), key: "paths", params: json!({}), paths: paths.clone() }); + super::frontend::dialog_answered( + &mut app, + crate::DialogAnswer { command: "file.import".into(), key: "paths", params: json!({}), paths: Ok(paths.clone()) }, + ); let status = &app.ui.status; assert!(status.contains("broken.aep") && status.contains("broken.ecproj"), "{status}"); assert!(!status.contains('"'), "messages, not quoted JSON: {status}"); @@ -915,7 +918,7 @@ fn a_picked_project_with_losses_asks_and_the_next_waits() { source.execute("comp.new", json!({"name": "Intro", "width": 64, "height": 36, "frameRate": 30, "duration": 1})).unwrap(); source.execute("file.exportAep", json!({"path": intro, "allowLosses": true})).unwrap(); let paths = vec![lossy.to_string_lossy().to_string(), intro.clone()]; - super::frontend::dialog_answered(&mut app, crate::DialogAnswer { command: "file.import".into(), key: "paths", params: json!({}), paths }); + super::frontend::dialog_answered(&mut app, crate::DialogAnswer { command: "file.import".into(), key: "paths", params: json!({}), paths: Ok(paths) }); assert_eq!(app.dialog, Some(crate::Dialog::AepLosses)); assert_eq!(app.dialog_state.aep_losses.queue, [intro]); assert!(app.session.project.items.is_empty(), "nothing imported before the answer"); From 3bc3adb4e0156ccfede75eae2b955f12dae01e37 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Mon, 16 Nov 2026 16:15:25 +0100 Subject: [PATCH 08/72] psd: parse descriptors and placed layers with craft-psd Pin only craft-psd to craft-libs main 9fc471fc (includes #1887 parse_prefix and #1885 PackBits recovery). Mid-stream descriptor reads use Descriptor::parse_prefix, mapped back to the public effectcraft Descriptor/DValue types. SoLd/SoLE/PlLd placements come from craft_psd::smart::SmartObject, including quiltWarp, and render_placed bakes through craft_psd::FloatImage. Pixel decode stays local until a follow-up can check unmatte parity on composite_f32. --- Cargo.lock | 2 +- Cargo.toml | 2 +- crates/psd/src/descriptor.rs | 179 ++++++++++++----------------------- crates/psd/src/parse.rs | 30 +----- crates/psd/src/placed.rs | 149 ++++++++--------------------- crates/psd/src/tests/opt.rs | 6 +- 6 files changed, 107 insertions(+), 261 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1284590d6..ec8643703 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1359,7 +1359,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=e836b6fd893eca3fbe5880f000dbf446c3a32fcc#e836b6fd893eca3fbe5880f000dbf446c3a32fcc" +source = "git+https://github.com/storytold/craft-libs?rev=9fc471fc5c18f467394a043adf17f021c2b27cae#9fc471fc5c18f467394a043adf17f021c2b27cae" dependencies = [ "encoding_rs", "flate2", diff --git a/Cargo.toml b/Cargo.toml index 0ed32db9a..5f9b2bede 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ craft-dpx = { version = "0.1.0", git = "https://github.com/storytold/craft-libs" craft-ps = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "808730f49b9637b7909fe2ae56f9d63fdb100cae", default-features = false, features = ["read"] } craft-exr = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" } craft-gif = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" } -craft-psd = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "e836b6fd893eca3fbe5880f000dbf446c3a32fcc" } +craft-psd = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "9fc471fc5c18f467394a043adf17f021c2b27cae" } craft-svg = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" } craft-webp = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" } craft-lottie = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" } diff --git a/crates/psd/src/descriptor.rs b/crates/psd/src/descriptor.rs index ca711b7ae..74bb44c3f 100644 --- a/crates/psd/src/descriptor.rs +++ b/crates/psd/src/descriptor.rs @@ -108,14 +108,6 @@ impl Descriptor { } } -/// A key or class id: length-prefixed string, or a 4-character code when the length is 0. -pub(crate) fn read_id(r: &mut Reader) -> Result { - let n = r.u32()? as usize; - let n = if n == 0 { 4 } else { n }; - let b = r.bytes(n)?; - Ok(String::from_utf8_lossy(b).into_owned()) -} - pub(crate) fn read_unicode(r: &mut Reader) -> Result { let n = r.u32()? as usize; let mut v = Vec::with_capacity(n.min(r.remaining() / 2)); @@ -128,122 +120,70 @@ pub(crate) fn read_unicode(r: &mut Reader) -> Result { Ok(String::from_utf16_lossy(&v)) } -/// Read a descriptor (after its version field). +/// Read a descriptor (after its version field) with [`craft_psd::descriptor::Descriptor::parse_prefix`]. +/// The public [`Descriptor`] / [`DValue`] types stay this crate's (engine interchange uses them). pub fn read_descriptor(r: &mut Reader) -> Result { - read_descriptor_at(r, 0) + let rest = r.data.get(r.pos..).unwrap_or(&[]); + let (d, used) = craft_psd::descriptor::Descriptor::parse_prefix(rest).map_err(desc_err)?; + r.skip(used)?; + Ok(from_craft_descriptor(d)) } -/// [`read_descriptor`] nested `depth` values deep: the limit in [`read_value`] counts nested -/// descriptors too, so a file can't recurse until the stack overflows. -fn read_descriptor_at(r: &mut Reader, depth: usize) -> Result { - let class_name = read_unicode(r)?; - let class_id = read_id(r)?; - let n = r.u32()? as usize; - if n > 100_000 { - return Err(Error::Invalid("descriptor item count".into())); +fn desc_err(e: craft_psd::PsdError) -> Error { + match e { + craft_psd::PsdError::UnexpectedEof { .. } => Error::Truncated, + craft_psd::PsdError::Unsupported(s) => Error::Unsupported(s), + other => Error::Invalid(other.to_string()), } - let mut items = Vec::with_capacity(n.min(64)); - for _ in 0..n { - let key = read_id(r)?; - let ty = r.tag()?; - let v = read_value(r, &ty, depth)?; - items.push((key, v)); - } - Ok(Descriptor { class_name, class_id, items }) } -fn read_value(r: &mut Reader, ty: &[u8; 4], depth: usize) -> Result { - if depth > 64 { - return Err(Error::Invalid("descriptor nesting".into())); +fn id_str(id: &craft_psd::descriptor::Id) -> String { + String::from_utf8_lossy(id.as_bytes()).into_owned() +} + +fn unit_str(u: &[u8; 4]) -> String { + String::from_utf8_lossy(u).into_owned() +} + +fn from_craft_descriptor(d: craft_psd::descriptor::Descriptor) -> Descriptor { + Descriptor { + class_name: d.name.to_string_lossy(), + class_id: id_str(&d.class_id), + items: d.items.into_iter().map(|(k, v)| (id_str(&k), from_craft_value(v))).collect(), + } +} + +fn from_craft_value(v: craft_psd::descriptor::Value) -> DValue { + use craft_psd::descriptor::Value; + match v { + Value::Descriptor(d) | Value::GlobalObject(d) => DValue::Descriptor(from_craft_descriptor(d)), + Value::List(l) => DValue::List(l.into_iter().map(from_craft_value).collect()), + Value::Double(x) => DValue::Double(if x.is_finite() { x } else { 0.0 }), + Value::UnitFloat { unit, value } => DValue::UnitFloat(unit_str(&unit), if value.is_finite() { value } else { 0.0 }), + Value::UnitFloats { unit, values } => DValue::UnitFloats(unit_str(&unit), values.into_iter().map(|x| if x.is_finite() { x } else { 0.0 }).collect()), + Value::Text(s) => DValue::Text(s.to_string_lossy()), + Value::Enumerated { type_id, value } => DValue::Enum(id_str(&type_id), id_str(&value)), + Value::Integer(i) => DValue::Integer(i), + Value::LargeInteger(i) => DValue::LargeInteger(i), + Value::Boolean(b) => DValue::Bool(b), + Value::Class(c) | Value::GlobalClass(c) => DValue::Class(c.name.to_string_lossy(), id_str(&c.class_id)), + Value::Alias(b) | Value::Path(b) | Value::RawData(b) => DValue::Raw(b), + Value::ObjectArray(o) => DValue::ObjectArray(o.prefix, from_craft_descriptor(o.body)), + Value::Reference(items) => DValue::Reference(items.into_iter().map(from_craft_ref).collect()), + } +} + +fn from_craft_ref(it: craft_psd::descriptor::ReferenceItem) -> RefItem { + use craft_psd::descriptor::ReferenceItem; + match it { + ReferenceItem::Property { class, key } => RefItem::Property(id_str(&class.class_id), id_str(&key)), + ReferenceItem::Class(c) => RefItem::Class(id_str(&c.class_id)), + ReferenceItem::Enumerated { class, type_id, value } => RefItem::Enum(id_str(&class.class_id), id_str(&type_id), id_str(&value)), + ReferenceItem::Offset { class, offset } => RefItem::Offset(id_str(&class.class_id), offset), + ReferenceItem::Identifier { id, .. } => RefItem::Identifier(id as i32), + ReferenceItem::Index { index, .. } => RefItem::Index(index as i32), + ReferenceItem::Name { class, name } => RefItem::Name(id_str(&class.class_id), name.to_string_lossy()), } - Ok(match ty { - b"Objc" | b"GlbO" => DValue::Descriptor(read_descriptor_at(r, depth + 1)?), - b"VlLs" => { - let n = r.u32()? as usize; - if n > 1_000_000 { - return Err(Error::Invalid("descriptor list length".into())); - } - let mut v = Vec::with_capacity(n.min(256)); - for _ in 0..n { - let t = r.tag()?; - v.push(read_value(r, &t, depth + 1)?); - } - DValue::List(v) - } - b"ObAr" => { - let n = r.u32()?; - DValue::ObjectArray(n, read_descriptor_at(r, depth + 1)?) - } - b"doub" => DValue::Double(r.f64_finite()?), - b"UntF" => { - let unit = String::from_utf8_lossy(&r.tag()?).into_owned(); - DValue::UnitFloat(unit, r.f64_finite()?) - } - b"UnFl" => { - let unit = String::from_utf8_lossy(&r.tag()?).into_owned(); - let n = r.u32()? as usize; - let mut v = Vec::with_capacity(n.min(1024)); - for _ in 0..n { - v.push(r.f64_finite()?); - } - DValue::UnitFloats(unit, v) - } - b"TEXT" => DValue::Text(read_unicode(r)?), - b"enum" => { - let t = read_id(r)?; - DValue::Enum(t, read_id(r)?) - } - b"long" => DValue::Integer(r.u32()? as i32), - b"comp" => DValue::LargeInteger(r.u64()? as i64), - b"bool" => DValue::Bool(r.u8()? != 0), - b"type" | b"GlbC" => { - let name = read_unicode(r)?; - DValue::Class(name, read_id(r)?) - } - b"alis" | b"tdta" | b"Pth " => { - let n = r.u32()? as usize; - DValue::Raw(r.bytes(n)?.to_vec()) - } - b"obj " => { - let n = r.u32()? as usize; - let mut items = Vec::with_capacity(n.min(16)); - for _ in 0..n { - let t = r.tag()?; - items.push(match &t { - b"prop" => { - let _name = read_unicode(r)?; - let class = read_id(r)?; - RefItem::Property(class, read_id(r)?) - } - b"Clss" => { - let _name = read_unicode(r)?; - RefItem::Class(read_id(r)?) - } - b"Enmr" => { - let _name = read_unicode(r)?; - let class = read_id(r)?; - let ty = read_id(r)?; - RefItem::Enum(class, ty, read_id(r)?) - } - b"rele" => { - let _name = read_unicode(r)?; - let class = read_id(r)?; - RefItem::Offset(class, r.u32()? as i32) - } - b"Idnt" => RefItem::Identifier(r.u32()? as i32), - b"indx" => RefItem::Index(r.u32()? as i32), - b"name" => { - let _name = read_unicode(r)?; - let class = read_id(r)?; - RefItem::Name(class, read_unicode(r)?) - } - other => return Err(Error::Invalid(format!("reference item `{}`", String::from_utf8_lossy(other)))), - }); - } - DValue::Reference(items) - } - other => return Err(Error::Invalid(format!("descriptor type `{}`", String::from_utf8_lossy(other)))), - }) } // ---------------------------------------------------------------- writing @@ -387,11 +327,16 @@ fn write_value(out: &mut Vec, v: &DValue) { out.extend_from_slice(&o.to_be_bytes()); } RefItem::Identifier(i) => { + // Photoshop stores a class before the id; craft-psd reads it that way. out.extend_from_slice(b"Idnt"); + put_unicode(out, ""); + put_id(out, "null"); out.extend_from_slice(&i.to_be_bytes()); } RefItem::Index(i) => { out.extend_from_slice(b"indx"); + put_unicode(out, ""); + put_id(out, "null"); out.extend_from_slice(&i.to_be_bytes()); } RefItem::Name(c, n) => { diff --git a/crates/psd/src/parse.rs b/crates/psd/src/parse.rs index 3f70a67b5..9fb2ce6b6 100644 --- a/crates/psd/src/parse.rs +++ b/crates/psd/src/parse.rs @@ -1,7 +1,5 @@ use super::limits::{Error, Result}; -use super::model::{ - Adjustment, ChannelInfo, ColorMode, Layer, LayerMask, LinkedFile, MAX_GROUP_DEPTH, Node, Rect, Section, SmartObject, SubPath, TextInfo, VectorMask, -}; +use super::model::{Adjustment, ChannelInfo, ColorMode, Layer, LayerMask, LinkedFile, MAX_GROUP_DEPTH, Node, Rect, Section, SubPath, TextInfo, VectorMask}; use super::{Psd, Reader, descriptor, engine_data, placed}; use std::sync::Arc; @@ -236,32 +234,10 @@ impl Psd { l.adjustment = Some(Adjustment::Other(String::from_utf8_lossy(key).into_owned())); } b"SoLd" | b"SoLE" => { - let _id = r.tag()?; - let _ver = r.u32()?; - let _dver = r.u32()?; - let d = descriptor::read_descriptor(&mut r)?; - let uuid = d.text("Idnt").unwrap_or_default().to_string(); - let t = placed::eight(&d, "Trnf").unwrap_or([0.0; 8]); - // The non-affine transform when present (perspective), else the transform. - let t = placed::eight(&d, "nonAffineTransform").unwrap_or(t); - let size = d.obj("Sz ").and_then(|s| Some([s.num("Wdth")?, s.num("Hght")?])); - let warp = d.obj("warp").and_then(placed::Warp::read); - l.smart_object = Some(SmartObject { uuid, quad: placed::quad_from(t), size, warp }); + l.smart_object = Some(placed::from_craft_smart(craft_psd::smart::SmartObject::from_placed_layer_data(b).map_err(|e| error(&e))?)); } b"PlLd" if l.smart_object.is_none() => { - let _id = r.tag()?; - let _ver = r.u32()?; - let n = r.u8()? as usize; - let uuid = String::from_utf8_lossy(r.bytes(n)?).into_owned(); - let _page = r.u32()?; - let _pages = r.u32()?; - let _aa = r.u32()?; - let _ty = r.u32()?; - let mut t = [0.0; 8]; - for v in &mut t { - *v = r.f64_finite()?; - } - l.smart_object = Some(SmartObject { uuid, quad: placed::quad_from(t), size: None, warp: None }); + l.smart_object = Some(placed::from_craft_smart(craft_psd::smart::SmartObject::from_placed_layer(b).map_err(|e| error(&e))?)); } b"vmsk" | b"vsms" => { let _ver = r.u32()?; diff --git a/crates/psd/src/placed.rs b/crates/psd/src/placed.rs index 981f4ff23..5cc0c336d 100644 --- a/crates/psd/src/placed.rs +++ b/crates/psd/src/placed.rs @@ -14,14 +14,7 @@ use crate::{Pixels, SmartObject}; /// The most pixels a baked smart object may have: 2^24 (256 MiB as float RGBA). The size comes /// from the file's transform, which is untrusted. -pub const MAX_BAKE_PIXELS: u64 = 1 << 24; - -/// The bake's rasterising budget, in bounding-box pixels visited over all mesh triangles, as a -/// multiple of the output pixel count. A sane warp visits about 2× the output; a hostile mesh -/// that makes every triangle cover the whole output would visit thousands of times more. -const BAKE_WORK_FACTOR: u64 = 8; -/// The smallest budget, so tiny outputs are never refused for rounding at the triangle edges. -const MIN_BAKE_WORK: u64 = 1 << 20; +pub const MAX_BAKE_PIXELS: u64 = craft_psd::smart::MAX_BAKE_PIXELS; /// A placed layer's warp. #[derive(Clone, Debug, Default, PartialEq)] @@ -61,14 +54,40 @@ pub(crate) fn floats(v: Option<&DValue>) -> Vec { } } -/// The eight numbers of a transform entry (`Trnf`, `nonAffineTransform`), when it has exactly eight. -pub(crate) fn eight(d: &Descriptor, key: &str) -> Option<[f64; 8]> { - floats(d.get(key)).try_into().ok() +pub(crate) fn from_craft_smart(s: craft_psd::smart::SmartObject) -> SmartObject { + SmartObject { uuid: s.uuid, quad: s.quad, size: s.size, warp: s.warp.map(from_craft_warp) } } -/// The corner quad (top-left, top-right, bottom-right, bottom-left) from x0 y0 … x3 y3. -pub(crate) fn quad_from(t: [f64; 8]) -> [[f64; 2]; 4] { - [[t[0], t[1]], [t[2], t[3]], [t[4], t[5]], [t[6], t[7]]] +fn from_craft_warp(w: craft_psd::smart::Warp) -> Warp { + Warp { + style: w.style, + bend: w.bend, + horizontal: w.horizontal, + vertical: w.vertical, + rotate_vertical: w.rotate_vertical, + bounds: w.bounds, + cols: w.cols, + rows: w.rows, + mesh: w.mesh, + } +} + +fn to_craft_smart(s: &SmartObject) -> craft_psd::smart::SmartObject { + craft_psd::smart::SmartObject { uuid: s.uuid.clone(), quad: s.quad, size: s.size, warp: s.warp.as_ref().map(to_craft_warp) } +} + +fn to_craft_warp(w: &Warp) -> craft_psd::smart::Warp { + craft_psd::smart::Warp { + style: w.style.clone(), + bend: w.bend, + horizontal: w.horizontal, + vertical: w.vertical, + rotate_vertical: w.rotate_vertical, + bounds: w.bounds, + cols: w.cols, + rows: w.rows, + mesh: w.mesh.clone(), + } } impl Warp { @@ -313,105 +332,11 @@ impl SmartObject { /// `k` pixels per document pixel (into `size` pixels when given; see [`Self::placed_size`]). /// Returns the pixels and their document-space origin. `None` when the content is empty or /// the baked image would exceed [`MAX_BAKE_PIXELS`] or the mesh needs more rasterising work than - /// the budget allows (see [`BAKE_WORK_FACTOR`]). + /// the budget allows. pub fn render_placed(&self, content: &Pixels, k: f64, size: Option<(u32, u32)>) -> Option<(Pixels, [f64; 2])> { - let (cw, ch) = (content.width as f64, content.height as f64); - if content.width == 0 || content.height == 0 { - return None; - } - // The quad is solved once for the bounds, the size and the whole grid. - let m = square_to_quad(self.quad); - let bb = self.bounds_with(&m, cw, ch); - let (ow, oh) = match size { - Some((w, h)) => (w.max(1), h.max(1)), - None => size_for(bb, k), - }; - let (ow, oh) = (ow as usize, oh as usize); - let count = ow.checked_mul(oh).filter(|&c| c as u64 <= MAX_BAKE_PIXELS)?; - // A forward grid, filled triangle by triangle with inverse barycentric sampling. - let n = 48usize; - let mut dst = Vec::with_capacity((n + 1) * (n + 1)); - let mut src = Vec::with_capacity((n + 1) * (n + 1)); - for j in 0..=n { - for i in 0..=n { - let s = [i as f64 / n as f64 * cw, j as f64 / n as f64 * ch]; - let d = self.map_with(&m, s, cw, ch); - dst.push([(d[0] - bb[0]) * k, (d[1] - bb[1]) * k]); - src.push(s); - } - } - let mut out: Vec<[f32; 4]> = Vec::new(); - out.try_reserve_exact(count).ok()?; - out.resize(count, [0.0; 4]); - let sample = |x: f64, y: f64| -> [f32; 4] { - let (fx, fy) = ((x - 0.5).clamp(0.0, cw - 1.0), (y - 0.5).clamp(0.0, ch - 1.0)); - let (x0, y0) = (fx.floor() as usize, fy.floor() as usize); - let (x1, y1) = ((x0 + 1).min(content.width as usize - 1), (y0 + 1).min(content.height as usize - 1)); - let (a, b) = ((fx - x0 as f64) as f32, (fy - y0 as f64) as f32); - let at = |x: usize, y: usize| { - let p = content.data[y * content.width as usize + x]; - [p[0] * p[3], p[1] * p[3], p[2] * p[3], p[3]] - }; - let (p00, p10, p01, p11) = (at(x0, y0), at(x1, y0), at(x0, y1), at(x1, y1)); - let mut o = [0.0; 4]; - for c in 0..4 { - o[c] = (p00[c] * (1.0 - a) + p10[c] * a) * (1.0 - b) + (p01[c] * (1.0 - a) + p11[c] * a) * b; - } - o - }; - let idx = |i: usize, j: usize| j * (n + 1) + i; - // A sane mesh's triangles each span about one grid cell (ow/n by oh/n), rounded out to - // whole pixels. A thin output (16384×1) stacks every grid row onto the same pixel row, so - // allow each of the 2n² triangles about two cells' extent along each axis, with margin. - let rounding = (4 * n as u64).saturating_mul((ow as u64).saturating_add(oh as u64).saturating_add(n as u64)); - let budget = (count as u64).saturating_mul(BAKE_WORK_FACTOR).max(MIN_BAKE_WORK).saturating_add(rounding); - let mut work = 0u64; - for j in 0..n { - for i in 0..n { - for tri in [[idx(i, j), idx(i + 1, j), idx(i + 1, j + 1)], [idx(i, j), idx(i + 1, j + 1), idx(i, j + 1)]] { - let [a, b, c] = tri.map(|t| dst[t]); - let den = (b[1] - c[1]) * (a[0] - c[0]) + (c[0] - b[0]) * (a[1] - c[1]); - if den.abs() < 1e-12 { - continue; - } - // Loop-invariant per triangle: the source corners and the barycentric coefficients. - let [sa, sb, sc] = tri.map(|t| src[t]); - let (l1y, l1x) = (b[1] - c[1], c[0] - b[0]); - let (l2y, l2x) = (c[1] - a[1], a[0] - c[0]); - let x0 = a[0].min(b[0]).min(c[0]).floor().max(0.0) as usize; - let x1 = (a[0].max(b[0]).max(c[0]).ceil() as usize).min(ow); - let y0 = a[1].min(b[1]).min(c[1]).floor().max(0.0) as usize; - let y1 = (a[1].max(b[1]).max(c[1]).ceil() as usize).min(oh); - work = work.saturating_add((x1.saturating_sub(x0) as u64).saturating_mul(y1.saturating_sub(y0) as u64)); - if work > budget { - return None; - } - for y in y0..y1 { - for x in x0..x1 { - let (px, py) = (x as f64 + 0.5, y as f64 + 0.5); - let l1 = (l1y * (px - c[0]) + l1x * (py - c[1])) / den; - let l2 = (l2y * (px - c[0]) + l2x * (py - c[1])) / den; - let l3 = 1.0 - l1 - l2; - if l1 < -1e-9 || l2 < -1e-9 || l3 < -1e-9 { - continue; - } - let sx = sa[0] * l1 + sb[0] * l2 + sc[0] * l3; - let sy = sa[1] * l1 + sb[1] * l2 + sc[1] * l3; - out[y * ow + x] = sample(sx, sy); - } - } - } - } - } - // Back to straight alpha. - for p in &mut out { - if p[3] > 0.0 { - for c in 0..3 { - p[c] /= p[3]; - } - } - } - Some((Pixels { width: ow as u32, height: oh as u32, data: out }, [bb[0], bb[1]])) + let img = craft_psd::FloatImage { width: content.width, height: content.height, data: content.data.clone() }; + let (out, origin) = to_craft_smart(self).render_placed(&img, k, size)?; + Some((Pixels { width: out.width, height: out.height, data: out.data }, origin)) } } diff --git a/crates/psd/src/tests/opt.rs b/crates/psd/src/tests/opt.rs index 241af0069..fac3a9c63 100644 --- a/crates/psd/src/tests/opt.rs +++ b/crates/psd/src/tests/opt.rs @@ -641,11 +641,11 @@ fn placed_bake_solves_the_quad_once() { assert_eq!(counters::take(&QUAD), 1, "33×33 mapped points, one solve (was 1089)"); so.placed_size(20.0, 10.0, 1.0); assert_eq!(counters::take(&QUAD), 1); - // The bounds, the size and the 49×49 grid of one bake share a single solve (was 1089 × 2 + 2401). + // The bake itself runs in craft-psd, so it no longer bumps this crate's quad counter. so.render_placed(&content(20, 10), 1.0, None).unwrap(); - assert_eq!(counters::take(&QUAD), 1); + assert_eq!(counters::take(&QUAD), 0); so.render_placed(&content(20, 10), 1.0, Some((40, 40))).unwrap(); - assert_eq!(counters::take(&QUAD), 1); + assert_eq!(counters::take(&QUAD), 0); // A single `map` still solves for itself. so.map([1.0, 1.0], 20.0, 10.0); assert_eq!(counters::take(&QUAD), 1); From b6d2598b3f217b2bbeb8b6ec86302941cfe21bc5 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Mon, 16 Nov 2026 11:27:30 -0500 Subject: [PATCH 09/72] interchange: delegate lexical depth preflight to craft-timeline --- Cargo.lock | 18 ++++++++ Cargo.toml | 1 + crates/interchange/Cargo.toml | 1 + crates/interchange/src/import.rs | 73 +------------------------------- 4 files changed, 21 insertions(+), 72 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a38c653da..397da745e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1603,6 +1603,15 @@ dependencies = [ "thiserror 2.0.21", ] +[[package]] +name = "craft-time" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=a2560df05b4c58631f53a57e65fb05f0e0e6cf76#a2560df05b4c58631f53a57e65fb05f0e0e6cf76" +dependencies = [ + "serde", + "thiserror 2.0.21", +] + [[package]] name = "craft-time" version = "0.1.0" @@ -1623,6 +1632,14 @@ dependencies = [ "serde_json", ] +[[package]] +name = "craft-timeline" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=a2560df05b4c58631f53a57e65fb05f0e0e6cf76#a2560df05b4c58631f53a57e65fb05f0e0e6cf76" +dependencies = [ + "craft-time 0.1.0 (git+https://github.com/storytold/craft-libs?rev=a2560df05b4c58631f53a57e65fb05f0e0e6cf76)", +] + [[package]] name = "craft-timeline" version = "0.1.0" @@ -2252,6 +2269,7 @@ dependencies = [ name = "effectcraft-interchange" version = "0.24.1" dependencies = [ + "craft-timeline 0.1.0 (git+https://github.com/storytold/craft-libs?rev=a2560df05b4c58631f53a57e65fb05f0e0e6cf76)", "effectcraft-color", "effectcraft-keyframe", "effectcraft-project", diff --git a/Cargo.toml b/Cargo.toml index 6c0fc585d..a7441a26b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ rust-version = "1.95" repository = "https://github.com/storytold/effectcraft" [workspace.dependencies] +craft-timeline = { git = "https://github.com/storytold/craft-libs", rev = "a2560df05b4c58631f53a57e65fb05f0e0e6cf76", default-features = false } craft-mime = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" } craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "808730f49b9637b7909fe2ae56f9d63fdb100cae", version = "=0.1.0", default-features = false, features = ["read"] } craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" } diff --git a/crates/interchange/Cargo.toml b/crates/interchange/Cargo.toml index 11dfec333..e2caa613d 100644 --- a/crates/interchange/Cargo.toml +++ b/crates/interchange/Cargo.toml @@ -10,6 +10,7 @@ rust-version.workspace = true workspace = true [dependencies] +craft-timeline = { workspace = true } effectcraft-time = { workspace = true } effectcraft-color = { workspace = true } effectcraft-keyframe = { workspace = true } diff --git a/crates/interchange/src/import.rs b/crates/interchange/src/import.rs index 5dd5642ac..a5336f406 100644 --- a/crates/interchange/src/import.rs +++ b/crates/interchange/src/import.rs @@ -49,78 +49,7 @@ pub struct ImportResult { /// a few levels per nested sequence; parsing several thousand levels overflowed the stack. pub const MAX_DEPTH: usize = 256; -/// The deepest element nesting of an XML document (a quick scan that skips comments, CDATA, -/// processing instructions, declarations and quoted attribute values). -pub(crate) fn xml_depth(b: &[u8]) -> usize { - let (mut i, mut depth, mut max) = (0usize, 0usize, 0usize); - let skip_to = |from: usize, end: &[u8]| b.get(from..).and_then(|r| r.windows(end.len()).position(|w| w == end)).map_or(b.len(), |p| from + p + end.len()); - while let Some(&c) = b.get(i) { - if c != b'<' { - i += 1; - continue; - } - let rest = b.get(i..).unwrap_or_default(); - if rest.starts_with(b""); - } else if rest.starts_with(b""); - } else if rest.starts_with(b""); - } else if rest.starts_with(b""); - } else if rest.starts_with(b""); - } else { - // A start tag: find its end outside quotes; `/>` closes it at once. - let mut j = i + 1; - let mut quote = None; - while let Some(&c) = b.get(j) { - match quote { - Some(q) if c == q => quote = None, - Some(_) => {} - None if c == b'"' || c == b'\'' => quote = Some(c), - None if c == b'>' => break, - None => {} - } - j += 1; - } - if b.get(j.wrapping_sub(1)) != Some(&b'/') { - depth += 1; - max = max.max(depth); - } - i = j + 1; - } - } - max -} - -/// The deepest array / object nesting of a JSON document (strings skipped). -pub(crate) fn json_depth(b: &[u8]) -> usize { - let (mut depth, mut max, mut in_str, mut esc) = (0usize, 0usize, false, false); - for &c in b { - if in_str { - if esc { - esc = false; - } else if c == b'\\' { - esc = true; - } else if c == b'"' { - in_str = false; - } - continue; - } - match c { - b'"' => in_str = true, - b'[' | b'{' => { - depth += 1; - max = max.max(depth); - } - b']' | b'}' => depth = depth.saturating_sub(1), - _ => {} - } - } - max -} +pub(crate) use craft_timeline::preflight::{json_depth, xml_depth}; pub fn import( project: &mut Project, From e57aa567b9fa408c7506917607eb3d2dbb0cba91 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Mon, 16 Nov 2026 13:33:08 -0500 Subject: [PATCH 10/72] interchange: pin merged shared nesting preflight --- Cargo.lock | 22 +++++++++++----------- Cargo.toml | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6f1bb26e5..73d74ecb5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1597,7 +1597,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=57288edafdc45552e30481cc649021de446abfa0#57288edafdc45552e30481cc649021de446abfa0" +source = "git+https://github.com/storytold/craft-libs?rev=0d6dd8bed815b8366869a800d2bf22588ca62dcb#0d6dd8bed815b8366869a800d2bf22588ca62dcb" dependencies = [ "serde", "thiserror 2.0.21", @@ -1606,7 +1606,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=a2560df05b4c58631f53a57e65fb05f0e0e6cf76#a2560df05b4c58631f53a57e65fb05f0e0e6cf76" +source = "git+https://github.com/storytold/craft-libs?rev=57288edafdc45552e30481cc649021de446abfa0#57288edafdc45552e30481cc649021de446abfa0" dependencies = [ "serde", "thiserror 2.0.21", @@ -1621,6 +1621,14 @@ dependencies = [ "thiserror 2.0.21", ] +[[package]] +name = "craft-timeline" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=0d6dd8bed815b8366869a800d2bf22588ca62dcb#0d6dd8bed815b8366869a800d2bf22588ca62dcb" +dependencies = [ + "craft-time 0.1.0 (git+https://github.com/storytold/craft-libs?rev=0d6dd8bed815b8366869a800d2bf22588ca62dcb)", +] + [[package]] name = "craft-timeline" version = "0.1.0" @@ -1632,14 +1640,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "craft-timeline" -version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=a2560df05b4c58631f53a57e65fb05f0e0e6cf76#a2560df05b4c58631f53a57e65fb05f0e0e6cf76" -dependencies = [ - "craft-time 0.1.0 (git+https://github.com/storytold/craft-libs?rev=a2560df05b4c58631f53a57e65fb05f0e0e6cf76)", -] - [[package]] name = "craft-timeline" version = "0.1.0" @@ -2269,7 +2269,7 @@ dependencies = [ name = "effectcraft-interchange" version = "0.24.1" dependencies = [ - "craft-timeline 0.1.0 (git+https://github.com/storytold/craft-libs?rev=a2560df05b4c58631f53a57e65fb05f0e0e6cf76)", + "craft-timeline 0.1.0 (git+https://github.com/storytold/craft-libs?rev=0d6dd8bed815b8366869a800d2bf22588ca62dcb)", "effectcraft-color", "effectcraft-keyframe", "effectcraft-project", diff --git a/Cargo.toml b/Cargo.toml index 62d4d6287..2889bdc34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ rust-version = "1.95" repository = "https://github.com/storytold/effectcraft" [workspace.dependencies] -craft-timeline = { git = "https://github.com/storytold/craft-libs", rev = "a2560df05b4c58631f53a57e65fb05f0e0e6cf76", default-features = false } +craft-timeline = { git = "https://github.com/storytold/craft-libs", rev = "0d6dd8bed815b8366869a800d2bf22588ca62dcb", default-features = false } craft-mime = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" } craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "808730f49b9637b7909fe2ae56f9d63fdb100cae", version = "=0.1.0", default-features = false, features = ["read"] } craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" } From fa542829e93005433b353f5f42b6be5eb2a0649c Mon Sep 17 00:00:00 2001 From: vangel76 Date: Mon, 16 Nov 2026 22:05:56 +0100 Subject: [PATCH 11/72] #3793: build the OCIO test's expected LUT path from its parts join("luts/grade.cube") keeps the forward slash on Windows, while the code resolves the config's LUT as luts\grade.cube, so the test's text lookup in the read log missed there. The code under test is unchanged. --- crates/engine/src/tests/lut_files.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/engine/src/tests/lut_files.rs b/crates/engine/src/tests/lut_files.rs index 98c95652a..6f6818b23 100644 --- a/crates/engine/src/tests/lut_files.rs +++ b/crates/engine/src/tests/lut_files.rs @@ -192,7 +192,7 @@ fn an_overridden_lut_file_renders_again() { #[test] fn ocio_files_render_again_from_warm_caches() { let dir = tempfile::tempdir().unwrap(); - let (lut, config, grade) = (dir.path().join("file.cube"), dir.path().join("config.ocio"), dir.path().join("luts/grade.cube")); + let (lut, config, grade) = (dir.path().join("file.cube"), dir.path().join("config.ocio"), dir.path().join("luts").join("grade.cube")); std::fs::create_dir_all(dir.path().join("luts")).unwrap(); write(&lut, BLACK, 1_000); write(&grade, BLACK, 1_000); From 3972e5181b1a6cad3a47a09524a9760f9a37f109 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Mon, 16 Nov 2026 19:38:19 -0500 Subject: [PATCH 12/72] svg: delegate stylesheet parsing and matching to craft-svg --- Cargo.lock | 138 +++--------------------- Cargo.toml | 2 +- crates/svg/src/lib.rs | 231 ++-------------------------------------- crates/svg/src/tests.rs | 33 ------ 4 files changed, 24 insertions(+), 380 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 73d74ecb5..a11599fd7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -147,21 +147,6 @@ dependencies = [ "equator", ] -[[package]] -name = "alloc-no-stdlib" -version = "3.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2fb6cfd47bf496ff64095c20eaba0c201404ee38714d4142fcfa1dc334fcc7a" - -[[package]] -name = "alloc-stdlib" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b5c1865780388bfa186411ab5f247819487fc4864c6e9c3106611fa347586e1" -dependencies = [ - "alloc-no-stdlib", -] - [[package]] name = "allocator-api2" version = "0.2.21" @@ -796,16 +781,6 @@ dependencies = [ "syn 3.0.6", ] -[[package]] -name = "brotli-decompressor" -version = "6.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc031cd87c6529082b0b65c604e86af0ed7744841b17ccfe60b1e31fa606179e" -dependencies = [ - "alloc-no-stdlib", - "alloc-stdlib", -] - [[package]] name = "built" version = "0.8.1" @@ -1376,39 +1351,6 @@ dependencies = [ "writeable", ] -[[package]] -name = "craft-image-codecs" -version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87#5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" -dependencies = [ - "craft-jpeg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87)", - "craft-metadata", - "crc32fast", - "exr", - "flate2", - "half", - "hayro-jpeg2000", - "image", - "image-webp", - "jpeg-encoder", - "png", - "rayon", - "serde_json", - "thiserror 2.0.21", - "tiff", - "zune-core", - "zune-jpeg", - "zune-jpegxl", -] - -[[package]] -name = "craft-jpeg" -version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87#5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" -dependencies = [ - "thiserror 2.0.21", -] - [[package]] name = "craft-jpeg" version = "0.1.0" @@ -1461,18 +1403,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "craft-metadata" -version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87#5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" -dependencies = [ - "brotli-decompressor", - "chrono", - "craft-tiff 0.1.0 (git+https://github.com/storytold/craft-libs?rev=5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87)", - "quick-xml 0.41.0", - "serde", -] - [[package]] name = "craft-mime" version = "0.1.0" @@ -1543,7 +1473,7 @@ name = "craft-raw" version = "0.1.0" source = "git+https://github.com/storytold/craft-libs?rev=bea91b1861eea3889bec9d26338076f2ff31c4ac#bea91b1861eea3889bec9d26338076f2ff31c4ac" dependencies = [ - "craft-tiff 0.1.0 (git+https://github.com/storytold/craft-libs?rev=bea91b1861eea3889bec9d26338076f2ff31c4ac)", + "craft-tiff", "miniz_oxide 0.9.1", "rayon", "serde", @@ -1555,10 +1485,9 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87#5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" +source = "git+https://github.com/storytold/craft-libs?rev=c3d9015ec985450386a86b04713d6f1cee597951#c3d9015ec985450386a86b04713d6f1cee597951" dependencies = [ - "craft-image-codecs", - "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87)", + "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=c3d9015ec985450386a86b04713d6f1cee597951)", "flate2", "kurbo", "quick-xml 0.41.0", @@ -1576,15 +1505,6 @@ dependencies = [ "thiserror 2.0.21", ] -[[package]] -name = "craft-tiff" -version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87#5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" -dependencies = [ - "serde", - "thiserror 2.0.21", -] - [[package]] name = "craft-tiff" version = "0.1.0" @@ -1747,16 +1667,6 @@ dependencies = [ "thiserror 2.0.21", ] -[[package]] -name = "craft-xml" -version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87#5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" -dependencies = [ - "quick-xml 0.41.0", - "serde", - "thiserror 2.0.21", -] - [[package]] name = "craft-xml" version = "0.1.0" @@ -1777,6 +1687,16 @@ dependencies = [ "thiserror 2.0.21", ] +[[package]] +name = "craft-xml" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=c3d9015ec985450386a86b04713d6f1cee597951#c3d9015ec985450386a86b04713d6f1cee597951" +dependencies = [ + "quick-xml 0.41.0", + "serde", + "thiserror 2.0.21", +] + [[package]] name = "craft-y4m" version = "0.1.0" @@ -3039,7 +2959,7 @@ version = "0.20.1" source = "git+https://github.com/storytold/filmcraft?rev=3f137a7ed420cac79b32145f5243b7f98b31f71c#3f137a7ed420cac79b32145f5243b7f98b31f71c" dependencies = [ "craft-audio 0.1.0 (git+https://github.com/storytold/craft-libs?rev=82062077bba679ba5236e2d1a391f02d1533cbab)", - "craft-jpeg 0.1.0 (git+https://github.com/storytold/craft-libs?rev=937ac93c5cf3cd4b6a81e195b078fe161eb081b9)", + "craft-jpeg", "craft-media 0.1.0 (git+https://github.com/storytold/craft-libs?rev=82062077bba679ba5236e2d1a391f02d1533cbab)", "craft-video 0.1.0 (git+https://github.com/storytold/craft-libs?rev=82062077bba679ba5236e2d1a391f02d1533cbab)", "craft-y4m", @@ -3071,7 +2991,7 @@ version = "0.20.1" source = "git+https://github.com/storytold/filmcraft?rev=3f137a7ed420cac79b32145f5243b7f98b31f71c#3f137a7ed420cac79b32145f5243b7f98b31f71c" dependencies = [ "craft-raw", - "craft-tiff 0.1.0 (git+https://github.com/storytold/craft-libs?rev=bea91b1861eea3889bec9d26338076f2ff31c4ac)", + "craft-tiff", "image", "rayon", "thiserror 2.0.21", @@ -3760,9 +3680,6 @@ name = "hayro-jpeg2000" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c75ab947623ef4ccaa7acf0579edf7cbb5a73838e3839a7be73335e522f433a1" -dependencies = [ - "fearless_simd", -] [[package]] name = "hayro-syntax" @@ -4024,7 +3941,6 @@ dependencies = [ "moxcms", "num-traits", "png", - "qoi", "tiff", "zune-core", "zune-jpeg", @@ -4175,12 +4091,6 @@ dependencies = [ "libc", ] -[[package]] -name = "jpeg-encoder" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b454d911ac55068f53495488d8ccd0646eaa540c033a28ee15b07838afafb01f" - [[package]] name = "js-sys" version = "0.3.106" @@ -5573,15 +5483,6 @@ version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea" -[[package]] -name = "qoi" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001" -dependencies = [ - "bytemuck", -] - [[package]] name = "quick-error" version = "1.2.3" @@ -9001,15 +8902,6 @@ dependencies = [ "zune-core", ] -[[package]] -name = "zune-jpegxl" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cba11ecd07cc23351500e840ae03841b7e4997923ec8e4832ee3ae199ea0b6b4" -dependencies = [ - "zune-core", -] - [[package]] name = "zvariant" version = "5.15.0" diff --git a/Cargo.toml b/Cargo.toml index 2889bdc34..bf9f999be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ craft-ps = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", craft-exr = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" } craft-gif = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" } craft-psd = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "ce2ec507c2e6a6a078a5f450f641487f8931816d" } -craft-svg = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" } +craft-svg = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "c3d9015ec985450386a86b04713d6f1cee597951" } craft-webp = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" } craft-lottie = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87" } craft-mesh = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "5a7a63a21dd03dd1a2bc6c308a3a6ce818caae87", default-features = false, features = ["stl", "obj", "gltf", "fbx"] } diff --git a/crates/svg/src/lib.rs b/crates/svg/src/lib.rs index fd4baa543..94977d153 100644 --- a/crates/svg/src/lib.rs +++ b/crates/svg/src/lib.rs @@ -425,186 +425,12 @@ enum PaintRef { Current, } -/// The most selectors (each entry of a comma list counts) the `