From 86f76dbc82fe948946cec5264b32efe931b472f4 Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Mon, 9 Nov 2026 22:13:26 -0700 Subject: [PATCH 1/8] feat(engine): draw.erase with Animate's erase modes, the faucet and Erase Everything; paint.pick and paint.apply_style (M7) The eraser sweeps the brush tip (ADR 0033) and goes into the planar merge as a fill whose regions come out empty, placed by the mode: on top (Erase Normal), between fills and lines (Erase Fills), over the lines only (Erase Lines), right above the selected fills or the fill the stroke starts on. Only raw shapes are erased; a stroke that erases nothing leaves no step (exact area and length compare). The Eyedropper picks a fill's paint (solid, gradient or bitmap, in stage space) or a line's colour, width and profile into the tool style; the Paint Bucket and the shape tools use a picked gradient where it is on the stage. --- crates/doc/src/lib.rs | 12 ++ crates/engine/src/cmds_brush.rs | 22 +- crates/engine/src/cmds_draw.rs | 12 +- crates/engine/src/cmds_erase.rs | 300 ++++++++++++++++++++++++++ crates/engine/src/cmds_paint.rs | 134 +++++++++++- crates/engine/src/confirm.rs | 11 + crates/engine/src/erase_tests.rs | 230 ++++++++++++++++++++ crates/engine/src/eyedropper_tests.rs | 132 ++++++++++++ crates/engine/src/lib.rs | 38 +++- crates/engine/src/merge.rs | 100 ++++++--- crates/engine/src/tests.rs | 5 + src/panels.rs | 21 +- src/stage.rs | 2 +- 13 files changed, 964 insertions(+), 55 deletions(-) create mode 100644 crates/engine/src/cmds_erase.rs create mode 100644 crates/engine/src/erase_tests.rs create mode 100644 crates/engine/src/eyedropper_tests.rs diff --git a/crates/doc/src/lib.rs b/crates/doc/src/lib.rs index ded94c00..91ea4f1d 100644 --- a/crates/doc/src/lib.rs +++ b/crates/doc/src/lib.rs @@ -124,6 +124,18 @@ impl Paint { } } + /// The paint carried by `m` (its geometry moved from one space to another), so a shape in + /// the new space shows it where it was: gradient ends and centre are mapped, a radial + /// gradient's radius scales by the mean scale, a bitmap's matrix is composed. + pub fn transformed(&self, m: &Affine) -> Paint { + match self { + Paint::Solid(_) => self.clone(), + Paint::Linear { start, end, stops } => Paint::Linear { start: m.apply(*start), end: m.apply(*end), stops: stops.clone() }, + Paint::Radial { center, radius, stops } => Paint::Radial { center: m.apply(*center), radius: radius * m.mean_scale(), stops: stops.clone() }, + Paint::Bitmap { bitmap, repeat, matrix } => Paint::Bitmap { bitmap: *bitmap, repeat: *repeat, matrix: m.mul(matrix) }, + } + } + pub fn lerp(&self, o: &Paint, t: f32) -> Paint { let lerp_stops = |a: &[GradientStop], b: &[GradientStop]| -> Option> { (a.len() == b.len()).then(|| { diff --git a/crates/engine/src/cmds_brush.rs b/crates/engine/src/cmds_brush.rs index 2034d26d..8afb5555 100644 --- a/crates/engine/src/cmds_brush.rs +++ b/crates/engine/src/cmds_brush.rs @@ -72,7 +72,7 @@ impl PaintMode { } } -fn samples(p: &Value) -> Result> { +pub(crate) fn samples(p: &Value) -> Result> { let bad = || EngineError::Param("param 'points' must be a list of [x, y] or [x, y, pressure]".into()); let list = p.get("points").and_then(Value::as_array).ok_or_else(bad)?; if list.is_empty() { @@ -97,7 +97,7 @@ fn samples(p: &Value) -> Result> { .collect() } -fn ranged(p: &Value, key: &str, range: std::ops::RangeInclusive, default: f32) -> Result { +pub(crate) fn ranged(p: &Value, key: &str, range: std::ops::RangeInclusive, default: f32) -> Result { match opt_f32(p, key)? { None => Ok(default), Some(v) if range.contains(&v) => Ok(v), @@ -105,24 +105,37 @@ fn ranged(p: &Value, key: &str, range: std::ops::RangeInclusive, default: f } } -fn draw_brush(s: &mut Session, p: &Value) -> Result { +/// The stroke's samples, refused when they reach too far. +pub(crate) fn bounded_samples(p: &Value) -> Result> { let pts = samples(p)?; let mut bounds = anicraft_geom::Rect::EMPTY; pts.iter().for_each(|x| bounds.include(x.at)); if bounds.width() > MAX_EXTENT || bounds.height() > MAX_EXTENT || bounds.min.x.abs().max(bounds.max.x.abs()).max(bounds.min.y.abs()).max(bounds.max.y.abs()) > MAX_EXTENT { return Err(EngineError::Param("the stroke is too large".into())); } + Ok(pts) +} + +/// The tip from `size`, `shape`, `angle` and `roundness` (shared with the Eraser, ADR 0034). +pub(crate) fn tip(p: &Value) -> Result { let size = ranged(p, "size", SIZE_RANGE, 10.0)?; let shape = match opt_str(p, "shape")?.unwrap_or("round") { "round" => TipShape::Round, "square" => TipShape::Square, - other => return Err(EngineError::Param(format!("unknown brush shape '{other}' (round or square)"))), + other => return Err(EngineError::Param(format!("unknown tip shape '{other}' (round or square)"))), }; let angle = opt_f32(p, "angle")?.unwrap_or(0.0); if !angle.is_finite() || angle.abs() > 1e6 { return Err(EngineError::Param("param 'angle' must be a finite number of degrees".into())); } let roundness = ranged(p, "roundness", 5.0..=100.0, 100.0)?; + Ok(Tip { shape, size, angle, roundness: roundness / 100.0 }) +} + +fn draw_brush(s: &mut Session, p: &Value) -> Result { + let pts = bounded_samples(p)?; + let tip = tip(p)?; + let size = tip.size; let smoothing = ranged(p, "smoothing", 0.0..=100.0, 50.0)?; let unit = ranged(p, "unit", 0.001..=1000.0, 1.0)?; let mode_key = opt_str(p, "mode")?.unwrap_or("normal"); @@ -130,7 +143,6 @@ fn draw_brush(s: &mut Session, p: &Value) -> Result { let color = opt_color(p, "color")?.unwrap_or(s.style.fill); let object = object_param(s, p)?; - let tip = Tip { shape, size, angle, roundness: roundness / 100.0 }; // Smoothing and accuracy are screen distances, so a stroke looks the same at any zoom: at 50 // the centre line may wander 3.3 screen points from the hand, at 0 a third of a point. // The outline is fitted within a third of a screen point, or a hundredth of the size for diff --git a/crates/engine/src/cmds_draw.rs b/crates/engine/src/cmds_draw.rs index 7a3f025d..35de8c1a 100644 --- a/crates/engine/src/cmds_draw.rs +++ b/crates/engine/src/cmds_draw.rs @@ -55,7 +55,8 @@ pub(crate) fn style(s: &Session, p: &Value, closed: bool) -> Result<(Option Some(Paint::Solid(c)), - None => s.style.use_fill.then_some(Paint::Solid(s.style.fill)), + // The fill swatch, in stage space (`add_shape` maps it into the shape). + None => s.style.use_fill.then(|| s.style.fill_paint()), } }; let width = match opt_f32(p, "stroke_width")? { @@ -63,7 +64,7 @@ pub(crate) fn style(s: &Session, p: &Value, closed: bool) -> Result<(Option return Err(EngineError::Param("param 'stroke_width' must be in 0..=1000".into())), None => s.style.stroke_width, }; - let profile = opt_profile(p, "profile")?.unwrap_or_else(|| s.style.stroke_profile.profile()); + let profile = opt_profile(p, "profile")?.unwrap_or_else(|| s.style.profile()); let stroke = if p.get("stroke").is_some_and(Value::is_null) || width <= 0.0 { None } else { @@ -95,6 +96,9 @@ fn rect_params(p: &Value) -> Result<(f32, f32, f32, f32)> { /// (Object Drawing), it merges with the raw shapes it touches (ADR 0031), and the pieces of it /// that come out are selected. pub(crate) fn add_shape(s: &mut Session, name: &str, local: Path, origin: Vec2, fill: Option, stroke: Option, object: bool) -> Result { + // A gradient or bitmap from the fill swatch is in stage space: it stays where it is on the + // stage (Animate's Lock Fill after the Eyedropper). + let fill = fill.map(|f| f.transformed(&Affine::translate(-origin.x, -origin.y))); let merge = !object && crate::merge::can_merge(fill.as_ref(), stroke.as_ref()); let id = ElementId(s.doc.alloc_id()); let el = Element { @@ -301,13 +305,13 @@ fn set_stroke(s: &mut Session, p: &Value) -> Result { return Err(EngineError::Param("param 'width' must be in 0..=1000".into())); } let profile = opt_profile(p, "profile")?; - let default = s.style; + let default = s.style.clone(); for sh in shapes_mut(s)? { if remove { sh.stroke = None; continue; } - let mut st = sh.stroke.take().unwrap_or_else(|| Stroke::new(default.stroke, default.stroke_width).with_profile(default.stroke_profile.profile())); + let mut st = sh.stroke.take().unwrap_or_else(|| Stroke::new(default.stroke, default.stroke_width).with_profile(default.profile())); if let Some(c) = color { st.color = c; } diff --git a/crates/engine/src/cmds_erase.rs b/crates/engine/src/cmds_erase.rs new file mode 100644 index 00000000..bf532ff2 --- /dev/null +++ b/crates/engine/src/cmds_erase.rs @@ -0,0 +1,300 @@ +//! The Eraser's commands (ADR 0034). The eraser sweeps the Brush's tip (ADR 0033) and takes +//! the area it covers out of the raw shapes on the active layer (ADR 0031): the swept outline +//! goes into the planar merge as a fill whose regions come out empty, placed by the erase mode. +//! Drawing objects, symbols and text are left alone, as in Animate. + +use crate::cmds_brush::{bounded_samples, ranged, tip}; +use crate::merge::{self, Part, mergeable, reach}; +use crate::params::*; +use crate::{CommandSpec, EngineError, Result, Session}; +use anicraft_doc::{Element, ElementId, ElementKind, LayerKind}; +use anicraft_geom::brush::outline; +use anicraft_geom::planar::SNAP; +use anicraft_geom::{Affine, Path, PathCmd, Vec2}; +use serde_json::{Value, json}; + +pub fn specs() -> Vec { + let c = |id, label, menu, shortcut, params, mutates, run| CommandSpec { id, label, menu, shortcut, params, mutates, run }; + vec![ + c("draw.erase", "Eraser", "", None, "{points: [[x, y] or [x, y, pressure], ..] (one point erases a dab), size? (stage units, default 10), shape?: round|square, angle?, roundness?, mode?: normal|fills|lines|selected_fills|inside (Erase Normal takes fills and lines, Erase Fills leaves lines, Erase Lines leaves fills, Erase Selected Fills only the selected fills, Erase Inside only the fill the stroke starts on), unit? (stage units per screen point)} erases from the raw shapes on the active layer; drawing objects, symbols and text are kept", true, erase as crate::RunFn), + c("draw.faucet", "Faucet", "", None, "{x, y, slop?} deletes the whole raw fill or stroke under the point on the active layer", true, faucet), + c("draw.erase_all", "Erase Everything", "", None, "{} clears every visible, unlocked layer at the playhead (asks first; undoable)", true, erase_all), + ] +} + +/// An erase mode (Animate's names). +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +pub enum EraseMode { + #[default] + Normal, + Fills, + Lines, + SelectedFills, + Inside, +} + +impl EraseMode { + pub const ALL: [EraseMode; 5] = [EraseMode::Normal, EraseMode::Fills, EraseMode::Lines, EraseMode::SelectedFills, EraseMode::Inside]; + + pub fn key(self) -> &'static str { + match self { + EraseMode::Normal => "normal", + EraseMode::Fills => "fills", + EraseMode::Lines => "lines", + EraseMode::SelectedFills => "selected_fills", + EraseMode::Inside => "inside", + } + } + pub fn label(self) -> &'static str { + match self { + EraseMode::Normal => "Erase Normal", + EraseMode::Fills => "Erase Fills", + EraseMode::Lines => "Erase Lines", + EraseMode::SelectedFills => "Erase Selected Fills", + EraseMode::Inside => "Erase Inside", + } + } + pub fn hint(self) -> &'static str { + match self { + EraseMode::Normal => "Erases lines and fills on the layer.", + EraseMode::Fills => "Erases fills only, leaving lines alone.", + EraseMode::Lines => "Erases lines only, leaving fills alone.", + EraseMode::SelectedFills => "Erases only the selected fills.", + EraseMode::Inside => "Erases only inside the fill where the stroke starts.", + } + } + pub fn from_key(k: &str) -> Option { + EraseMode::ALL.into_iter().find(|m| m.key() == k) + } +} + +fn erase(s: &mut Session, p: &Value) -> Result { + let pts = bounded_samples(p)?; + let tip = tip(p)?; + let unit = ranged(p, "unit", 0.001..=1000.0, 1.0)?; + let mode_key = opt_str(p, "mode")?.unwrap_or("normal"); + let mode = EraseMode::from_key(mode_key).ok_or_else(|| EngineError::Param(format!("unknown erase mode '{mode_key}' (normal, fills, lines, selected_fills or inside)")))?; + let start = pts.first().map_or(Vec2::ZERO, |x| x.at); + // The eraser follows the hand (a third of a screen point), fitted as finely as the brush. + let path = outline(&pts, &tip, unit * 0.3, (unit * 0.35).min(tip.size * 0.01)); + if !path.cmds.iter().any(|c| matches!(c, PathCmd::CubicTo(..) | PathCmd::LineTo(..))) { + return Err(EngineError::Param("the stroke is too small to erase with".into())); + } + erase_with(s, &path, mode, start) +} + +/// Erases `eraser` (keyframe space) from the active layer's raw shapes, as `mode` says. +pub(crate) fn erase_with(s: &mut Session, eraser: &Path, mode: EraseMode, start: Vec2) -> Result { + let nothing = |why: &str| Ok(json!({"erased": false, "mode": mode.key(), "elements": [], "reason": why})); + // Nothing may change when nothing is erased (no keyframe made, no undo step). + let before = s.doc.clone(); + let els = s.editable_keyframe()?.elements.clone(); + let area = eraser.bounds().inflate(2.0 * SNAP); + let touching: Vec = (0..els.len()).filter(|&i| els.get(i).and_then(|e| mergeable(e).map(|sh| !reach(sh, &e.transform).intersect(&area).is_empty())).unwrap_or(false)).collect(); + let el = |i: &usize| els.get(*i).map(|e| e.as_ref()); + let is_fill = |i: &usize| el(i).and_then(mergeable).is_some_and(|sh| sh.fill.is_some()); + let fills: Vec = touching.iter().copied().filter(is_fill).collect(); + let lines: Vec = touching.iter().copied().filter(|i| !is_fill(i)).collect(); + // What the eraser takes from (it sits right above them), and what goes into the merge. + let (targets, members): (Vec, Vec) = match mode { + EraseMode::Normal => (touching.clone(), touching.clone()), + EraseMode::Fills => (fills.clone(), touching.clone()), + // Only the lines take part, so the fills stay exactly as they are. + EraseMode::Lines => (lines.clone(), lines.clone()), + EraseMode::SelectedFills => (fills.iter().copied().filter(|i| el(i).is_some_and(|e| s.selection.contains(&e.id))).collect(), touching.clone()), + EraseMode::Inside => { + // The topmost raw fill under the start of the stroke. + let at = fills.iter().rev().copied().find(|i| el(i).is_some_and(|e| mergeable(e).is_some_and(|sh| sh.path.contains(start, &e.transform, sh.fill_rule)))); + (at.into_iter().collect(), touching.clone()) + } + }; + if targets.is_empty() { + s.doc = before; + return nothing(match mode { + EraseMode::SelectedFills if s.selection.is_empty() => "select the fills to erase first", + EraseMode::Inside => "start the stroke on a fill to erase inside it", + _ => "nothing raw to erase there", + }); + } + // Bottom to top: the targets, the eraser, then the rest (fills before lines, so lines still + // cut the fills they cross and nothing hides them). + let rest: Vec = members.iter().copied().filter(|i| !targets.contains(i)).collect(); + let (rest_fills, rest_lines): (Vec, Vec) = rest.into_iter().partition(is_fill); + let selected = s.selection.clone(); + let shape = |i: &usize| el(i).map(|e| Part::Shape(e, selected.contains(&e.id))); + let parts: Vec = targets.iter().filter_map(shape).chain(std::iter::once(Part::Eraser(eraser))).chain(rest_fills.iter().filter_map(shape)).chain(rest_lines.iter().filter_map(shape)).collect(); + let Some((out, picked)) = merge::remerge(s, &parts) else { + s.doc = before; + return Err(EngineError::State("there is too much artwork under the eraser to erase at once; erase a smaller area".into())); + }; + // Erased nothing (the eraser only came near): leave the drawing as it was. + let was = measure(members.iter().filter_map(el)); + let now = measure(out.iter().map(|e| e.as_ref())); + let close = |a: f64, b: f64| (a - b).abs() <= 1e-3 + 1e-7 * a.abs().max(b.abs()); + if close(was.0, now.0) && close(was.1, now.1) { + s.doc = before; + return nothing("nothing raw to erase there"); + } + let ids: Vec = out.iter().map(|e| e.id.0).collect(); + let gone: Vec = members.iter().filter_map(el).map(|e| e.id).collect(); + merge::replace(s, &members, out, false)?; + // What stays selected: the rest of the selection, and what is left of selected shapes. + s.selection.retain(|id| !gone.contains(id)); + s.selection.extend(picked); + Ok(json!({"erased": true, "mode": mode.key(), "elements": ids, "area_erased": (was.0 - now.0).max(0.0), "length_erased": (was.1 - now.1).max(0.0)})) +} + +/// Total fill area and stroke length of raw shapes, in keyframe space. Fill areas are exact +/// (Green's theorem with Gauss–Legendre nodes, exact for cubics); lengths are by Gauss–Legendre +/// too, so a shape that comes back from the merge unchanged measures exactly the same. +fn measure<'a>(els: impl Iterator) -> (f64, f64) { + let (mut area, mut length) = (0.0, 0.0); + for e in els { + let Some(sh) = mergeable(e) else { continue }; + if sh.fill.is_some() { + area += signed_area(&sh.path, &e.transform).abs(); + } + if sh.stroke.is_some() { + length += path_length(&sh.path, &e.transform); + } + } + (area, length) +} + +/// The path's segments as cubics, in the space `m` maps to (closing segments included). +fn cubics(path: &Path, m: &Affine) -> Vec<[Vec2; 4]> { + let mut out = Vec::new(); + let (mut start, mut cur) = (Vec2::ZERO, Vec2::ZERO); + let line = |a: Vec2, b: Vec2| [a, a.lerp(b, 1.0 / 3.0), a.lerp(b, 2.0 / 3.0), b]; + for c in &path.cmds { + match *c { + PathCmd::MoveTo(p) => { + start = m.apply(p); + cur = start; + } + PathCmd::LineTo(p) => { + let p = m.apply(p); + out.push(line(cur, p)); + cur = p; + } + PathCmd::QuadTo(q, p) => { + let (q, p) = (m.apply(q), m.apply(p)); + out.push([cur, cur.lerp(q, 2.0 / 3.0), p.lerp(q, 2.0 / 3.0), p]); + cur = p; + } + PathCmd::CubicTo(a, b, p) => { + let (a, b, p) = (m.apply(a), m.apply(b), m.apply(p)); + out.push([cur, a, b, p]); + cur = p; + } + PathCmd::Close => { + if cur != start { + out.push(line(cur, start)); + } + cur = start; + } + } + } + out +} + +/// A cubic's point and derivative at `t`, in f64. +fn point_and_tangent(c: &[Vec2; 4], t: f64) -> ((f64, f64), (f64, f64)) { + let p = |v: Vec2| (f64::from(v.x), f64::from(v.y)); + let [p0, p1, p2, p3] = c.map(p); + let u = 1.0 - t; + let (b0, b1, b2, b3) = (u * u * u, 3.0 * u * u * t, 3.0 * u * t * t, t * t * t); + let at = (b0 * p0.0 + b1 * p1.0 + b2 * p2.0 + b3 * p3.0, b0 * p0.1 + b1 * p1.1 + b2 * p2.1 + b3 * p3.1); + let (d0, d1, d2) = (3.0 * u * u, 6.0 * u * t, 3.0 * t * t); + let d = (d0 * (p1.0 - p0.0) + d1 * (p2.0 - p1.0) + d2 * (p3.0 - p2.0), d0 * (p1.1 - p0.1) + d1 * (p2.1 - p1.1) + d2 * (p3.1 - p2.1)); + (at, d) +} + +/// Five-point Gauss–Legendre nodes and weights on 0..1. +const GAUSS: [(f64, f64); 5] = [ + (0.046_910_077_030_668, 0.118_463_442_528_094_5), + (0.230_765_344_947_158_45, 0.239_314_335_249_683_2), + (0.5, 0.284_444_444_444_444_4), + (0.769_234_655_052_841_6, 0.239_314_335_249_683_2), + (0.953_089_922_969_332, 0.118_463_442_528_094_5), +]; + +fn signed_area(path: &Path, m: &Affine) -> f64 { + // ½ ∮ (x dy − y dx): a degree-5 polynomial per cubic, which these nodes integrate exactly. + cubics(path, m).iter().map(|c| GAUSS.iter().map(|&(t, w)| { + let ((x, y), (dx, dy)) = point_and_tangent(c, t); + w * (x * dy - y * dx) + }).sum::()).sum::() * 0.5 +} + +fn path_length(path: &Path, m: &Affine) -> f64 { + cubics(path, m).iter().map(|c| GAUSS.iter().map(|&(t, w)| { + let (_, (dx, dy)) = point_and_tangent(c, t); + w * (dx * dx + dy * dy).sqrt() + }).sum::()).sum() +} + +/// `draw.faucet`: Animate's Faucet deletes a whole fill or stroke with one click. +fn faucet(s: &mut Session, p: &Value) -> Result { + let at = Vec2::new(f32_req(p, "x")?, f32_req(p, "y")?); + let slop = opt_f32(p, "slop")?.unwrap_or(2.0).clamp(0.0, 100.0); + let els = s.visible_elements(); + // Topmost shape on the active layer under the point: in a fill, or on a stroke. + let hit = els.iter().rev().find(|e| match &e.kind { + ElementKind::Shape(sh) => { + let hw = sh.stroke.as_ref().map_or(0.0, |st| st.reach() * e.transform.mean_scale()); + let near = sh.path.bounds().transformed(&e.transform).inflate(hw + slop).contains(at); + near && ((sh.fill.is_some() && sh.path.contains(at, &e.transform, sh.fill_rule)) || (sh.stroke.is_some() && sh.path.distance_to_edge(at, &e.transform) <= hw + slop)) + } + ElementKind::Symbol { .. } | ElementKind::Text(_) => s.element_bounds(e.id).contains(at), + ElementKind::Camera => false, + }); + let Some(hit) = hit else { + return Err(EngineError::State("click a fill or a line on this layer to delete it".into())); + }; + if mergeable(hit).is_none() { + return Err(EngineError::State("the faucet deletes raw fills and lines; drawing objects, symbols and text are kept (select one and press Delete)".into())); + } + let (id, line) = (hit.id, matches!(&hit.kind, ElementKind::Shape(sh) if sh.fill.is_none())); + let kf = s.editable_keyframe()?; + kf.elements.retain(|e| e.id != id); + s.selection.retain(|x| *x != id); + Ok(json!({"deleted": id.0, "kind": if line { "line" } else { "fill" }})) +} + +/// The layers `draw.erase_all` clears: visible, unlocked layers that hold artwork (not folders, +/// not the camera), with the number of elements at the playhead on each. +pub(crate) fn erasable_layers(s: &Session) -> Vec<(anicraft_doc::LayerId, usize)> { + let tl = s.doc.timeline(s.scene); + tl.layers + .iter() + .filter(|l| l.visible && !l.locked && !tl.locked_by_folder(l.id) && !matches!(l.kind, LayerKind::Folder | LayerKind::Camera)) + .filter_map(|l| l.keyframe_at(s.frame).map(|k| (l.id, k.elements.len()))) + .filter(|(_, n)| *n > 0) + .collect() +} + +/// `draw.erase_all`: double-clicking the Eraser clears the stage at this frame: every element on +/// the visible, unlocked layers' keyframes at the playhead (raw shapes, objects, symbols, text). +fn erase_all(s: &mut Session, _: &Value) -> Result { + let layers = erasable_layers(s); + let (scene, frame) = (s.scene, s.frame); + let mut erased = 0; + for (id, _) in &layers { + let Some(layer) = s.doc.timeline_mut(scene).layer_mut(*id) else { continue }; + let Some(i) = layer.keyframe_index_at(frame) else { continue }; + let Some(kf) = layer.keyframe_mut(i) else { continue }; + erased += kf.elements.len(); + kf.elements.clear(); + // Nothing is left to tween. + kf.tween = None; + kf.motion = None; + } + s.selection.clear(); + Ok(json!({"erased": erased, "layers": layers.len()})) +} + +#[cfg(test)] +pub(crate) fn measure_els(els: &[std::sync::Arc]) -> (f64, f64) { + measure(els.iter().map(|e| e.as_ref())) +} diff --git a/crates/engine/src/cmds_paint.rs b/crates/engine/src/cmds_paint.rs index 7de80231..a5ac6bbe 100644 --- a/crates/engine/src/cmds_paint.rs +++ b/crates/engine/src/cmds_paint.rs @@ -1,4 +1,4 @@ -//! Paint Bucket and Ink Bottle. +//! Paint Bucket, Ink Bottle and Eyedropper. //! //! AniCraft shapes are independent objects (like object drawing), so a fill for an area //! enclosed by several shapes has to be found, not looked up: @@ -32,6 +32,8 @@ pub fn specs() -> Vec { vec![ c("paint.bucket", "Paint Bucket", "", None, "{x, y, color?, gap? (stage units: how wide an opening still counts as closed)}", true, bucket as crate::RunFn), c("paint.ink", "Ink Bottle", "", None, "{x, y, color?, width?, profile?}", true, ink), + c("paint.pick", "Eyedropper", "", None, "{x, y, other?: bool (into the other swatch only: a fill's colour into the stroke, a line's into the fill), slop?} picks the style under the point on any visible layer into the tool settings: a fill's paint (solid, gradient or bitmap, kept where it is on the stage) into the fill swatch, a line's colour, width and profile into the stroke settings", false, pick_style), + c("paint.apply_style", "Apply Style", "", None, "{fill?: bool, stroke?: bool} (default both) gives the selected shapes the fill swatch's paint (shapes with a fill) and the stroke settings (shapes with a line, and drawing objects without one)", true, apply_style), ] } @@ -68,7 +70,8 @@ fn element_shape_mut(s: &mut Session, id: ElementId) -> Result<&mut Shape> { fn bucket(s: &mut Session, p: &Value) -> Result { let at = Vec2::new(f32_req(p, "x")?, f32_req(p, "y")?); - let color = opt_color(p, "color")?.unwrap_or(s.style.fill); + // The fill swatch (a picked gradient or bitmap stays where it is on the stage). + let paint = opt_color(p, "color")?.map_or_else(|| s.style.fill_paint(), Paint::Solid); let gap = opt_f32(p, "gap")?.unwrap_or(0.0); if !(0.0..=1000.0).contains(&gap) { return Err(EngineError::Param("param 'gap' must be between 0 and 1000".into())); @@ -76,7 +79,8 @@ fn bucket(s: &mut Session, p: &Value) -> Result { let items = layer_items(s); // 1. On a fill: recolour it. if let Some((id, true)) = pick(&items, at, 0.0) { - element_shape_mut(s, id)?.fill = Some(Paint::Solid(color)); + let to_local = items.iter().find(|i| i.element == id).and_then(|i| i.transform.inverse()).unwrap_or(Affine::IDENTITY); + element_shape_mut(s, id)?.fill = Some(paint.transformed(&to_local)); return Ok(json!({"recolored": id.0})); } // 2. Find the enclosed area. @@ -91,7 +95,7 @@ fn bucket(s: &mut Session, p: &Value) -> Result { name: String::new(), transform: Affine::translate(c.x, c.y), color: ColorEffect::default(), - kind: ElementKind::Shape(Shape { path: Arc::new(local), fill: Some(Paint::Solid(color)), stroke: None, fill_rule: FillRule::EvenOdd, merge: false }), + kind: ElementKind::Shape(Shape { path: Arc::new(local), fill: Some(paint.transformed(&Affine::translate(-c.x, -c.y))), stroke: None, fill_rule: FillRule::EvenOdd, merge: false }), }; let kf = s.editable_keyframe()?; if kf.elements.len() >= 100_000 { @@ -283,8 +287,128 @@ fn ink(s: &mut Session, p: &Value) -> Result { let (id, _) = pick(&items, at, slop).ok_or_else(|| EngineError::State("click a shape to give it this stroke".into()))?; let profile = match opt_profile(p, "profile")? { Some(pr) => pr, - None => s.style.stroke_profile.profile(), + None => s.style.profile(), }; element_shape_mut(s, id)?.stroke = Some(Stroke::new(color, width).with_profile(profile)); Ok(json!({"element": id.0})) } + +/// The kind of a paint, as commands report it. +fn paint_kind(p: &Paint) -> &'static str { + match p { + Paint::Solid(_) => "solid", + Paint::Linear { .. } => "linear", + Paint::Radial { .. } => "radial", + Paint::Bitmap { .. } => "bitmap", + } +} + +/// What the Eyedropper found: a fill's paint (stage space), or a line's stroke and the scale it +/// is drawn at. +enum Picked { + Fill(Paint), + Line(Stroke, f32), +} + +/// `paint.pick`: the Eyedropper. The topmost thing drawn under the point on any visible layer +/// (locked ones too: picking reads, it doesn't change them): on a line, its stroke; in a fill, +/// its paint. +fn pick_style(s: &mut Session, p: &Value) -> Result { + let at = Vec2::new(f32_req(p, "x")?, f32_req(p, "y")?); + let other = opt_bool(p, "other")?.unwrap_or(false); + let slop = opt_f32(p, "slop")?.unwrap_or(2.0).clamp(0.0, 100.0); + let dl = s.display_list(); + let hit = dl.items.iter().rev().find_map(|it| { + // Mask artwork isn't drawn, and masked-away parts can't be picked. + if it.masks.is_some() || it.clip.is_some_and(|c| !dl.clip_contains(c, at)) { + return None; + } + let hw = it.stroke.as_ref().map_or(0.0, |st| st.reach() * it.transform.mean_scale()); + if !it.path.bounds().transformed(&it.transform).inflate(hw + slop).contains(at) { + return None; + } + if let Some(st) = &it.stroke + && it.path.distance_to_edge(at, &it.transform) <= hw + slop + { + return Some(Picked::Line(st.clone(), it.transform.mean_scale())); + } + match &it.fill { + Some(f) if it.path.contains(at, &it.transform, it.fill_rule) => Some(Picked::Fill(f.transformed(&it.transform))), + _ => None, + } + }); + let st = &mut s.style; + match hit { + Some(Picked::Fill(paint)) => { + let color = paint.primary_color(); + if other { + st.stroke = color; + st.use_stroke = true; + return Ok(json!({"picked": "fill", "into": "stroke", "paint": paint_kind(&paint), "color": color.to_hex()})); + } + st.fill = color; + st.fill_paint = (!matches!(paint, Paint::Solid(_))).then(|| paint.clone()); + st.use_fill = true; + Ok(json!({"picked": "fill", "into": "fill", "paint": paint_kind(&paint), "color": color.to_hex()})) + } + Some(Picked::Line(stroke, scale)) => { + if other { + st.set_fill_color(stroke.color); + st.use_fill = true; + return Ok(json!({"picked": "line", "into": "fill", "paint": "solid", "color": stroke.color.to_hex()})); + } + st.stroke = stroke.color; + st.stroke_width = (stroke.width * scale).clamp(0.1, 1000.0); + st.use_stroke = true; + let preset = anicraft_doc::ProfilePreset::ALL.into_iter().find(|pr| pr.profile() == stroke.profile); + let profile = match preset { + Some(pr) => { + st.set_profile(pr); + pr.key() + } + None => { + st.custom_profile = stroke.profile.clone(); + "custom" + } + }; + Ok(json!({"picked": "line", "into": "stroke", "color": stroke.color.to_hex(), "width": st.stroke_width, "profile": profile})) + } + None => Err(EngineError::State("click a fill or a line to pick its colour".into())), + } +} + +/// `paint.apply_style`: what the Eyedropper does with a selection (Animate applies the picked +/// style to it). +fn apply_style(s: &mut Session, p: &Value) -> Result { + let fill = opt_bool(p, "fill")?.unwrap_or(true); + let stroke = opt_bool(p, "stroke")?.unwrap_or(true); + if !fill && !stroke { + return Err(EngineError::Param("apply the fill, the stroke or both".into())); + } + let style = s.style.clone(); + let paint = style.fill_paint(); + let line = Stroke::new(style.stroke, style.stroke_width).with_profile(style.profile()); + let mut changed = 0; + for e in s.selected_elements_mut()? { + let to_local = e.transform.inverse(); + let ElementKind::Shape(sh) = &mut e.kind else { continue }; + let mut hit = false; + if fill + && sh.fill.is_some() + && let Some(m) = to_local + { + sh.fill = Some(paint.transformed(&m)); + hit = true; + } + // Raw fills stay fill-only: the lines round them are shapes of their own (ADR 0031). + if stroke && (sh.stroke.is_some() || !sh.merge) { + sh.stroke = Some(line.clone()); + hit = true; + } + changed += usize::from(hit); + } + if changed == 0 { + return Err(EngineError::State("none of the selected items is a shape that takes this style".into())); + } + Ok(json!({"changed": changed})) +} diff --git a/crates/engine/src/confirm.rs b/crates/engine/src/confirm.rs index 2fc73a75..c3c2f5a7 100644 --- a/crates/engine/src/confirm.rs +++ b/crates/engine/src/confirm.rs @@ -145,6 +145,17 @@ pub fn confirmation(s: &Session, id: &str, p: &Value) -> Option { irreversible: false, }) } + "draw.erase_all" => { + // Double-clicking the Eraser: everything on the stage at this frame (ADR 0034). + let layers = crate::cmds_erase::erasable_layers(s); + let elements: usize = layers.iter().map(|(_, n)| n).sum(); + (elements > 0).then(|| Confirmation { + title: "Erase everything?".into(), + message: format!("Everything on the stage at frame {} goes: {} on {}. Locked and hidden layers are kept. You can undo this.", s.frame + 1, plural(elements, "element"), plural(layers.len(), "layer")), + action: "Erase Everything".into(), + irreversible: false, + }) + } "camera.remove" => camera_removal(s, s.doc.timeline(s.scene).camera_layer()?), "layer.delete" => { let l = target_layer(s, p)?; diff --git a/crates/engine/src/erase_tests.rs b/crates/engine/src/erase_tests.rs new file mode 100644 index 00000000..be5f6c42 --- /dev/null +++ b/crates/engine/src/erase_tests.rs @@ -0,0 +1,230 @@ +//! The Eraser's commands (ADR 0034). + +use crate::Session; +use crate::cmds_erase::measure_els; +use anicraft_doc::{ElementKind, Paint, Rgba, Shape}; +use anicraft_geom::{Affine, Vec2}; +use serde_json::{Value, json}; + +fn run(s: &mut Session, id: &str, p: Value) -> Value { + s.execute(id, &p).unwrap_or_else(|e| panic!("{id}: {e}")) +} + +fn blank(object: bool) -> Session { + let mut s = Session::new(anicraft_doc::Document::default()); + run(&mut s, "draw.object_drawing", json!({"on": object})); + s +} + +/// The keyframe's shapes, bottom to top, with their transforms. +fn shapes(s: &Session) -> Vec<(Shape, Affine)> { + s.visible_elements() + .iter() + .filter_map(|e| match &e.kind { + ElementKind::Shape(sh) => Some((sh.clone(), e.transform)), + _ => None, + }) + .collect() +} + +fn fill_of(sh: &Shape) -> Option { + match sh.fill { + Some(Paint::Solid(c)) => Some(c), + _ => None, + } +} + +/// The fill colour covering stage point `p` (the topmost filled shape containing it). +fn top_at(s: &Session, p: Vec2) -> Option { + shapes(s).iter().rev().filter(|(sh, _)| sh.fill.is_some()).find(|(sh, m)| sh.path.contains(p, m, sh.fill_rule)).and_then(|(sh, _)| fill_of(sh)) +} + +/// Total raw fill area and line length on the active layer. +fn measure(s: &Session) -> (f64, f64) { + measure_els(&s.visible_elements()) +} + +fn stroke(x0: f32, y0: f32, x1: f32, y1: f32) -> Vec<[f32; 2]> { + (0..=30).map(|i| i as f32 / 30.0).map(|t| [x0 + (x1 - x0) * t, y0 + (y1 - y0) * t]).collect() +} + +const BLUE: &str = "#0000ff"; +const RED: &str = "#ff0000"; +const BLACK: &str = "#000000"; + +fn near(a: f64, b: f64, tol: f64) -> bool { + (a - b).abs() <= tol +} + +/// A raw 200 × 100 blue rectangle at (100, 100), outlined in black 4 wide when `outlined`. +fn rect(outlined: bool) -> Session { + let mut s = blank(false); + let stroke = if outlined { json!(BLACK) } else { Value::Null }; + run(&mut s, "draw.rect", json!({"x": 100, "y": 100, "w": 200, "h": 100, "fill": BLUE, "stroke": stroke, "stroke_width": 4})); + run(&mut s, "edit.deselect", json!({})); + s +} + +#[test] +fn erasing_a_band_out_of_a_rectangle_leaves_the_analytic_area() { + let mut s = rect(false); + assert!(near(measure(&s).0, 20_000.0, 0.01)); + let steps = s.history_len(); + // A round tip 20 wide straight down through the middle: its ends are outside the shape. + let r = run(&mut s, "draw.erase", json!({"points": stroke(200.0, 60.0, 200.0, 240.0), "size": 20})); + assert_eq!(r["erased"], true); + let (area, _) = measure(&s); + assert!(near(area, 18_000.0, 40.0), "area {area}, want 20000 − 20 × 100"); + let blues = shapes(&s).iter().filter(|(sh, _)| fill_of(sh) == Some(Rgba::hex(0x0000ff))).count(); + assert_eq!(blues, 2, "the band cuts the rectangle in two"); + assert!(shapes(&s).iter().all(|(sh, _)| sh.merge), "what is left is raw"); + assert_eq!(top_at(&s, Vec2::new(200.0, 150.0)), None); + assert_eq!(top_at(&s, Vec2::new(150.0, 150.0)), Some(Rgba::hex(0x0000ff))); + // The CPU renderer agrees (the oracle): the stage shows through the band. + let img = anicraft_render::render_frame(&s.doc, 0, 1.0).unwrap(); + let bg = s.doc.stage.background; + let (gap, kept) = (img.pixel(200, 150).unwrap(), img.pixel(150, 150).unwrap()); + assert!((gap[0] - bg.r).abs() < 0.02 && (gap[2] - bg.b).abs() < 0.02, "{gap:?}"); + assert!(kept[2] > 0.9 && kept[0] < 0.1, "{kept:?}"); + // One stroke, one undo step. + assert_eq!(s.history_len(), steps + 1); + run(&mut s, "edit.undo", json!({})); + assert!(near(measure(&s).0, 20_000.0, 0.01)); +} + +#[test] +fn erase_modes_take_what_animate_takes() { + let band = stroke(50.0, 150.0, 350.0, 150.0); + // Fill 200 × 100 = 20000, lines 2 × (200 + 100) = 600; the band is 20 tall across it all. + let after = |mode: &str| { + let mut s = rect(true); + let r = run(&mut s, "draw.erase", json!({"points": band, "size": 20, "mode": mode})); + assert_eq!(r["erased"], true, "{mode}"); + measure(&s) + }; + let (area, length) = after("normal"); + assert!(near(area, 16_000.0, 40.0) && near(length, 560.0, 1.0), "normal: {area} {length}"); + let (area, length) = after("fills"); + assert!(near(area, 16_000.0, 40.0) && near(length, 600.0, 0.01), "fills keeps lines: {area} {length}"); + let (area, length) = after("lines"); + assert!(near(area, 20_000.0, 0.01) && near(length, 560.0, 1.0), "lines keeps fills: {area} {length}"); +} + +/// Blue at x 100..200 and red at 200..300 (raw, side by side), no outlines. +fn two_fills() -> Session { + let mut s = blank(false); + run(&mut s, "draw.rect", json!({"x": 100, "y": 100, "w": 100, "h": 100, "fill": BLUE, "stroke": null})); + run(&mut s, "draw.rect", json!({"x": 200, "y": 100, "w": 100, "h": 100, "fill": RED, "stroke": null})); + run(&mut s, "edit.deselect", json!({})); + s +} + +fn fill_area(s: &Session, c: u32) -> f64 { + let els: Vec<_> = s.visible_elements().into_iter().filter(|e| matches!(&e.kind, ElementKind::Shape(sh) if fill_of(sh) == Some(Rgba::hex(c)))).collect(); + measure_els(&els).0 +} + +#[test] +fn erase_selected_fills_and_erase_inside_keep_the_other_fills() { + let band = stroke(50.0, 150.0, 350.0, 150.0); + // Selected fills: only the selected (blue) one loses the band, and what's left stays selected. + let mut s = two_fills(); + let r = run(&mut s, "draw.erase", json!({"points": band, "size": 20, "mode": "selected_fills"})); + assert_eq!(r["erased"], false, "nothing selected, nothing erased"); + let blue = s.visible_elements().iter().find(|e| matches!(&e.kind, ElementKind::Shape(sh) if fill_of(sh) == Some(Rgba::hex(0x0000ff)))).map(|e| e.id.0).unwrap(); + run(&mut s, "element.select", json!({"ids": [blue]})); + run(&mut s, "draw.erase", json!({"points": band, "size": 20, "mode": "selected_fills"})); + assert!(near(fill_area(&s, 0x0000ff), 8_000.0, 30.0) && near(fill_area(&s, 0xff0000), 10_000.0, 0.01), "{} {}", fill_area(&s, 0x0000ff), fill_area(&s, 0xff0000)); + assert_eq!(s.selection.len(), 2, "both blue pieces stay selected"); + // Inside: only the fill the stroke starts on (a 50 × 20 band and the round start's half disc). + let mut s = two_fills(); + run(&mut s, "draw.erase", json!({"points": stroke(150.0, 150.0, 350.0, 150.0), "size": 20, "mode": "inside"})); + let want = 10_000.0 - 1_000.0 - std::f64::consts::PI * 50.0; + assert!(near(fill_area(&s, 0x0000ff), want, 20.0) && near(fill_area(&s, 0xff0000), 10_000.0, 0.01), "{} {}", fill_area(&s, 0x0000ff), fill_area(&s, 0xff0000)); + // Starting off the artwork erases nothing, and leaves no undo step. + let steps = s.history_len(); + let r = run(&mut s, "draw.erase", json!({"points": stroke(50.0, 150.0, 350.0, 150.0), "size": 20, "mode": "inside"})); + assert_eq!(r["erased"], false); + assert_eq!(s.history_len(), steps); +} + +#[test] +fn drawing_objects_and_symbols_are_not_erased() { + let mut s = blank(true); + run(&mut s, "draw.rect", json!({"x": 100, "y": 100, "w": 200, "h": 100, "fill": BLUE})); + run(&mut s, "draw.ellipse", json!({"x": 100, "y": 220, "w": 200, "h": 60, "fill": RED})); + run(&mut s, "modify.convert_to_symbol", json!({"name": "Disc"})); + let (doc, steps) = (s.doc.clone(), s.history_len()); + let r = run(&mut s, "draw.erase", json!({"points": stroke(200.0, 60.0, 200.0, 300.0), "size": 30})); + assert_eq!(r["erased"], false); + assert_eq!(s.doc, doc, "objects and symbols are untouched"); + assert_eq!(s.history_len(), steps, "no undo step"); + // Raw shapes beside them are erased, the object stays whole. + run(&mut s, "draw.rect", json!({"x": 320, "y": 100, "w": 100, "h": 100, "fill": BLUE, "stroke": null, "object": false})); + run(&mut s, "draw.erase", json!({"points": stroke(150.0, 150.0, 450.0, 150.0), "size": 20})); + let objects = shapes(&s).into_iter().filter(|(sh, _)| !sh.merge).collect::>(); + assert_eq!(objects.len(), 1, "the rectangle object is whole"); + assert!(near(measure_els(&s.visible_elements()).0, 8_000.0, 30.0), "only the raw square lost the band"); +} + +#[test] +fn the_faucet_deletes_a_whole_fill_or_line() { + let mut s = rect(true); + let lines = shapes(&s).iter().filter(|(sh, _)| sh.stroke.is_some()).count(); + let r = run(&mut s, "draw.faucet", json!({"x": 150, "y": 150})); + assert_eq!(r["kind"], "fill"); + assert!(shapes(&s).iter().all(|(sh, _)| sh.fill.is_none()), "the fill is gone, its outline stays"); + let r = run(&mut s, "draw.faucet", json!({"x": 100, "y": 150})); + assert_eq!(r["kind"], "line"); + assert_eq!(shapes(&s).len(), lines - 1, "one side of the outline is gone"); + assert!(s.execute("draw.faucet", &json!({"x": 600, "y": 600})).is_err(), "nothing there"); + // Drawing objects are kept. + run(&mut s, "draw.rect", json!({"x": 400, "y": 100, "w": 50, "h": 50, "fill": RED, "object": true})); + assert!(s.execute("draw.faucet", &json!({"x": 425, "y": 125})).is_err()); +} + +#[test] +fn erase_everything_asks_first_and_keeps_locked_layers() { + let mut s = rect(true); + run(&mut s, "layer.new", json!({"name": "Kept"})); + run(&mut s, "draw.ellipse", json!({"x": 0, "y": 0, "w": 50, "h": 50, "fill": RED, "object": true})); + run(&mut s, "layer.toggle_lock", json!({})); + let c = s.confirmation("draw.erase_all", &json!({})).expect("it asks"); + assert!(!c.irreversible, "undoable"); + assert!(c.message.contains("5 elements on 1 layer"), "{}", c.message); + let r = run(&mut s, "draw.erase_all", json!({})); + assert_eq!(r["erased"], 5); + let tl = s.doc.timeline(0); + let counts: Vec = tl.layers.iter().map(|l| l.keyframe_at(0).map_or(0, |k| k.elements.len())).collect(); + assert!(counts.contains(&0) && counts.contains(&1), "{counts:?}"); + assert!(s.confirmation("draw.erase_all", &json!({})).is_none(), "nothing left to ask about"); + run(&mut s, "edit.undo", json!({})); + assert_eq!(s.doc.timeline(0).layers.iter().map(|l| l.keyframe_at(0).map_or(0, |k| k.elements.len())).sum::(), 6); +} + +#[test] +fn erased_drawings_round_trip_through_the_file_format() { + let mut s = rect(true); + run(&mut s, "draw.erase", json!({"points": [[150, 150, 0.3], [200, 160, 1.0], [260, 140, 0.6]], "size": 24})); + let json = crate::format::to_json(&s.doc).unwrap(); + assert_eq!(crate::format::from_json(&json).unwrap(), s.doc); +} + +#[test] +fn bad_params_are_errors_and_plug_ins_may_erase() { + let mut s = rect(true); + for p in [ + json!({}), + json!({"points": []}), + json!({"points": [[0, 0]], "size": 0}), + json!({"points": [[0, 0]], "mode": "behind"}), + json!({"points": [[0, 0]], "shape": "star"}), + json!({"points": [[0, 0], [1e7, 0]]}), + ] { + assert!(s.execute("draw.erase", &p).is_err(), "{p}"); + } + assert!(s.execute("draw.faucet", &json!({"x": "a"})).is_err()); + for id in ["draw.erase", "draw.faucet", "draw.erase_all", "paint.pick", "paint.apply_style"] { + assert!(crate::cmds_plugin::plugin_may_call(id).is_ok(), "{id}"); + } +} diff --git a/crates/engine/src/eyedropper_tests.rs b/crates/engine/src/eyedropper_tests.rs new file mode 100644 index 00000000..18efa673 --- /dev/null +++ b/crates/engine/src/eyedropper_tests.rs @@ -0,0 +1,132 @@ +//! The Eyedropper's commands (ADR 0034). + +use crate::Session; +use anicraft_doc::{ElementId, ElementKind, GradientStop, Paint, ProfilePreset, Rgba, Shape}; +use anicraft_geom::{Affine, Vec2}; +use serde_json::{Value, json}; + +fn run(s: &mut Session, id: &str, p: Value) -> Value { + s.execute(id, &p).unwrap_or_else(|e| panic!("{id}: {e}")) +} + +fn shape(s: &Session, id: u64) -> (Shape, Affine) { + s.visible_elements() + .iter() + .find(|e| e.id == ElementId(id)) + .and_then(|e| match &e.kind { + ElementKind::Shape(sh) => Some((sh.clone(), e.transform)), + _ => None, + }) + .expect("a shape") +} + +fn rect(s: &mut Session, x: f32, fill: &str) -> u64 { + run(s, "draw.rect", json!({"x": x, "y": 100, "w": 100, "h": 100, "fill": fill, "stroke": null}))["element"].as_u64().unwrap() +} + +/// A linear gradient across the shape's own width (local space: the shape is centred on 0). +fn gradient() -> Paint { + Paint::Linear { start: Vec2::new(-50.0, 0.0), end: Vec2::new(50.0, 0.0), stops: vec![GradientStop { offset: 0.0, color: Rgba::hex(0xff8800) }, GradientStop { offset: 1.0, color: Rgba::hex(0x0044ff) }] } +} + +#[test] +fn picking_a_solid_fill_sets_the_fill_colour_and_records_no_step() { + let mut s = Session::default(); + rect(&mut s, 100.0, "#ff0000"); + let steps = s.history_len(); + let r = run(&mut s, "paint.pick", json!({"x": 150, "y": 150})); + assert_eq!((r["picked"].as_str(), r["into"].as_str(), r["paint"].as_str()), (Some("fill"), Some("fill"), Some("solid"))); + assert_eq!(s.style.fill, Rgba::hex(0xff0000)); + assert!(s.style.fill_paint.is_none()); + assert_eq!(s.history_len(), steps, "picking changes the tool, not the document"); + assert!(s.execute("paint.pick", &json!({"x": 900, "y": 900})).is_err(), "nothing there"); + // Shift-click: into the other swatch only. + s.style.set_fill_color(Rgba::hex(0x00ff00)); + let r = run(&mut s, "paint.pick", json!({"x": 150, "y": 150, "other": true})); + assert_eq!(r["into"], "stroke"); + assert_eq!((s.style.stroke, s.style.fill), (Rgba::hex(0xff0000), Rgba::hex(0x00ff00))); +} + +#[test] +fn a_picked_gradient_stays_where_it_is_on_the_stage() { + let mut s = Session::default(); + let a = rect(&mut s, 100.0, "#ff0000"); + let b = rect(&mut s, 300.0, "#00ff00"); + for e in s.editable_keyframe().unwrap().elements_mut_where(|id| id == ElementId(a)) { + if let ElementKind::Shape(sh) = &mut e.kind { + sh.fill = Some(gradient()); + } + } + let r = run(&mut s, "paint.pick", json!({"x": 150, "y": 150})); + assert_eq!(r["paint"], "linear"); + assert_eq!(s.style.fill, Rgba::hex(0xff8800), "the swatch shows its first colour"); + // In stage space: the shape's centre is (150, 150). + match &s.style.fill_paint { + Some(Paint::Linear { start, end, .. }) => assert!(start.distance(Vec2::new(100.0, 150.0)) < 1e-3 && end.distance(Vec2::new(200.0, 150.0)) < 1e-3, "{start:?} {end:?}"), + other => panic!("{other:?}"), + } + // The Paint Bucket pours it into the other shape, mapped into that shape's space, so the + // gradient carries on across the stage (Animate's Lock Fill). + run(&mut s, "paint.bucket", json!({"x": 350, "y": 150})); + let (sh, m) = shape(&s, b); + match sh.fill { + Some(Paint::Linear { start, .. }) => assert!(m.apply(start).distance(Vec2::new(100.0, 150.0)) < 1e-3, "{:?}", m.apply(start)), + other => panic!("{other:?}"), + } + // Picking a colour in the swatch drops the gradient. + s.style.set_fill_color(Rgba::hex(0x123456)); + assert!(s.style.fill_paint.is_none()); +} + +#[test] +fn picking_a_line_takes_its_colour_width_and_profile() { + let mut s = Session::default(); + run(&mut s, "draw.line", json!({"x0": 100, "y0": 100, "x1": 300, "y1": 100, "stroke": "#336699", "stroke_width": 6, "profile": "taper_both"})); + let r = run(&mut s, "paint.pick", json!({"x": 200, "y": 101})); + assert_eq!((r["picked"].as_str(), r["profile"].as_str()), (Some("line"), Some("taper_both"))); + assert_eq!(s.style.stroke, Rgba::hex(0x336699)); + assert!((s.style.stroke_width - 6.0).abs() < 1e-4); + assert_eq!(s.style.stroke_profile, ProfilePreset::TaperBoth); + // A custom profile, on a line drawn twice the size: the width is as it shows on the stage. + run(&mut s, "draw.line", json!({"x0": 100, "y0": 300, "x1": 300, "y1": 300, "stroke": "#000000", "stroke_width": 4, "profile": [[0, 1, 1], [0.3, 2, 2], [1, 0.5, 0.5]]})); + run(&mut s, "element.set_transform", json!({"sx": 2, "sy": 2})); + let r = run(&mut s, "paint.pick", json!({"x": 200, "y": 300})); + assert_eq!(r["profile"], "custom"); + assert!(s.style.custom_profile.is_some() && (s.style.stroke_width - 8.0).abs() < 1e-3, "{}", s.style.stroke_width); + // New lines get it. + let id = run(&mut s, "draw.line", json!({"x0": 0, "y0": 0, "x1": 50, "y1": 0}))["element"].as_u64().unwrap(); + assert_eq!(shape(&s, id).0.stroke.and_then(|st| st.profile), s.style.custom_profile); + // Shift-click on a line: its colour into the fill. + run(&mut s, "paint.pick", json!({"x": 200, "y": 101, "other": true})); + assert_eq!(s.style.fill, Rgba::hex(0x336699)); +} + +#[test] +fn applying_the_picked_style_to_the_selection_is_one_step() { + let mut s = Session::default(); + let a = rect(&mut s, 100.0, "#ff0000"); + let b = rect(&mut s, 300.0, "#00ff00"); + run(&mut s, "element.select", json!({"ids": [b]})); + run(&mut s, "paint.pick", json!({"x": 150, "y": 150})); + let steps = s.history_len(); + let r = run(&mut s, "paint.apply_style", json!({"fill": true, "stroke": false})); + assert_eq!(r["changed"], 1); + assert_eq!(s.history_len(), steps + 1); + assert_eq!(shape(&s, b).0.fill, Some(Paint::Solid(Rgba::hex(0xff0000)))); + assert_eq!(shape(&s, a).0.fill, Some(Paint::Solid(Rgba::hex(0xff0000))), "the source is unchanged"); + // The stroke settings go onto a drawing object that had none. + run(&mut s, "paint.apply_style", json!({"fill": false})); + assert!(shape(&s, b).0.stroke.is_some()); + run(&mut s, "edit.deselect", json!({})); + assert!(s.execute("paint.apply_style", &json!({})).is_err(), "nothing selected"); + assert!(s.execute("paint.apply_style", &json!({"fill": false, "stroke": false})).is_err()); +} + +#[test] +fn picking_reads_locked_layers_too() { + let mut s = Session::default(); + rect(&mut s, 100.0, "#ff0000"); + run(&mut s, "layer.toggle_lock", json!({})); + run(&mut s, "paint.pick", json!({"x": 150, "y": 150})); + assert_eq!(s.style.fill, Rgba::hex(0xff0000)); +} diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 516e0f0a..2deb2a05 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -9,6 +9,7 @@ mod cmds_actions; pub mod cmds_brush; mod cmds_camera; mod cmds_draw; +pub mod cmds_erase; mod cmds_file; mod cmds_frames; mod cmds_modify; @@ -107,6 +108,7 @@ pub fn commands() -> Vec { v.extend(cmds_modify::specs()); v.extend(cmds_path::specs()); v.extend(cmds_brush::specs()); + v.extend(cmds_erase::specs()); v.extend(cmds_paint::specs()); v.extend(cmds_text::specs()); v.extend(cmds_width::specs()); @@ -134,15 +136,20 @@ pub use history::{Snapshot, StateId}; pub const MAX_FRAME: u32 = 100_000; /// Drawing defaults used by the drawing commands when params omit colours. -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Debug)] pub struct ToolStyle { pub fill: anicraft_doc::Rgba, + /// The fill swatch holds a gradient or a bitmap (picked with the Eyedropper, ADR 0034), in + /// stage space; `fill` is then its representative colour. `None`: the solid `fill`. + pub fill_paint: Option, pub stroke: anicraft_doc::Rgba, pub stroke_width: f32, pub use_fill: bool, pub use_stroke: bool, /// The width profile new strokes get (ADR 0018). pub stroke_profile: anicraft_doc::ProfilePreset, + /// A picked width profile that is none of the presets (it wins over `stroke_profile`). + pub custom_profile: Option, /// Object Drawing: new shapes are drawing objects. Off, they merge with the raw shapes they /// touch (ADR 0031). On by default, so a script's draw command makes one element; the editor /// starts with it off, as Animate does. @@ -151,7 +158,28 @@ pub struct ToolStyle { impl Default for ToolStyle { fn default() -> Self { - ToolStyle { fill: anicraft_doc::Rgba::hex(0x3d8bfd), stroke: anicraft_doc::Rgba::hex(0x1b2a4a), stroke_width: 2.0, use_fill: true, use_stroke: true, stroke_profile: anicraft_doc::ProfilePreset::Uniform, object_drawing: true } + ToolStyle { fill: anicraft_doc::Rgba::hex(0x3d8bfd), fill_paint: None, stroke: anicraft_doc::Rgba::hex(0x1b2a4a), stroke_width: 2.0, use_fill: true, use_stroke: true, stroke_profile: anicraft_doc::ProfilePreset::Uniform, custom_profile: None, object_drawing: true } + } +} + +impl ToolStyle { + /// The fill swatch's paint, in stage space. + pub fn fill_paint(&self) -> anicraft_doc::Paint { + self.fill_paint.clone().unwrap_or(anicraft_doc::Paint::Solid(self.fill)) + } + /// Sets the fill swatch to a solid colour (dropping a picked gradient or bitmap). + pub fn set_fill_color(&mut self, c: anicraft_doc::Rgba) { + self.fill = c; + self.fill_paint = None; + } + /// The width profile new strokes get. + pub fn profile(&self) -> Option { + self.custom_profile.clone().or_else(|| self.stroke_profile.profile()) + } + /// Sets the profile to a preset (dropping a picked custom one). + pub fn set_profile(&mut self, p: anicraft_doc::ProfilePreset) { + self.stroke_profile = p; + self.custom_profile = None; } } @@ -293,7 +321,7 @@ impl Session { /// Replaces the document (new/open), clearing history. pub fn replace_document(&mut self, doc: Document, path: Option) { - let style = self.style; + let style = std::mem::take(&mut self.style); let rev = self.revision; let budget = self.history.budget_bytes; let clipboard = std::mem::take(&mut self.clipboard); @@ -706,3 +734,7 @@ mod tests_camera; mod merge_tests; #[cfg(test)] mod brush_tests; +#[cfg(test)] +mod erase_tests; +#[cfg(test)] +mod eyedropper_tests; diff --git a/crates/engine/src/merge.rs b/crates/engine/src/merge.rs index f078ea36..d593a664 100644 --- a/crates/engine/src/merge.rs +++ b/crates/engine/src/merge.rs @@ -19,7 +19,7 @@ pub fn specs() -> Vec { } /// A raw shape the merge can take: a solid fill (or none) and a stroke of one width (or none). -fn mergeable(e: &Element) -> Option<&Shape> { +pub(crate) fn mergeable(e: &Element) -> Option<&Shape> { match &e.kind { ElementKind::Shape(s) if s.merge && matches!(s.fill, None | Some(Paint::Solid(_))) && s.stroke.as_ref().is_none_or(|st| st.profile.is_none()) => Some(s), _ => None, @@ -32,7 +32,7 @@ pub(crate) fn can_merge(fill: Option<&Paint>, stroke: Option<&Stroke>) -> bool { matches!(fill, None | Some(Paint::Solid(_))) && stroke.is_none_or(|st| st.profile.is_none()) } -fn reach(s: &Shape, m: &Affine) -> Rect { +pub(crate) fn reach(s: &Shape, m: &Affine) -> Rect { let pad = s.stroke.as_ref().map_or(0.0, Stroke::reach) * m.mean_scale(); s.path.bounds().transformed(m).inflate(pad + 2.0 * SNAP) } @@ -71,28 +71,13 @@ pub(crate) fn merge_in_order(s: &mut Session, new: Vec, order: Order) - .collect(); let old: Vec<&Element> = touching.iter().filter_map(|&i| existing.get(i).map(|e| e.as_ref())).collect(); let is_line = |e: &&Element| mergeable(e).is_some_and(|sh| sh.fill.is_none()); - // Bottom to top, each with whether it is new. - let all: Vec<(&Element, bool)> = match order { - Order::Top => old.iter().map(|e| (*e, false)).chain(new.iter().map(|e| (e, true))).collect(), - Order::Behind => new.iter().map(|e| (e, true)).chain(old.iter().map(|e| (*e, false))).collect(), - Order::UnderLines => old.iter().filter(|e| !is_line(e)).map(|e| (*e, false)).chain(new.iter().map(|e| (e, true))).chain(old.iter().filter(|e| is_line(e)).map(|e| (*e, false))).collect(), + // Bottom to top, the new shapes marked (their pieces are selected). + let all: Vec = match order { + Order::Top => old.iter().map(|e| Part::Shape(e, false)).chain(new.iter().map(|e| Part::Shape(e, true))).collect(), + Order::Behind => new.iter().map(|e| Part::Shape(e, true)).chain(old.iter().map(|e| Part::Shape(e, false))).collect(), + Order::UnderLines => old.iter().filter(|e| !is_line(e)).map(|e| Part::Shape(e, false)).chain(new.iter().map(|e| Part::Shape(e, true))).chain(old.iter().filter(|e| is_line(e)).map(|e| Part::Shape(e, false))).collect(), }; - // Style tables: equal entries are one style to the merge. - let mut fills: Vec<(Paint, ColorEffect)> = Vec::new(); - let mut strokes: Vec<(Stroke, ColorEffect)> = Vec::new(); - let mut paths: Vec = Vec::with_capacity(all.len()); - let mut styles: Vec<(Option, Option, anicraft_geom::FillRule)> = Vec::with_capacity(all.len()); - let mut fresh: Vec = Vec::with_capacity(all.len()); - for (e, is_new) in &all { - let Some(sh) = mergeable(e) else { continue }; - paths.push(sh.path.transformed(&e.transform)); - let fill = sh.fill.clone().map(|f| index_of(&mut fills, (f, e.color))); - let stroke = sh.stroke.clone().map(|st| index_of(&mut strokes, (Stroke { width: st.width * e.transform.mean_scale(), ..st }, e.color))); - styles.push((fill, stroke, sh.fill_rule)); - fresh.push(*is_new); - } - let items: Vec = paths.iter().zip(&styles).map(|(path, &(fill, stroke, fill_rule))| Item { path, fill, fill_rule, stroke }).collect(); - let Some(merged) = planar::merge(&items) else { + let Some((out, picked)) = remerge(s, &all) else { // Too much to merge at once: keep the new shapes whole, as objects. kept.extend(new.iter().map(|e| e.id)); let objects = new @@ -107,11 +92,58 @@ pub(crate) fn merge_in_order(s: &mut Session, new: Vec, order: Order) - add_whole(s.editable_keyframe()?, objects, order); return Ok(kept); }; + replace(s, &touching, out, order == Order::Behind)?; + kept.extend(picked); + Ok(kept) +} + +/// One entry of a merge, bottom to top. +pub(crate) enum Part<'a> { + /// A raw shape, and whether it is marked (the pieces it ends up on top of are reported). + Shape(&'a Element, bool), + /// The eraser (ADR 0034): a fill whose regions come out empty. Above a shape it takes away + /// what it covers, fills and the lines it covers on both sides; under a shape, nothing of it. + Eraser(&'a Path), +} + +/// The fill style the eraser paints: regions of it are dropped. +const ERASED: u32 = u32::MAX; + +/// Merges `parts` into raw shapes (one element per fill region and per stroke run, fills first) +/// and returns them with the ids of the pieces whose topmost source part was marked. `None` when +/// there is too much to merge at once. +pub(crate) fn remerge(s: &mut Session, parts: &[Part]) -> Option<(Vec>, Vec)> { + // Style tables: equal entries are one style to the merge. + let mut fills: Vec<(Paint, ColorEffect)> = Vec::new(); + let mut strokes: Vec<(Stroke, ColorEffect)> = Vec::new(); + let mut paths: Vec = Vec::with_capacity(parts.len()); + let mut styles: Vec<(Option, Option, anicraft_geom::FillRule)> = Vec::with_capacity(parts.len()); + let mut marked: Vec = Vec::with_capacity(parts.len()); + for part in parts { + match part { + Part::Shape(e, mark) => { + let Some(sh) = mergeable(e) else { continue }; + paths.push(sh.path.transformed(&e.transform)); + let fill = sh.fill.clone().map(|f| index_of(&mut fills, (f, e.color))); + let stroke = sh.stroke.clone().map(|st| index_of(&mut strokes, (Stroke { width: st.width * e.transform.mean_scale(), ..st }, e.color))); + styles.push((fill, stroke, sh.fill_rule)); + marked.push(*mark); + } + Part::Eraser(path) => { + paths.push((*path).clone()); + styles.push((Some(ERASED), None, anicraft_geom::FillRule::NonZero)); + marked.push(false); + } + } + } + let items: Vec = paths.iter().zip(&styles).map(|(path, &(fill, stroke, fill_rule))| Item { path, fill, fill_rule, stroke }).collect(); + let merged = planar::merge(&items)?; let mut out: Vec> = Vec::with_capacity(merged.fills.len() + merged.strokes.len()); let mut picked = Vec::new(); for (piece, is_fill) in merged.fills.iter().map(|p| (p, true)).chain(merged.strokes.iter().map(|p| (p, false))) { let (fill, stroke, color) = if is_fill { - let Some((f, c)) = fills.get(piece.style as usize) else { continue }; + // Erased regions (and anything without a style) are left out. + let Some((f, c)) = fills.get(piece.style as usize).filter(|_| piece.style != ERASED) else { continue }; (Some(f.clone()), None, *c) } else { let Some((st, c)) = strokes.get(piece.style as usize) else { continue }; @@ -120,7 +152,7 @@ pub(crate) fn merge_in_order(s: &mut Session, new: Vec, order: Order) - // Local origin at the centre of the piece, as the drawing tools place shapes. let c = piece.path.bounds().center(); let id = ElementId(s.doc.alloc_id()); - if fresh.get(piece.item).copied().unwrap_or(false) { + if marked.get(piece.item).copied().unwrap_or(false) { picked.push(id); } out.push(Arc::new(Element { @@ -131,22 +163,26 @@ pub(crate) fn merge_in_order(s: &mut Session, new: Vec, order: Order) - kind: ElementKind::Shape(Shape { path: Arc::new(piece.path.transformed(&Affine::translate(-c.x, -c.y))), fill, stroke, fill_rule: Default::default(), merge: true }), })); } + Some((out, picked)) +} + +/// Replaces the keyframe's elements at `taken` (ascending indices) with `out`, placed where the +/// lowest of them was (raw shapes sit under objects); taking nothing, on top, or at the bottom +/// when `behind`. +pub(crate) fn replace(s: &mut Session, taken: &[usize], out: Vec>, behind: bool) -> Result<()> { let kf = s.editable_keyframe()?; - if kf.elements.len() - touching.len() + out.len() > 100_000 { + if kf.elements.len().saturating_sub(taken.len()) + out.len() > 100_000 { return Err(crate::EngineError::State("too many elements on this keyframe".into())); } - // The drawing goes where the lowest shape it took in was (raw shapes sit under objects); - // touching nothing, on top, or at the bottom when painting behind. - let at = touching.first().copied().unwrap_or(if order == Order::Behind { 0 } else { kf.elements.len() }); - for &i in touching.iter().rev() { + let at = taken.first().copied().unwrap_or(if behind { 0 } else { kf.elements.len() }); + for &i in taken.iter().rev() { if i < kf.elements.len() { kf.elements.remove(i); } } let at = at.min(kf.elements.len()); kf.elements.splice(at..at, out); - kept.extend(picked); - Ok(kept) + Ok(()) } /// Shapes added whole (objects): on top, or at the bottom when painting behind. diff --git a/crates/engine/src/tests.rs b/crates/engine/src/tests.rs index 60710cfc..2a5e6c37 100644 --- a/crates/engine/src/tests.rs +++ b/crates/engine/src/tests.rs @@ -565,6 +565,11 @@ fn panic_hunt_every_command() { json!({"points": [[0, 0, 0.0], [99_999, 99_999, 1.0], [-99_999, 5, 0.5]], "size": 2000, "shape": "square", "angle": 1e6, "roundness": 5, "smoothing": 0, "mode": "behind", "unit": 0.001}), json!({"points": (0..3000).map(|i| json!([i % 7, (i * 13) % 11, f64::from(i % 3) * 0.5])).collect::>(), "size": 0.1, "mode": "fills", "smoothing": 100, "unit": 1000}), json!({"points": [[5, 5, -1], [6, 6, "x"]], "shape": 3, "mode": null, "roundness": f64::NAN}), + // Eraser and Eyedropper (ADR 0034): strokes over the raw shapes, a tip larger than the + // stage, picks into the other swatch, styles applied to whatever is selected. + json!({"points": [[0, 0], [40, 40], [90, 5]], "size": 30, "mode": "selected_fills", "x": 30, "y": 30, "slop": 0}), + json!({"points": [[45, 45]], "size": 2000, "mode": "inside", "x": 45, "y": 45, "other": true, "fill": false, "stroke": true}), + json!({"points": [[5, 5], [55, 55]], "size": 4, "mode": "lines", "shape": "square", "x": 1, "y": 1, "fill": "yes"}), ]; // File commands are exercised separately (they touch the disk). let skip = |id: &str| id.starts_with("file."); diff --git a/src/panels.rs b/src/panels.rs index 9550f0aa..f6b3442b 100644 --- a/src/panels.rs +++ b/src/panels.rs @@ -79,7 +79,7 @@ fn tool_column(app: &mut App, ui: &mut egui::Ui, area: Rect) { } ui.add_space(10.0); // fill / stroke swatches - let st = app.s.style; + let st = &app.s.style; let (r, _) = ui.allocate_exact_size(vec2(TOOL_BUTTON, TOOL_BUTTON), Sense::hover()); let back = Rect::from_min_size(r.left_top() + vec2(14.0, 14.0), vec2(24.0, 24.0)); let front = Rect::from_min_size(r.left_top() + vec2(2.0, 2.0), vec2(24.0, 24.0)); @@ -1238,7 +1238,7 @@ fn tool_props(app: &mut App, ui: &mut egui::Ui) { } return; } - let mut st = app.s.style; + let mut st = app.s.style.clone(); // Each tool shows only what it uses: the bucket and the brush always fill, the ink bottle // always strokes. let (fills, ink) = (matches!(app.tool, Tool::PaintBucket | Tool::Brush), app.tool == Tool::InkBottle); @@ -1246,7 +1246,18 @@ fn tool_props(app: &mut App, ui: &mut egui::Ui) { row(ui, "Fill", |ui| { let mut c = rgb(st.fill); if ui.color_edit_button_srgb(&mut c).named("Fill colour").changed() { - st.fill = Rgba::new(c[0] as f32 / 255.0, c[1] as f32 / 255.0, c[2] as f32 / 255.0, 1.0); + st.set_fill_color(Rgba::new(c[0] as f32 / 255.0, c[1] as f32 / 255.0, c[2] as f32 / 255.0, 1.0)); + } + // A gradient or bitmap picked with the Eyedropper (ADR 0034): the swatch shows its + // first colour, and says what it holds. + if let Some(p) = &st.fill_paint { + let what = match p { + Paint::Linear { .. } => "Linear gradient", + Paint::Radial { .. } => "Radial gradient", + Paint::Bitmap { .. } => "Bitmap fill", + Paint::Solid(_) => "Solid", + }; + ui.label(text(Type::Caption, what)).on_hover_text("Picked with the Eyedropper. It stays where it was on the stage (lock fill). Pick a colour to fill with a solid colour again."); } if !fills { crate::theme::checkbox(ui, &mut st.use_fill, "").named("Fill").on_hover_text("Fill on/off"); @@ -1265,9 +1276,9 @@ fn tool_props(app: &mut App, ui: &mut egui::Ui) { ui.add(egui::DragValue::new(&mut st.stroke_width).suffix(" px").speed(0.1).range(0.0..=100.0).max_decimals(1)).set_name("Stroke width"); }); // The width profile new strokes get. - let current = st.stroke_profile.profile(); + let current = st.profile(); if let Some(pick) = profile_picker(ui, ProfileRow::Tool, current.as_ref()) { - st.stroke_profile = pick; + st.set_profile(pick); } } // Merge drawing (ADR 0031) or drawing objects, for the tools that draw shapes. diff --git a/src/stage.rs b/src/stage.rs index bf5cf449..a89fd6d9 100644 --- a/src/stage.rs +++ b/src/stage.rs @@ -1178,7 +1178,7 @@ fn create_shape(app: &mut App, start: Pos2, cur: Pos2) { } fn draw_preview(app: &App, painter: &egui::Painter, a: Pos2, b: Pos2, zoom: f32) { - let st = app.s.style; + let st = &app.s.style; let fill = if st.use_fill { crate::theme::to_color32(st.fill).gamma_multiply(0.6) } else { Color32::TRANSPARENT }; let stroke = Stroke::new((st.stroke_width * zoom).max(1.0), if st.use_stroke { crate::theme::to_color32(st.stroke) } else { T.selection }); match app.tool { From b28f1dffe16b9ac1543ac678a1dd797e94edefea Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Mon, 9 Nov 2026 22:17:52 -0700 Subject: [PATCH 2/8] fix(xfl): movie clips by default, brightness, instance names, comments, custom eases, and reports for what draws differently (M4) A symbol without symbolType is a movie clip (the format leaves defaults out). Brightness becomes a tint towards white or black; advanced colour effects keep alpha and are reported. Movie clip and button instance names that are identifiers are kept for actions (ADR 0024). Frame comments are no longer labels. A one-segment custom ease is its cubic Bezier. Reverse loop modes, non-round caps and joins, gradient strokes, repeating, reflecting, focal-point, elliptical and linear-RGB gradients and extra tween spins are reported instead of silently changed. --- crates/xfl/src/import.rs | 129 +++++++++++++++++++++++++++++++++------ crates/xfl/src/tests.rs | 28 +++++++++ 2 files changed, 139 insertions(+), 18 deletions(-) diff --git a/crates/xfl/src/import.rs b/crates/xfl/src/import.rs index a5b96d36..092d8d9e 100644 --- a/crates/xfl/src/import.rs +++ b/crates/xfl/src/import.rs @@ -9,7 +9,10 @@ //! depth; bitmaps (library items, instances and bitmap fills) whose image is stored as PNG or //! JPEG in the package; text fields, laid out with this computer's fonts (`text`, ADR 0014). //! Everything else (sound, motion tweens with property curves, unknown filters, -//! bitmaps kept only in Animate's own storage) is counted in the report instead of guessed at. +//! bitmaps kept only in Animate's own storage) is counted in the report instead of guessed at, +//! and so is whatever is drawn the nearest way AniCraft can (square caps, reflecting +//! gradients, advanced colour effects, …). The self-authored corpus in `tests/corpus/` covers +//! every feature listed here, with golden renders (ADR 0035). use crate::edges::{self, Edge}; use crate::xml::{self, Element as X}; @@ -154,6 +157,24 @@ fn paint(def: &X, bitmaps: &HashMap, report: &mut Report) -> O if stops.is_empty() { return None; } + // What AniCraft's gradients can't draw yet is drawn the nearest way, and said. + if def.attr("spreadMethod").is_some_and(|s| s.trim() != "pad") { + report.skip("repeating and reflecting gradients (drawn padded)"); + } + if def.attr("interpolationMethod").is_some_and(|s| s.trim() == "linearRGB") { + report.skip("linear-RGB gradients (blended in sRGB)"); + } + if def.name == "RadialGradient" { + if def.f32("focalPointRatio").is_some_and(|f| f != 0.0) { + report.skip("radial gradient focal points (drawn centred)"); + } + let (x, y) = (m.apply_vector(Vec2::new(1.0, 0.0)), m.apply_vector(Vec2::new(0.0, 1.0))); + let (lx, ly) = (x.length(), y.length()); + // Columns of different lengths, or not at right angles: an ellipse. + if (lx - ly).abs() > 0.01 * lx.max(ly) || x.dot(y).abs() > 0.01 * lx * ly { + report.skip("elliptical radial gradients (drawn round)"); + } + } Some(if def.name == "LinearGradient" { Paint::Linear { start: m.apply(Vec2::new(-GRADIENT_HALF, 0.0)), end: m.apply(Vec2::new(GRADIENT_HALF, 0.0)), stops } } else { @@ -185,9 +206,21 @@ fn stroke(def: &X, bitmaps: &HashMap, report: &mut Report) -> if def.name != "SolidStroke" { report.skip("stroke styles drawn as solid"); } + // AniCraft strokes have round caps and joins (the format's default). + let round = |k: &str| def.attr(k).is_none_or(|v| v.trim() == "round"); + if !round("caps") || !round("joints") { + report.skip("stroke caps and joins other than round (drawn round)"); + } let width = def.f32("weight").unwrap_or(1.0).clamp(0.05, 1000.0); let fill = def.child("fill").and_then(|f| f.children.first()); - let c = fill.map_or(Rgba::BLACK, |f| if f.name == "SolidColor" { color(f, "color", "alpha") } else { paint(f, bitmaps, report).map_or(Rgba::BLACK, |p| p.primary_color()) }); + let c = fill.map_or(Rgba::BLACK, |f| { + if f.name == "SolidColor" { + color(f, "color", "alpha") + } else { + report.skip("gradient and bitmap strokes (drawn in one colour)"); + paint(f, bitmaps, report).map_or(Rgba::BLACK, |p| p.primary_color()) + } + }); Some(Stroke::new(c, width)) } @@ -329,30 +362,57 @@ impl<'a> Builder<'a> { } } + /// An instance's `Color`: alpha, tint, or brightness (a tint towards white or black by that + /// amount, which is the same colour change). Other channel multipliers and offsets + /// (Animate's Advanced style) keep only their alpha, and are reported. + fn color_effect(&mut self, c: &X) -> ColorEffect { + let mut fx = ColorEffect { alpha: c.f32("alphaMultiplier").unwrap_or(1.0).clamp(0.0, 1.0), ..ColorEffect::default() }; + if let Some(t) = c.f32("tintMultiplier") { + fx.tint = color(c, "tintColor", "__none"); + fx.tint_amount = t.clamp(0.0, 1.0); + } else if let Some(b) = c.f32("brightness").filter(|b| *b != 0.0) { + fx.tint = if b > 0.0 { Rgba::WHITE } else { Rgba::BLACK }; + fx.tint_amount = b.abs().min(1.0); + } else { + let multiplied = ["redMultiplier", "greenMultiplier", "blueMultiplier"].iter().any(|k| c.f32(k).is_some_and(|v| v != 1.0)); + let offset = ["redOffset", "greenOffset", "blueOffset", "alphaOffset"].iter().any(|k| c.f32(k).is_some_and(|v| v != 0.0)); + if multiplied || offset { + self.report.skip("advanced colour effects (only alpha kept)"); + } + } + fx + } + fn instance(&mut self, el: &X, parent: &Affine, out: &mut Vec>) { let Some(&symbol) = el.attr("libraryItemName").and_then(|n| self.ids.get(n)) else { self.report.skip("instances of missing symbols"); return; }; - let loop_mode = match el.attr("loop") { + let loop_mode = match el.attr("loop").map(str::trim) { Some("play once") => LoopMode::PlayOnce, Some("single frame") => LoopMode::SingleFrame, + Some(r @ ("play once reverse" | "loop reverse")) => { + self.report.skip("reverse loop modes (played forward)"); + if r == "loop reverse" { LoopMode::Loop } else { LoopMode::PlayOnce } + } _ => LoopMode::Loop, }; let first_frame = el.u32("firstFrame").unwrap_or(0).min(MAX_FRAME); - let mut fx = ColorEffect::default(); - if let Some(c) = el.child("color").and_then(|c| c.child("Color")) { - fx.alpha = c.f32("alphaMultiplier").unwrap_or(1.0).clamp(0.0, 1.0); - if let Some(t) = c.f32("tintMultiplier") { - fx.tint = color(c, "tintColor", "__none"); - fx.tint_amount = t.clamp(0.0, 1.0); - } - } + let fx = el.child("color").and_then(|c| c.child("Color")).map_or_else(ColorEffect::default, |c| self.color_effect(c)); let m = parent.mul(&matrix(el)); // Blend modes by Animate's names; unknown ones stay Normal. let blend = el.attr("blendMode").and_then(BlendMode::from_key).unwrap_or_default(); let filters = self.filters(el); - out.push(self.element(ElementKind::Symbol { symbol, loop_mode, first_frame, blend, filters, events: Vec::new() }, m, fx)); + let mut e = Element { id: ElementId(self.doc.alloc_id()), name: String::new(), transform: m, color: fx, kind: ElementKind::Symbol { symbol, loop_mode, first_frame, blend, filters, events: Vec::new() } }; + // The instance name actions address it by (ADR 0024); one they couldn't is reported. + if let Some(name) = el.attr("name").map(str::trim).filter(|n| !n.is_empty()) { + if anicraft_doc::actions::valid_instance_name(name) { + e.name = name.to_string(); + } else { + self.report.skip("instance names actions can't use (left out)"); + } + } + out.push(Arc::new(e)); } fn elements(&mut self, list: &[X], parent: &Affine, out: &mut Vec>, depth: usize) { @@ -413,13 +473,21 @@ impl<'a> Builder<'a> { let start = f.u32("index").unwrap_or(0).min(MAX_FRAME); let duration = f.u32("duration").unwrap_or(1).clamp(1, MAX_FRAME); let mut k = Keyframe::new(start, duration); - k.label = f.attr("name").unwrap_or("").chars().take(256).collect(); + // A frame's name is a label (or an anchor, a label too); a comment is a note + // to the animator that nothing can go to, which AniCraft has no place for yet. + if f.attr("labelType").map(str::trim) == Some("comment") { + self.report.skip("frame comments"); + } else { + k.label = f.attr("name").unwrap_or("").chars().take(256).collect(); + } match f.attr("tweenType") { Some(t @ ("motion" | "shape")) => { - let acc = f.f32("acceleration").unwrap_or(0.0).clamp(-100.0, 100.0); let kind = if t == "shape" { TweenKind::Shape } else { TweenKind::Classic }; let orient = f.bool("motionTweenOrientToPath").unwrap_or(false); - k.tween = Some(Tween { easing: if acc == 0.0 { Easing::Linear } else { Easing::Classic(acc) }, kind, orient }); + if kind == TweenKind::Classic && f.attr("motionTweenRotate").is_some_and(|r| matches!(r.trim(), "clockwise" | "counter-clockwise")) { + self.report.skip("tween spins (turned the shortest way)"); + } + k.tween = Some(Tween { easing: self.easing(f), kind, orient }); } Some("motion object") => self.report.skip("motion tweens (kept as keyframes)"), _ => {} @@ -455,6 +523,29 @@ impl<'a> Builder<'a> { tl } + /// A tween's ease: the classic single-slider `acceleration`, or a custom ease curve. A + /// curve of one segment (four points from (0, 0) to (1, 1)) is a cubic Bézier exactly; a + /// longer one, or one per property, is drawn with the slider's ease and reported. + fn easing(&mut self, f: &X) -> Easing { + let acc = f.f32("acceleration").unwrap_or(0.0).clamp(-100.0, 100.0); + let classic = if acc == 0.0 { Easing::Linear } else { Easing::Classic(acc) }; + if f.bool("hasCustomEase") != Some(true) { + return classic; + } + let curves: Vec<&X> = f.list("tweens").iter().filter(|c| c.name == "CustomEase").collect(); + let one_curve = f.bool("useSingleEaseCurve") != Some(false) || curves.len() == 1; + let bezier = curves.first().filter(|_| one_curve).and_then(|c| { + let p: Vec = c.children.iter().filter(|p| p.name == "Point").take(5).map(|p| Vec2::new(p.f32("x").unwrap_or(0.0), p.f32("y").unwrap_or(0.0))).collect(); + let [a, b, c, d] = p.as_slice() else { return None }; + let near = |p: &Vec2, x: f32, y: f32| (p.x - x).abs() < 1e-3 && (p.y - y).abs() < 1e-3; + (near(a, 0.0, 0.0) && near(d, 1.0, 1.0)).then(|| Easing::CubicBezier(b.x.clamp(0.0, 1.0), b.y.clamp(-10.0, 10.0), c.x.clamp(0.0, 1.0), c.y.clamp(-10.0, 10.0))) + }); + bezier.unwrap_or_else(|| { + self.report.skip("custom ease curves (drawn with the simple ease)"); + classic + }) + } + /// The hints listed in a frame's `shapeHints`, in letter order (ADR 0023). Each child is a /// hint; it gives its point on this keyframe as `x`/`y` (or `startPoint="x, y"`, or /// `startX`/`startY`), and may carry its end point too (`endPoint`, or `endX`/`endY`); @@ -573,10 +664,12 @@ impl<'a> Builder<'a> { continue; } let name = item.attr("name").map(str::to_string).unwrap_or_else(|| href.trim_end_matches(".xml").to_string()); - let kind = match item.attr("symbolType") { - Some("movie clip") => SymbolKind::MovieClip, + // The format leaves out default values, and a symbol's default type is movie clip: + // only graphics and buttons say what they are. + let kind = match item.attr("symbolType").map(str::trim) { + Some("graphic") => SymbolKind::Graphic, Some("button") => SymbolKind::Button, - _ => SymbolKind::Graphic, + _ => SymbolKind::MovieClip, }; let id = SymbolId(self.doc.alloc_id()); self.ids.insert(name.clone(), id); diff --git a/crates/xfl/src/tests.rs b/crates/xfl/src/tests.rs index 5ad8b89d..8a8a5bc5 100644 --- a/crates/xfl/src/tests.rs +++ b/crates/xfl/src/tests.rs @@ -355,3 +355,31 @@ fn odd_shape_hints_are_reported_not_fatal() { assert!(d.timeline(0).layers[0].keyframes[0].hints.is_empty()); assert!(report.skipped.contains_key("shape hints missing on the end keyframe")); } + +#[test] +fn eases_names_and_loop_modes_the_corpus_found_missing() { + let frame = |attrs: &str, inner: &str| format!(r#"{inner}"#); + let pts = |p: &[(f32, f32)]| p.iter().map(|(x, y)| format!(r#""#)).collect::(); + let layers = [ + // Seven points: a curve of two segments, drawn with the slider's ease. + frame(r#"hasCustomEase="true" acceleration="30""#, &format!(r#"{}"#, pts(&[(0.0, 0.0), (0.2, 0.0), (0.3, 0.5), (0.5, 0.5), (0.7, 0.5), (0.8, 1.0), (1.0, 1.0)]))), + // One curve per property: also the slider's. + frame(r#"hasCustomEase="true" useSingleEaseCurve="false""#, &format!(r#"{0}{0}"#, pts(&[(0.0, 0.0), (0.5, 0.0), (0.5, 1.0), (1.0, 1.0)]))), + // Said to have a custom ease, with none there. + frame(r#"hasCustomEase="true""#, ""), + ]; + let layers: String = layers.iter().map(|f| format!(r#"{f}"#)).collect(); + let doc = format!(r#"{layers}"#); + let doc: &'static str = Box::leak(doc.into_boxed_str()); + let clip = r#""#; + let (d, report) = import(&HashMap::from([("DOMDocument.xml", doc), ("LIBRARY/Clip.xml", clip)])).unwrap(); + let eases: Vec = d.timeline(0).layers.iter().map(|l| l.keyframes[0].tween.unwrap().easing).collect(); + assert_eq!(eases, [anicraft_doc::Easing::Classic(30.0), anicraft_doc::Easing::Linear, anicraft_doc::Easing::Linear]); + assert_eq!(report.skipped.get("custom ease curves (drawn with the simple ease)"), Some(&3)); + assert_eq!(d.library[0].kind, SymbolKind::MovieClip, "no symbolType: a movie clip"); + let ElementKind::Symbol { loop_mode, .. } = &d.timeline(0).layers[0].keyframes[0].elements[0].kind else { panic!() }; + assert_eq!(*loop_mode, LoopMode::Loop, "loop reverse plays forward"); + assert_eq!(report.skipped.get("reverse loop modes (played forward)"), Some(&3)); + assert_eq!(d.timeline(0).layers[0].keyframes[0].elements[0].name, "", "not an identifier: left out"); + assert_eq!(report.skipped.get("instance names actions can't use (left out)"), Some(&3)); +} From cc85a76be118fa59fa83b5711175c9f322363520 Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Mon, 9 Nov 2026 22:17:52 -0700 Subject: [PATCH 3/8] test(xfl): a self-authored corpus of eleven XFL packages with report, structure and hostile-variant tests (M4) Every feature the importer claims, in hand-written XFL folders (with original PNG and JPEG images). Each package has an exact report expectation and targeted structure checks; 2,963 hostile variants (cut short, garbled, files missing) import without panicking and evaluate, in 0.15 s. The golden renders are committed with the packages. --- crates/xfl/tests/corpus.rs | 350 ++++++++++++++++++ .../xfl/tests/corpus/bitmaps/DOMDocument.xml | 67 ++++ .../corpus/bitmaps/LIBRARY/art/checker.png | Bin 0 -> 104 bytes .../corpus/bitmaps/LIBRARY/art/sunset.jpg | Bin 0 -> 315 bytes crates/xfl/tests/corpus/bitmaps/bitmaps.xfl | 1 + .../tests/corpus/bitmaps/golden/frame-000.png | Bin 0 -> 9064 bytes .../xfl/tests/corpus/filters/DOMDocument.xml | 66 ++++ .../xfl/tests/corpus/filters/LIBRARY/Chip.xml | 20 + crates/xfl/tests/corpus/filters/filters.xfl | 1 + .../tests/corpus/filters/golden/frame-000.png | Bin 0 -> 9610 bytes .../tests/corpus/gradients/DOMDocument.xml | 83 +++++ .../corpus/gradients/golden/frame-000.png | Bin 0 -> 11441 bytes .../xfl/tests/corpus/gradients/gradients.xfl | 1 + .../xfl/tests/corpus/guides/DOMDocument.xml | 71 ++++ .../xfl/tests/corpus/guides/LIBRARY/Ball.xml | 19 + .../xfl/tests/corpus/guides/LIBRARY/Box.xml | 19 + .../tests/corpus/guides/golden/frame-000.png | Bin 0 -> 1065 bytes .../tests/corpus/guides/golden/frame-006.png | Bin 0 -> 1678 bytes .../tests/corpus/guides/golden/frame-012.png | Bin 0 -> 1065 bytes crates/xfl/tests/corpus/guides/guides.xfl | 1 + crates/xfl/tests/corpus/masks/DOMDocument.xml | 94 +++++ .../tests/corpus/masks/LIBRARY/Peephole.xml | 31 ++ .../tests/corpus/masks/golden/frame-000.png | Bin 0 -> 6854 bytes crates/xfl/tests/corpus/masks/masks.xfl | 1 + .../tests/corpus/primitives/DOMDocument.xml | 70 ++++ .../corpus/primitives/golden/frame-000.png | Bin 0 -> 5069 bytes .../tests/corpus/primitives/primitives.xfl | 1 + .../xfl/tests/corpus/scenes/DOMDocument.xml | 88 +++++ .../tests/corpus/scenes/golden/frame-000.png | Bin 0 -> 1827 bytes .../tests/corpus/scenes/golden/frame-003.png | Bin 0 -> 1953 bytes .../tests/corpus/scenes/golden/frame-007.png | Bin 0 -> 1384 bytes .../tests/corpus/scenes/golden/frame-008.png | Bin 0 -> 1369 bytes .../tests/corpus/scenes/golden/frame-010.png | Bin 0 -> 1005 bytes crates/xfl/tests/corpus/scenes/scenes.xfl | 1 + .../xfl/tests/corpus/shapes/DOMDocument.xml | 95 +++++ .../tests/corpus/shapes/golden/frame-000.png | Bin 0 -> 7405 bytes crates/xfl/tests/corpus/shapes/shapes.xfl | 1 + .../xfl/tests/corpus/symbols/DOMDocument.xml | 92 +++++ .../corpus/symbols/LIBRARY/Movie/Spinner.xml | 18 + .../corpus/symbols/LIBRARY/Parts/Badge.xml | 40 ++ .../corpus/symbols/LIBRARY/Parts/Blink.xml | 18 + .../corpus/symbols/LIBRARY/Parts/Dot.xml | 21 ++ .../corpus/symbols/LIBRARY/Ui/Play Button.xml | 31 ++ .../tests/corpus/symbols/golden/frame-000.png | Bin 0 -> 6606 bytes .../tests/corpus/symbols/golden/frame-005.png | Bin 0 -> 6976 bytes crates/xfl/tests/corpus/symbols/symbols.xfl | 1 + crates/xfl/tests/corpus/text/DOMDocument.xml | 76 ++++ .../tests/corpus/text/golden/frame-000.png | Bin 0 -> 1730 bytes crates/xfl/tests/corpus/text/text.xfl | 1 + .../xfl/tests/corpus/tweens/DOMDocument.xml | 117 ++++++ .../xfl/tests/corpus/tweens/LIBRARY/Ball.xml | 19 + .../xfl/tests/corpus/tweens/LIBRARY/Box.xml | 19 + .../tests/corpus/tweens/golden/frame-000.png | Bin 0 -> 2150 bytes .../tests/corpus/tweens/golden/frame-006.png | Bin 0 -> 2823 bytes .../tests/corpus/tweens/golden/frame-012.png | Bin 0 -> 2376 bytes crates/xfl/tests/corpus/tweens/tweens.xfl | 1 + 56 files changed, 1535 insertions(+) create mode 100644 crates/xfl/tests/corpus.rs create mode 100644 crates/xfl/tests/corpus/bitmaps/DOMDocument.xml create mode 100644 crates/xfl/tests/corpus/bitmaps/LIBRARY/art/checker.png create mode 100644 crates/xfl/tests/corpus/bitmaps/LIBRARY/art/sunset.jpg create mode 100644 crates/xfl/tests/corpus/bitmaps/bitmaps.xfl create mode 100644 crates/xfl/tests/corpus/bitmaps/golden/frame-000.png create mode 100644 crates/xfl/tests/corpus/filters/DOMDocument.xml create mode 100644 crates/xfl/tests/corpus/filters/LIBRARY/Chip.xml create mode 100644 crates/xfl/tests/corpus/filters/filters.xfl create mode 100644 crates/xfl/tests/corpus/filters/golden/frame-000.png create mode 100644 crates/xfl/tests/corpus/gradients/DOMDocument.xml create mode 100644 crates/xfl/tests/corpus/gradients/golden/frame-000.png create mode 100644 crates/xfl/tests/corpus/gradients/gradients.xfl create mode 100644 crates/xfl/tests/corpus/guides/DOMDocument.xml create mode 100644 crates/xfl/tests/corpus/guides/LIBRARY/Ball.xml create mode 100644 crates/xfl/tests/corpus/guides/LIBRARY/Box.xml create mode 100644 crates/xfl/tests/corpus/guides/golden/frame-000.png create mode 100644 crates/xfl/tests/corpus/guides/golden/frame-006.png create mode 100644 crates/xfl/tests/corpus/guides/golden/frame-012.png create mode 100644 crates/xfl/tests/corpus/guides/guides.xfl create mode 100644 crates/xfl/tests/corpus/masks/DOMDocument.xml create mode 100644 crates/xfl/tests/corpus/masks/LIBRARY/Peephole.xml create mode 100644 crates/xfl/tests/corpus/masks/golden/frame-000.png create mode 100644 crates/xfl/tests/corpus/masks/masks.xfl create mode 100644 crates/xfl/tests/corpus/primitives/DOMDocument.xml create mode 100644 crates/xfl/tests/corpus/primitives/golden/frame-000.png create mode 100644 crates/xfl/tests/corpus/primitives/primitives.xfl create mode 100644 crates/xfl/tests/corpus/scenes/DOMDocument.xml create mode 100644 crates/xfl/tests/corpus/scenes/golden/frame-000.png create mode 100644 crates/xfl/tests/corpus/scenes/golden/frame-003.png create mode 100644 crates/xfl/tests/corpus/scenes/golden/frame-007.png create mode 100644 crates/xfl/tests/corpus/scenes/golden/frame-008.png create mode 100644 crates/xfl/tests/corpus/scenes/golden/frame-010.png create mode 100644 crates/xfl/tests/corpus/scenes/scenes.xfl create mode 100644 crates/xfl/tests/corpus/shapes/DOMDocument.xml create mode 100644 crates/xfl/tests/corpus/shapes/golden/frame-000.png create mode 100644 crates/xfl/tests/corpus/shapes/shapes.xfl create mode 100644 crates/xfl/tests/corpus/symbols/DOMDocument.xml create mode 100644 crates/xfl/tests/corpus/symbols/LIBRARY/Movie/Spinner.xml create mode 100644 crates/xfl/tests/corpus/symbols/LIBRARY/Parts/Badge.xml create mode 100644 crates/xfl/tests/corpus/symbols/LIBRARY/Parts/Blink.xml create mode 100644 crates/xfl/tests/corpus/symbols/LIBRARY/Parts/Dot.xml create mode 100644 crates/xfl/tests/corpus/symbols/LIBRARY/Ui/Play Button.xml create mode 100644 crates/xfl/tests/corpus/symbols/golden/frame-000.png create mode 100644 crates/xfl/tests/corpus/symbols/golden/frame-005.png create mode 100644 crates/xfl/tests/corpus/symbols/symbols.xfl create mode 100644 crates/xfl/tests/corpus/text/DOMDocument.xml create mode 100644 crates/xfl/tests/corpus/text/golden/frame-000.png create mode 100644 crates/xfl/tests/corpus/text/text.xfl create mode 100644 crates/xfl/tests/corpus/tweens/DOMDocument.xml create mode 100644 crates/xfl/tests/corpus/tweens/LIBRARY/Ball.xml create mode 100644 crates/xfl/tests/corpus/tweens/LIBRARY/Box.xml create mode 100644 crates/xfl/tests/corpus/tweens/golden/frame-000.png create mode 100644 crates/xfl/tests/corpus/tweens/golden/frame-006.png create mode 100644 crates/xfl/tests/corpus/tweens/golden/frame-012.png create mode 100644 crates/xfl/tests/corpus/tweens/tweens.xfl diff --git a/crates/xfl/tests/corpus.rs b/crates/xfl/tests/corpus.rs new file mode 100644 index 00000000..dfedf446 --- /dev/null +++ b/crates/xfl/tests/corpus.rs @@ -0,0 +1,350 @@ +//! The self-authored XFL corpus (`tests/corpus/`, ADR 0035): each package imports with exactly +//! the report it should, keeps its structure, and survives being cut short or garbled. The +//! golden renders of the same packages are in `crates/engine/tests/xfl_corpus.rs` (rendering +//! is a layer this crate may not use). + +use anicraft_doc::{Document, Easing, ElementKind, LayerKind, LoopMode, SymbolKind, TweenKind, evaluate}; +use anicraft_text::Fonts; +use anicraft_xfl::{Report, XflError, import_with_fonts}; +use std::collections::BTreeMap; +use std::path::{Path, PathBuf}; + +fn corpus() -> PathBuf { + Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/corpus") +} + +/// Every package in the corpus, by folder name. +fn cases() -> Vec { + let mut out: Vec = std::fs::read_dir(corpus()).unwrap().flatten().filter(|e| e.path().is_dir()).map(|e| e.file_name().to_string_lossy().into_owned()).collect(); + out.sort(); + out +} + +/// A package's files by their path inside it (`DOMDocument.xml`, `LIBRARY/x.xml`), without +/// its golden renders. +fn files(case: &str) -> BTreeMap> { + fn walk(dir: &Path, prefix: &str, out: &mut BTreeMap>) { + for e in std::fs::read_dir(dir).unwrap().flatten() { + let name = e.file_name().to_string_lossy().into_owned(); + let path = if prefix.is_empty() { name.clone() } else { format!("{prefix}/{name}") }; + if e.path().is_dir() { + if path != "golden" { + walk(&e.path(), &path, out); + } + } else { + out.insert(path, std::fs::read(e.path()).unwrap()); + } + } + } + let mut out = BTreeMap::new(); + walk(&corpus().join(case), "", &mut out); + out +} + +fn import_files(files: &BTreeMap>, fonts: &Fonts) -> Result<(Document, Report), XflError> { + let read = |p: &str| -> Result>, XflError> { Ok(files.get(p).cloned()) }; + import_with_fonts(&read, fonts) +} + +/// Imports a package without fonts, so the result is the same on every computer. +fn import(case: &str) -> (Document, Report) { + import_files(&files(case), &Fonts::from_faces(Vec::new())).unwrap_or_else(|e| panic!("{case}: {e}")) +} + +/// What each package's report says, imported without fonts. Every line is something the +/// package uses on purpose. +const REPORTS: &[(&str, &[(&str, usize)])] = &[ + ("bitmaps", &[("instances of missing bitmaps", 1), ("missing bitmap files", 1)]), + ("filters", &[("unknown filters", 1)]), + ( + "gradients", + &[ + ("elliptical radial gradients (drawn round)", 1), + ("gradient and bitmap strokes (drawn in one colour)", 1), + ("linear-RGB gradients (blended in sRGB)", 1), + ("radial gradient focal points (drawn centred)", 1), + ("repeating and reflecting gradients (drawn padded)", 2), + ], + ), + ("guides", &[]), + ("masks", &[]), + ("primitives", &[]), + ("scenes", &[("frame comments", 1), ("frame scripts (ActionScript isn't supported yet)", 2)]), + ("shapes", &[("stroke caps and joins other than round (drawn round)", 2)]), + ( + "symbols", + &[("advanced colour effects (only alpha kept)", 1), ("instances of missing symbols", 1), ("missing library files", 1), ("reverse loop modes (played forward)", 1)], + ), + ("text", &[("dynamic and input text fields (imported as static text)", 2), ("text fields (no fonts on this computer)", 4)]), + ("tweens", &[("motion tweens (kept as keyframes)", 1), ("tween spins (turned the shortest way)", 1)]), +]; + +#[test] +fn every_package_has_a_report_expectation() { + let listed: Vec<&str> = REPORTS.iter().map(|(c, _)| *c).collect(); + assert_eq!(cases(), listed, "add the new package to REPORTS here and to the golden frames in crates/engine/tests/xfl_corpus.rs"); +} + +#[test] +fn each_package_reports_exactly_what_it_uses_that_does_not_come_across() { + for (case, want) in REPORTS { + let (_, report) = import(case); + let want: BTreeMap = want.iter().map(|(k, n)| (k.to_string(), *n)).collect(); + assert_eq!(report.skipped, want, "{case}"); + assert!(report.notes.is_empty() && report.missing_fonts.is_empty(), "{case}: {report:?}"); + } +} + +#[test] +fn every_package_opens_from_its_folder() { + for case in cases() { + let (doc, _) = anicraft_xfl::import_path(&corpus().join(&case)).unwrap_or_else(|e| panic!("{case}: {e}")); + let (mem, _) = import(&case); + assert_eq!((doc.scenes.len(), doc.library.len(), doc.bitmaps.len(), doc.frame_count()), (mem.scenes.len(), mem.library.len(), mem.bitmaps.len(), mem.frame_count()), "{case}"); + // And through the .xfl file inside it, as Animate saves one. + let (doc, _) = anicraft_xfl::import_path(&corpus().join(&case).join(format!("{case}.xfl"))).unwrap_or_else(|e| panic!("{case}: {e}")); + assert_eq!(doc.scenes.len(), mem.scenes.len()); + } +} + +fn layer_names(doc: &Document, scene: usize) -> Vec<&str> { + doc.timeline(scene).layers.iter().map(|l| l.name.as_str()).collect() +} + +#[test] +fn shapes_rebuild_every_fill_and_stroke() { + let (doc, _) = import("shapes"); + assert_eq!((doc.stage.width, doc.stage.height, doc.stage.fps), (320, 180, 24.0)); + let fills = &doc.timeline(0).layers[1].keyframes[0].elements; + let shapes: Vec<&anicraft_doc::Shape> = fills.iter().filter_map(|e| if let ElementKind::Shape(s) = &e.kind { Some(s) } else { None }).collect(); + assert_eq!(shapes.len(), 5, "four fills, then one stroke"); + let loops = |s: &anicraft_doc::Shape| s.path.flatten(&anicraft_geom::Affine::IDENTITY, 0.1).iter().filter(|p| p.closed).count(); + // Red is one loop (it shares an edge with blue); blue is a loop and its hole. + assert_eq!(shapes.iter().take(4).map(|s| loops(s)).collect::>(), [1, 2, 1, 1]); + let b = shapes[0].path.bounds(); + assert!((b.min.x - 20.0).abs() < 0.01 && (b.max.x - 70.0).abs() < 0.01 && (b.max.y - 80.0).abs() < 0.01, "{b:?}"); + let tri = shapes[3].path.bounds(); + assert!((tri.min.x - 240.0).abs() < 0.01 && (tri.max.x - 300.0).abs() < 0.01 && (tri.min.y - 20.0).abs() < 0.01, "hex fixed point: {tri:?}"); + assert!(shapes[4].stroke.is_some() && shapes[4].fill.is_none()); + // The strokes layer: the zigzag split over two edges is one run. + let strokes = &doc.timeline(0).layers[0].keyframes[0].elements; + assert_eq!(strokes.len(), 4); + let ElementKind::Shape(zig) = &strokes[0].kind else { panic!() }; + assert_eq!(zig.path.flatten(&anicraft_geom::Affine::IDENTITY, 0.1).len(), 1, "an edge starting where the last ended continues it"); + let ElementKind::Shape(gap) = &strokes[3].kind else { panic!() }; + assert_eq!(gap.path.flatten(&anicraft_geom::Affine::IDENTITY, 0.1).len(), 2, "a move away leaves a gap"); +} + +#[test] +fn symbols_keep_their_kinds_loop_modes_and_colour_effects() { + let (doc, _) = import("symbols"); + let kind = |name: &str| doc.library.iter().find(|s| s.name == name).map(|s| s.kind); + assert_eq!(kind("Spinner"), Some(SymbolKind::MovieClip), "no symbolType: a movie clip"); + assert_eq!(kind("Play Button"), Some(SymbolKind::Button)); + assert_eq!(kind("Blink"), Some(SymbolKind::Graphic)); + assert_eq!(doc.library.len(), 5); + let loops = &doc.timeline(0).layers[2].keyframes[0].elements; + let modes: Vec<(LoopMode, u32)> = loops.iter().filter_map(|e| if let ElementKind::Symbol { loop_mode, first_frame, .. } = &e.kind { Some((*loop_mode, *first_frame)) } else { None }).collect(); + assert_eq!(modes, [(LoopMode::Loop, 0), (LoopMode::PlayOnce, 1), (LoopMode::SingleFrame, 2), (LoopMode::PlayOnce, 3), (LoopMode::Loop, 0)]); + let fx: Vec<_> = doc.timeline(0).layers[0].keyframes[0].elements.iter().map(|e| (e.color.alpha, e.color.tint, e.color.tint_amount)).collect(); + use anicraft_doc::Rgba; + assert_eq!(fx[0].0, 0.4); + assert_eq!((fx[1].1, fx[1].2), (Rgba::hex(0x0000ff), 0.7)); + assert_eq!((fx[2].1, fx[2].2), (Rgba::WHITE, 0.6), "brightness up is a tint towards white"); + assert_eq!((fx[3].1, fx[3].2), (Rgba::BLACK, 0.5), "brightness down is a tint towards black"); + assert_eq!((fx[4].0, fx[4].2), (0.8, 0.0), "advanced: alpha kept"); + assert_eq!(doc.timeline(0).layers[1].keyframes[0].elements[0].name, "spinner", "a movie clip keeps its instance name"); +} + +#[test] +fn tweens_keep_their_kinds_eases_and_hints() { + let (doc, _) = import("tweens"); + let t = |l: usize| doc.timeline(0).layers[l].keyframes[0].tween.expect("a tween"); + assert_eq!((t(0).kind, t(0).easing), (TweenKind::Classic, Easing::Classic(-100.0))); + assert_eq!(t(1).easing, Easing::CubicBezier(0.7, 0.0, 0.3, 1.0), "a one-segment custom ease is a cubic Bézier"); + assert_eq!((t(3).kind, t(3).easing), (TweenKind::Shape, Easing::Classic(50.0))); + let hints = &doc.timeline(0).layers[3].keyframes[0].hints; + assert_eq!(hints.len(), 1); + assert!(hints[0].start.distance(anicraft_geom::Vec2::new(20.0, 120.0)) < 0.01 && hints[0].end.distance(anicraft_geom::Vec2::new(270.0, 115.0)) < 0.01, "{hints:?}"); + assert!(doc.timeline(0).layers[4].keyframes[0].tween.is_none(), "a motion tween stays a keyframe"); + assert_eq!(doc.frame_count(), 13); +} + +#[test] +fn masks_and_folders_link_up() { + let (doc, _) = import("masks"); + let l = &doc.timeline(0).layers; + assert_eq!(layer_names(&doc, 0), ["Spot", "Stripes", "Inside", "Window", "Sky", "Loose", "Ground"]); + let kinds: Vec = l.iter().map(|l| l.kind).collect(); + assert_eq!(kinds, [LayerKind::Mask, LayerKind::Normal, LayerKind::Folder, LayerKind::Mask, LayerKind::Normal, LayerKind::Normal, LayerKind::Normal]); + let parents: Vec> = l.iter().map(|x| x.parent.and_then(|p| l.iter().position(|y| y.id == p))).collect(); + assert_eq!(parents, [None, Some(0), None, Some(2), Some(3), Some(2), None]); + let sym = &doc.library[0]; + assert_eq!(sym.timeline.layers[0].kind, LayerKind::Mask); + assert_eq!(sym.timeline.layers[1].parent, Some(sym.timeline.layers[0].id), "a mask inside a symbol"); + // Three masks drawn: the scene's two and the symbol's, once per instance. + assert_eq!(evaluate(&doc, 0).clip_parents.len(), 4); +} + +#[test] +fn guides_guide_and_never_draw() { + let (doc, _) = import("guides"); + let l = &doc.timeline(0).layers; + assert_eq!((l[0].kind, l[1].kind), (LayerKind::Guide, LayerKind::Guide)); + assert_eq!((l[2].parent, l[3].parent), (Some(l[1].id), Some(l[1].id)), "both riders follow the arc"); + assert!(l[2].keyframes[0].tween.is_some_and(|t| t.orient)); + // Half-way the riders are on the arc, well above the straight line between their ends. + let mid = evaluate(&doc, 6); + let drawn: Vec<_> = mid.items.iter().filter(|i| !i.guide).collect(); + assert!(drawn.iter().any(|i| i.transform.translation().y < 100.0), "{:?}", drawn.iter().map(|i| i.transform.translation()).collect::>()); +} + +#[test] +fn scenes_labels_and_scripts() { + let (doc, _) = import("scenes"); + assert_eq!(doc.scenes.iter().map(|s| s.name.as_str()).collect::>(), ["Opening", "Credits", "Scene 3"]); + let labels: Vec<&str> = doc.timeline(0).layers[1].keyframes.iter().map(|k| k.label.as_str()).collect(); + assert_eq!(labels, ["intro", "", "sunrise"], "a comment isn't a label; an anchor is"); + assert_eq!(doc.timeline(1).layers[0].keyframes[0].label, "credits"); + assert_eq!(doc.frame_count(), 6 + 4 + 1); + assert_eq!(doc.stage.fps, 12.0); +} + +#[test] +fn bitmaps_come_from_png_and_jpeg_files() { + let (doc, _) = import("bitmaps"); + let b: Vec<(&str, u32, u32)> = doc.bitmaps.iter().map(|b| (b.name.as_str(), b.width, b.height)).collect(); + assert_eq!(b, [("checker.png", 16, 16), ("sunset.jpg", 32, 16)]); + assert_eq!(evaluate(&doc, 0).items.iter().filter(|i| i.image.is_some()).count(), 5); +} + +#[test] +fn filters_and_blend_modes_come_across() { + let (doc, _) = import("filters"); + let filters: Vec = doc.timeline(0).layers[0].keyframes[0].elements.iter().map(|e| if let ElementKind::Symbol { filters, .. } = &e.kind { filters.len() } else { 99 }).collect(); + assert_eq!(filters, [1, 1, 1, 1, 1, 1, 1, 2, 0, 0, 1], "switched-off and unknown filters are left out"); + let blends: Vec<&str> = doc.timeline(0).layers[1].keyframes[0].elements.iter().filter_map(|e| if let ElementKind::Symbol { blend, .. } = &e.kind { Some(blend.key()) } else { None }).collect(); + assert_eq!(blends, ["multiply", "screen", "difference", "add", "subtract", "overlay", "hardlight", "invert"]); +} + +#[test] +fn text_fields_become_blocks_with_this_computers_fonts() { + let fonts = Fonts::get(); + if fonts.resolve("").is_none() { + return; // A computer without fonts: the report test covers it. + } + let (doc, report) = import_files(&files("text"), fonts).unwrap(); + let blocks: Vec<(String, String, f32, bool)> = doc.timeline(0).layers[0].keyframes[0] + .elements + .iter() + .filter_map(|e| if let ElementKind::Text(t) = &e.kind { Some((e.name.clone(), t.text.clone(), t.size, t.bold)) } else { None }) + .collect(); + let want = [("", "Corpus", 28.0, true), ("", "self-authored, line two", 12.0, false), ("", "A fixed-width field wraps its words onto lines.", 11.0, false), ("score", "Score 0042", 18.0, false), ("answer", "type here", 14.0, false)]; + assert_eq!(blocks.iter().map(|(n, t, s, b)| (n.as_str(), t.as_str(), *s, *b)).collect::>(), want); + assert_eq!(report.skipped.get("dynamic and input text fields (imported as static text)"), Some(&2)); + assert!(!report.skipped.contains_key("text fields (no fonts on this computer)")); +} + +/// A small deterministic generator (xorshift), so a failing variant can be found again. +struct Rng(u64); +impl Rng { + fn next(&mut self) -> u64 { + self.0 ^= self.0 << 13; + self.0 ^= self.0 >> 7; + self.0 ^= self.0 << 17; + self.0 + } + fn below(&mut self, n: usize) -> usize { + (self.next() % n.max(1) as u64) as usize + } +} + +/// Bytes and strings that poke at the readers: markup, edge commands, numbers out of range. +const POISON: &[&str] = &["<", ">", "\"", "/>", " Vec { + let mut out = bytes.to_vec(); + for _ in 0..1 + rng.below(4) { + let at = rng.below(out.len() + 1); + match rng.below(5) { + // Overwrite a byte. + 0 if at < out.len() => out[at] = rng.next() as u8, + // Insert poison. + 1 | 0 => { + let p = POISON[rng.below(POISON.len())].as_bytes(); + out.splice(at..at, p.iter().copied()); + } + // Delete a span. + 2 => { + let end = (at + 1 + rng.below(64)).min(out.len()); + out.drain(at.min(end)..end); + } + // Repeat a span (deeper nesting, repeated layers and edges). + 3 => { + let end = (at + 1 + rng.below(400)).min(out.len()); + let span: Vec = out[at.min(end)..end].to_vec(); + for _ in 0..1 + rng.below(3) { + out.splice(end..end, span.iter().copied()); + } + } + // Swap a digit for another, moving geometry and indices. + _ => { + if let Some(i) = (at..out.len()).find(|&i| out[i].is_ascii_digit()) { + out[i] = b'0' + rng.below(10) as u8; + } + } + } + } + out +} + +/// Imports a hostile variant: it may fail, but it must not panic, and what it imports must +/// evaluate. +fn survive(files: &BTreeMap>, fonts: &Fonts, what: &str) { + let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| { + if let Ok((doc, _)) = import_files(files, fonts) { + let n = doc.frame_count(); + for f in [0, 1, n / 2, n.saturating_sub(1)] { + let _ = evaluate(&doc, f); + } + } + })); + assert!(result.is_ok(), "panicked on {what}"); +} + +#[test] +fn hostile_variants_of_every_package_never_panic() { + let fonts = Fonts::from_faces(Vec::new()); + let start = std::time::Instant::now(); + let mut variants = 0; + for case in cases() { + let original = files(&case); + for (path, bytes) in original.iter().filter(|(p, _)| p.ends_with(".xml") || p.ends_with(".png") || p.ends_with(".jpg")) { + let mut rng = Rng(0x9E37_79B9_7F4A_7C15 ^ (path.len() as u64 * 0x1000_0001) ^ (case.len() as u64) << 32); + // Cut short at evenly spaced points (and just after the start and before the end). + let cuts = (0..24).map(|k| bytes.len() * k / 24).chain([1, bytes.len().saturating_sub(1)]); + for cut in cuts { + let mut f = original.clone(); + f.insert(path.clone(), bytes[..cut.min(bytes.len())].to_vec()); + survive(&f, &fonts, &format!("{case}/{path} cut at {cut}")); + variants += 1; + } + for n in 0..96 { + let mut f = original.clone(); + f.insert(path.clone(), garble(bytes, &mut rng)); + survive(&f, &fonts, &format!("{case}/{path} garbled #{n}")); + variants += 1; + } + } + // A package missing each of its files in turn. + for path in original.keys() { + let mut f = original.clone(); + f.remove(path); + survive(&f, &fonts, &format!("{case} without {path}")); + variants += 1; + } + } + assert!(variants > 1000, "{variants}"); + eprintln!("{variants} hostile variants in {:?}", start.elapsed()); +} diff --git a/crates/xfl/tests/corpus/bitmaps/DOMDocument.xml b/crates/xfl/tests/corpus/bitmaps/DOMDocument.xml new file mode 100644 index 00000000..df820b2a --- /dev/null +++ b/crates/xfl/tests/corpus/bitmaps/DOMDocument.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/bitmaps/LIBRARY/art/checker.png b/crates/xfl/tests/corpus/bitmaps/LIBRARY/art/checker.png new file mode 100644 index 0000000000000000000000000000000000000000..6239c17b39d911b6e9d82ddb57c52558fc4c49bb GIT binary patch literal 104 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%``kpS1Ar-fh6C9YMihuuCemvcM zQ-HxPo5KbM4I#WQJ{>;D5M-Lb^2op-!9?~CJA=)U7WTw2?+{{ zii%1~%KtyYkj=oz$jE>U*jSl?La2glEUe4|42;YyOw34%6GcUYgcUEcEMzre6BJ}% zWMW}Q)+Q{JC@RPza#4|WAye}qw*Lnh1UVQ47!;Tpg&3HG7?_0^{@-HY0UF38$SlZU z&#>>&LUmEYr4uB*6*NLR1GBqY=7dP=G@OcLy6Q1iY{v@EqmG+S@GPC68`2qUzw60~ z#`(8W%F|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BW%q#Fi zm8=%N3jzQZG#TFjyyaD3`{PG05}vwoyYu0x@v8kK^Hlh5#9mt6@w0v?V#ejJtJRh) zGcTReUez%>2mVP-V)LtnVZ_wp_~{;e9$x^LPjb>l6xVP$BBT3i{F69l$AKcY;2cH^ zhc*`pZ3Ej>1;!WJ+H7C2P+u1-Aw*`a_CyA|v!Z!hFhlNmAsa7SgyXb77Rw|3)iN~W z{^B|Ri7eB%BnUNqo9skN-HdAeplJ#7+9`Es`h4zrHO`m6Z9%js7~WuovDGe4b3k9XVQs6L%c#k9%siIXgP(~!4PI^pOh+h< zO&&PTw#k;e8t%))NiZK^fJ(4>*qcA)bfA^<8Gib^P!){TI>nCFUGB=@+5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/filters/LIBRARY/Chip.xml b/crates/xfl/tests/corpus/filters/LIBRARY/Chip.xml new file mode 100644 index 00000000..76a38fc2 --- /dev/null +++ b/crates/xfl/tests/corpus/filters/LIBRARY/Chip.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/filters/filters.xfl b/crates/xfl/tests/corpus/filters/filters.xfl new file mode 100644 index 00000000..860a820e --- /dev/null +++ b/crates/xfl/tests/corpus/filters/filters.xfl @@ -0,0 +1 @@ +PROXY-CS5 \ No newline at end of file diff --git a/crates/xfl/tests/corpus/filters/golden/frame-000.png b/crates/xfl/tests/corpus/filters/golden/frame-000.png new file mode 100644 index 0000000000000000000000000000000000000000..f80f0512000f47a5036231cb18a6491c0c8e0b55 GIT binary patch literal 9610 zcmeHtYgAL`wzd}#6(Loss7PW3q!u+;D4+yV>m^kbO5JKJl4z+HP}Cp+LI@;Wa|LoCS@~A5`<%1CvCsIvAN$7{XY4V^Vyujr z^*-~N&zx({cdgX#{Bc%`S1+D3XO7jLZ+CtV|Gx`=jx1aNAF)lr@E1;jdv+;vdqz!`=mC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vU{w_{$#~bW?r)_~z3r5vG@+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/gradients/golden/frame-000.png b/crates/xfl/tests/corpus/gradients/golden/frame-000.png new file mode 100644 index 0000000000000000000000000000000000000000..a495087af4bf1b085ce92aa9ea553342af80e11e GIT binary patch literal 11441 zcmdT~4K$SL`yNFsAtfqmwhtsR#12wTinKn{2ce88iII>f%oHoj7v+oN3O@E!ykev(FW}Uq}x(@My6rs5@jkJ-+jQzTjUT%bBRBYH3rCXx31* ze4U~bT^J!EuF$1SQM-mJ>`PVD7DZ~#EO?P+(&^w9DB=X2iKD3v<=<#p$vx%ML`U zR$q0-I6rYR)k<4IbW=^2JrJ2E^6@sfnXo@fJz+ms4^}6A=(Xx5cUFIRgnnLJn?(1I zAR83cRJT0h>g5&QgwYZY6%;>-IA3FSz3WwPjy|RKXyEl_q-dPd@y-&lHDi%O07WHL zgb#+1pzo@2*a^Bw0mxKy0rG`23!3XL+SP}tb2+|glV;84X_1OO65>^D1Unc(%W zH8f%_yK3ts-6{<&H92aWA8K!{o*}zY#CTsyk8vL7!A*dx96~05U}3&e06`tVHPtGB z-~wb&96krkJdb7@af`QcD}?CW@rIXuNm#`9?!t#s_U_$v8M79kcx`a#?{ zjw#AaxZ+Uq^DmyPbpbTBQf*)AVr_W{jbefeBjJJ5C6K@beF&L$Ih4msk~0g;bqAWp z8$(@ zAv;3u2;T@wF?zKE;!wqI;ajM64?Y2*}e{`+elg9xw+9<2(NEX zZ3=>NNW8^f{9*Oz_P3kc)_zs}YfSR6fWP63P@nr3^6^kTW6<%IOLR z&5yUiP1R~zhyd)&>e6=}@CIC3v23BY2IN(kt8 zeEMRXW)>9L#Q?^FymlCYyq?6XFd1Q%z`(r+X07x7I`cKT69C**>@pGE@gqbTy8>YwPM{#AVYx2 z4g2VZ^wc{k9fsK%atFn)hOFDz#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)5(9v`$PV(Z?u+mX#vA)7|NFDY{b~_}qu6`79+gLuL4&SZY zHDPhyI%^@{Opy~FI!lSaTMqOeaw%D%@{i%cwO%7hszml+4t6Vfgl%=qUS+(vw>O4a zPaj!&WGX@ZX41C~R0Ze}A)j>cS8jUUXY{(=4&POb&$|7C3-J*KW+Yp*Ke1&c{&e{s zvJ;8!luCbzs+h~pdOtM|_t7^*yhh(h_vND|*BZ$n%)fCoaMWhY0bZWan|oaU&S8Su zW#pFp2*#qF*0fZ<#_lIvCsOx6M6!r9iJ?Z8m3UW)Y zk?VpbGS4#3rn%Szg4E%DpTog}disrnhpYarlgIetto71yNk?j(sI-Lrp1kK)T;vj7 z(_GBWM*4^xuKo(PM^XChr>8T=5hzNY`zoWMxw$p^MDX2mRRaOHEL1N_wxj=Q6D zU^VZzFPsYe3knAg!LchHyVY}g!)9FoFJvx(t)TNb!9i^XT&3};Dsq6|onWdQFA+*E zdeVp7Fx@p3j=mfpQ0sAi?Z0bHVn)VM{_xD{i1^@|frw39wd2~j59|H4J2grsh-iuK zFzAsp-@eRg<2;#v*P6ip{jWRX*MgHi-uXXWxH6kwT+k@rTc-{F6dCrTv8B + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/guides/LIBRARY/Ball.xml b/crates/xfl/tests/corpus/guides/LIBRARY/Ball.xml new file mode 100644 index 00000000..1db5c596 --- /dev/null +++ b/crates/xfl/tests/corpus/guides/LIBRARY/Ball.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/guides/LIBRARY/Box.xml b/crates/xfl/tests/corpus/guides/LIBRARY/Box.xml new file mode 100644 index 00000000..58481187 --- /dev/null +++ b/crates/xfl/tests/corpus/guides/LIBRARY/Box.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/guides/golden/frame-000.png b/crates/xfl/tests/corpus/guides/golden/frame-000.png new file mode 100644 index 0000000000000000000000000000000000000000..c373f964f673dc7a6cdc4081ae0bfdc8d7f63245 GIT binary patch literal 1065 zcmeAS@N?(olHy`uVBq!ia0vp^3xGI^gAGX9ABzPFFn{oLaSW+oe0zX-flB1GV;}#Q zzw145W_gi!^19sH+n^}3XWlfg_4AC3mEQd<+n!amtlc{Ms{gjLq2YhOJB(68F9`M@ zx>$5n{_ofOACK4nEoa#C$$LM``cIei4<1W82aHs0#oN!~KP27%d3BG$<^Df*{9lg5 z|14a$>y>Lm&g}Yw-L=odKOge3|Mc7Df^hxQ<2zri5@+0$`;S%s+uZoG+{S-Ty#MUr z|7WWF^Hr8L{pZd02Wre7uUh?&6(n8vxc^^If6X8H59>c} z?XNVAdmkFtxO&|$afRE@T7NX<|MIIV*mivXF>Tw*{`Y?toqqz;xbMO2eUs(qy#2WT zW0(KE$Gi8vFa|oN9_X03j{83r+do#8|Ihv>yXI|jT<`Vjso@V`8etCFe=L5_?RJCt zXLmrfLH)4*nEjsj?!{L_^_fy`|KW~%W4(V?eQ$lm{r+blFTJ?;xjyM1>-x`^>rd=I zmcRGw>LQTRlJ`ID4gYhUzIq`3&*9uZNAKG+H%zbo$o{cNzl^)P@;oSH7gnGD-wAZ% ze>t!rz%bp7{ literal 0 HcmV?d00001 diff --git a/crates/xfl/tests/corpus/guides/golden/frame-006.png b/crates/xfl/tests/corpus/guides/golden/frame-006.png new file mode 100644 index 0000000000000000000000000000000000000000..0da043eaf99268b38178286f7f11264a0c5b6dbc GIT binary patch literal 1678 zcmdT_jaO4;7)LEM4R^{EMcg%}$4ql4QI|4y#ULbuRZ6JnZffb_V=k8N!_8ekh^dH+ zI)a8Wjvb?zhY2P_8@pP{HU*~10zw#wgPgLDi(|Xn-M!rre?zCvdEfUr=Y5~^{GQ+M z`JM9~|1cvpYHG~Xh=_=&wDrj!Q?ZKLTc<=)C)m85x`@n7OHSG(nJ|1~Qq_VjWz8N^ z>?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Q+^iPkY1g*stri#PI$(YJcZg{GY$Z3>7=Y>jm_`CvD#_gTe~DWM4fD_4G_ literal 0 HcmV?d00001 diff --git a/crates/xfl/tests/corpus/guides/guides.xfl b/crates/xfl/tests/corpus/guides/guides.xfl new file mode 100644 index 00000000..860a820e --- /dev/null +++ b/crates/xfl/tests/corpus/guides/guides.xfl @@ -0,0 +1 @@ +PROXY-CS5 \ No newline at end of file diff --git a/crates/xfl/tests/corpus/masks/DOMDocument.xml b/crates/xfl/tests/corpus/masks/DOMDocument.xml new file mode 100644 index 00000000..37d10018 --- /dev/null +++ b/crates/xfl/tests/corpus/masks/DOMDocument.xml @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/masks/LIBRARY/Peephole.xml b/crates/xfl/tests/corpus/masks/LIBRARY/Peephole.xml new file mode 100644 index 00000000..d1b5c317 --- /dev/null +++ b/crates/xfl/tests/corpus/masks/LIBRARY/Peephole.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/masks/golden/frame-000.png b/crates/xfl/tests/corpus/masks/golden/frame-000.png new file mode 100644 index 0000000000000000000000000000000000000000..1fa458de9c1014136480f8866b8bb21e3e349109 GIT binary patch literal 6854 zcmc&(2~<;Ow?)JXXd6Kk1to$EQcF<~oTyP6MJ7@Fl{N~oI3QCIr2>jv#Q`WHNEl=g zoPbgb6gA+0L}e~T6p%rb01=QXWME1lx%Zv#GTGPn{_hM$%U|T&-wP*d!KWz z;oG-aeXgvbEGH-Tx%F1MBV4b+i=p@#ywl2@;RB6GYx<^t1x)LGGX0wF_wi*y!oM%F z;?K;Zw)=CuTk^;MxnE3;x5-U4G1cjl953)VkrBGy^OZw>^)4sb@W%i31-p^?HrN0Y zBw)p9vbVek{5Lb6_x2sd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hCfj84zI_; z^)Dg%eXbxDYimou&b1q2HL^od!3(zqwPkKnAnajkN%N9qayA1rMBE>hp5GOAd=L<& zfBOO;vSyEubQ{!eW#4LxPU;$QC-sMbKe*G6NFUQuCAOR|$L{nSkaHH3NW3>|SjfCS zMN$Eln0Z;4ZvfkR-oH7>BQnS@QsgjndBSJ^R-In&5oLbwh#VikS< z*jl+y5uQx!pLD=XQN!URup+o4Gk&8IPH%F7fOiMW_;g?mFZjPLir5D|+ru0GEz_p> zEmvRDbfVaQU;iLCp7^XHU*gl&sa-{r866F*;8=ZS{yo&~TB*L%(|=RBx5w58{%+-8 zRlI}7BcVLv$Hdg6_+QvC?0pvCu^-u=3K zLOwTx%ep=knQ7+Y`Xvot5XH#e30cZ)hf@}BjVM;Ki-aCx|1RPipfYW$suZ;d`}w)z zb%*mRcM)z-aqJ54=j$MuTkY3xW^VjM{J#=A(N`zTVcG-+PO`MKU~B)Kp`XPR+H~*c V_lQqN!T(RmS#RD(&#~MW@*nn_I->vp literal 0 HcmV?d00001 diff --git a/crates/xfl/tests/corpus/masks/masks.xfl b/crates/xfl/tests/corpus/masks/masks.xfl new file mode 100644 index 00000000..860a820e --- /dev/null +++ b/crates/xfl/tests/corpus/masks/masks.xfl @@ -0,0 +1 @@ +PROXY-CS5 \ No newline at end of file diff --git a/crates/xfl/tests/corpus/primitives/DOMDocument.xml b/crates/xfl/tests/corpus/primitives/DOMDocument.xml new file mode 100644 index 00000000..a0adf1ec --- /dev/null +++ b/crates/xfl/tests/corpus/primitives/DOMDocument.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/primitives/golden/frame-000.png b/crates/xfl/tests/corpus/primitives/golden/frame-000.png new file mode 100644 index 0000000000000000000000000000000000000000..ed6fb08f41659b99722b86995bd606bd9703b5e3 GIT binary patch literal 5069 zcmc&&dsI_bzK$}ANHJ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gRwkBV`V$a{;MG&u}Gt6(u5!xgUF^&`=i&9`ahmxsfH|E)7=<@X~)VBWE&_t#n7~bWBAyuhb}vln>#CD6YT9QC$5{ z6(F@Q!FqGZ>V!Yr)s}Cl=J%L}-OxE8uFPe}Ya-x@>euBd3g6(I!SyKXuFV@Mt$@&( zX-$4)_qv18+1=2X#vt|XB9c855l&}t+UxGA;2)AIuFC`|v>*EB0caDU_CR+8f2=z8 zu(GUC*rkcG-ejHxXC?u?xDj+fQG%u|+?SGj3sQ2nnl!M+#npqLdT@@~W7W^SxE~2){e<^FuWF9nXu4r(aqgRjoLQIGQL6!vnzE zEbPY|)z!t6{9f)R$$~hWhCeT#X)e9>)?ubqHMA!Vl)qo_HEZ=v3riQYsFg>ltH^zW zt*vY|Vzc%IP|rD+)A;>_&EnKfI?jW7%4OvgkHG-NTha~?E9JL_?T$*r;btf3LVjBA zOr&==i(w-5jz{&kliK(GkhZL>-Jg2CAgwC^o90Cn3-^Xh`ap`ZKP9NY%bu-IdEky@ zex9Mlyc#(7Bw_AzV5P^v(U!3dvtUaGtQ176t<>8OEr(gw@i8$UJnCJiSrECy@t`U< z;kovJT?UuJH&v2^-Fh*{=WV>;jjo1`*hNnsw7R{F!c;mCA>F3`s`j + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/scenes/golden/frame-000.png b/crates/xfl/tests/corpus/scenes/golden/frame-000.png new file mode 100644 index 0000000000000000000000000000000000000000..a63234b9248e5082d7bec04af8870485c3e52192 GIT binary patch literal 1827 zcmeAS@N?(olHy`uVBq!ia0vp^3xGI^gAGX9ABzPFu)XqhaSW+oe0zX-flB1GV;}#Q zzw145W_gi!^19sH+n^}3XWlfg_4AC3mEQd<+n!amtlc{Ms{eBNPg2iTt^QZN;4*(D zZ}HX8|F#!iw(n`%`D)dFxffrY;||A^UajXZ`K7o%aow(0``NAjP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}^?`L(j^s^nlkf7~7S z`h4Z(_PgimTjFb8ovk_bevb{ZvtOCtJ#D_{q5LQLhllIFhW`9(z3wTJyKn`|hyKr& W(s@480sDZJAA_f>pUXO@geCwr{rv?1 literal 0 HcmV?d00001 diff --git a/crates/xfl/tests/corpus/scenes/golden/frame-003.png b/crates/xfl/tests/corpus/scenes/golden/frame-003.png new file mode 100644 index 0000000000000000000000000000000000000000..955efea5ca9a0730535c71df62dd11b9d3303254 GIT binary patch literal 1953 zcmeHI`%{ux7^bW!ch%Lc!POEoH*MR7H4|?j=xRo$maRE93Z<5r7~`e5>bJUiY1GBk zYLx`5O)@s=&@Je?haq?0n~ZXXZQa_ndd$=XuX_ zZhu&?g}I$M1Olr0+omi}c^;#@>Tj$* zFet^OaR%r^&D8FmY}n*9jOHhS38uuHy1q!glaWeVc7SZ1fR2DGD-+kvJK;LS+S%`f zGoFI)`yvsxMv_~x90g7F$xU$jB2Xw;ta4}ckYb)jBEB(hqX`0iccxG^&h{?=%67F( zS)mFDz;k32nqU-;5)~kW!j;YrX=!gJBw!l&kI4?WN*)_#0$_^ioqiaZ!@wKNqvp(s z-_*q}r1W9ANkvoh#UubqS}JYU2CIA8(Ea&3b!dzdWzr{A`vi))aH;8N4{)}vF}dA7 zQ{M651J$HsIpq--#g-I`fV1Pr-VPEJwtSjN&q@?qwv9QZzB&&-N{*%|VCXy^+oWqW zlc0IS{S@K(qlPK-B=4YHBW2k}p-uXyIZUV*$g=y0#;3qpj&@AKc+Z^Zj2tkv0{gKP z9mj!Fn29p@+i~HXzgAS%(D-jkYun+B7iAQX6oAPkyrk`dr4w$Q-klabqz`#ua04ex<+($OyRnaH6I`eRIOQ@DS+YZgp=d}*|9e24)Bb2L(w#d^#@#IgFn*timk8PSntVpDp{Gke^mtJh)aKG z(oAQ?2<~`k%GKg6Ltf8B=X*s!o)~!N$5GXgQZcgO=-!hUsH(j_C#X5%gBfb+3!3S$g+F2^{&U=(1hd!q^`^e&e#(NV#h7njuZR! z!4g_mn%)M)C(7ZW)-U+nj7{~@ZL#6C7hEsctajD~-%h%9-g~g-9MW>11Zy8$llrhi zYi}S}4zbSdT5v<2`Q7?@+J*#{*JyJmh*ePx+;Ytw9k>x2KJ9Z-e6Wcf@q->#ha41T zCv7|->E30zucMM!46HEp9JY3oz3<~_;+*5^C^W)1dUh_gt|5fAn~gZfXASmEX58~0 zCx%V?=rAXTx*y=(_)%ajCAZhGpja_x(V~Sqv+7>)4v?x_OiQnpjPsYbHodxh3dv>l z)!y?i1>5h{al1pGf1!0fz+ZvUt5hBauV@{Swg`-#(uJSO>@%1JV!>xF*8Bq A1ONa4 literal 0 HcmV?d00001 diff --git a/crates/xfl/tests/corpus/scenes/golden/frame-007.png b/crates/xfl/tests/corpus/scenes/golden/frame-007.png new file mode 100644 index 0000000000000000000000000000000000000000..fad2e5b9569a0eb4372253a84112ff473a2ea90d GIT binary patch literal 1384 zcmeAS@N?(olHy`uVBq!ia0vp^3xGI^gAGX9ABzPFu0;Haff3{uh#RI{8C(>xNg_0{p?nMCtNoOkNtX|d2Zc_ z>=~=q{d(W%XaB_XOlbJu?+(M;xc_YRpMTq*3H@KZ=gR8+#{YT2LG?5LgZcjdhhx6l zANSt-%lh+u25`uXDjp4uHoB*c5tSdw^XxxCo9A~#*SvHw29}@zopr00amw ALI3~& literal 0 HcmV?d00001 diff --git a/crates/xfl/tests/corpus/scenes/golden/frame-008.png b/crates/xfl/tests/corpus/scenes/golden/frame-008.png new file mode 100644 index 0000000000000000000000000000000000000000..4e54f9c68af888265c1f7945bc9002045e27384c GIT binary patch literal 1369 zcmeAS@N?(olHy`uVBq!ia0vp^3xGI^gAGX9ABzPFuqt@EIEGX(zCFOaKqYe8v5)`D z-}Rn2v%JVVd0p=9ZBUfiGjE#L`gumiO7DJ_ZO^J&)^44B)qlDCC#h$vR{yJBaGAf7 zxA0;Haff3{uh#RI{8C(>xNg_0{p?nMCtNoOkNtX|d2Zc_ z>=~=q{d(W%XaB_XOlbJu?+(M;xc_Y5Yu?>2zWQJ0dhN6B&-WR?K`<&h8V&=O9!69K eB+s+|1hbFd5uMEaaT2h|WbkzLb6Mw<&;$T?v@KWw literal 0 HcmV?d00001 diff --git a/crates/xfl/tests/corpus/scenes/golden/frame-010.png b/crates/xfl/tests/corpus/scenes/golden/frame-010.png new file mode 100644 index 0000000000000000000000000000000000000000..c364fe89e4f7aae90c504d9ce555aee5198c444c GIT binary patch literal 1005 zcmeAS@N?(olHy`uVBq!ia0vp^3xGI^gAGX9ABzPFFmLg6aSW+oe0zX-flB1GV;}#Q zzw145W_gi!^19sH+n^}3XWlfg_4AC3mEQd<+n!amtlc{Ms{eBNPg2iTt^QZN;4*(D zZ}HX8|F#!iw(n`%`D)dFxffrY;||A^UajXZ`K7o%aow(0``NAjPPlFm9{cq^^W3@< z*)vwJ`}Mxj&;E(&nb7dR-yKGc8x6bBghE8F_~FiE(IhIUQ+yMcjTt;${an^LB{Ts5 DY9}tU literal 0 HcmV?d00001 diff --git a/crates/xfl/tests/corpus/scenes/scenes.xfl b/crates/xfl/tests/corpus/scenes/scenes.xfl new file mode 100644 index 00000000..860a820e --- /dev/null +++ b/crates/xfl/tests/corpus/scenes/scenes.xfl @@ -0,0 +1 @@ +PROXY-CS5 \ No newline at end of file diff --git a/crates/xfl/tests/corpus/shapes/DOMDocument.xml b/crates/xfl/tests/corpus/shapes/DOMDocument.xml new file mode 100644 index 00000000..f427a66b --- /dev/null +++ b/crates/xfl/tests/corpus/shapes/DOMDocument.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/shapes/golden/frame-000.png b/crates/xfl/tests/corpus/shapes/golden/frame-000.png new file mode 100644 index 0000000000000000000000000000000000000000..ff1c170fdf5e86f55ee43128b50f3af1a691f7ae GIT binary patch literal 7405 zcmb_h3se*5ww6-M@tIbtw4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+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/symbols/LIBRARY/Movie/Spinner.xml b/crates/xfl/tests/corpus/symbols/LIBRARY/Movie/Spinner.xml new file mode 100644 index 00000000..32246fda --- /dev/null +++ b/crates/xfl/tests/corpus/symbols/LIBRARY/Movie/Spinner.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/symbols/LIBRARY/Parts/Badge.xml b/crates/xfl/tests/corpus/symbols/LIBRARY/Parts/Badge.xml new file mode 100644 index 00000000..ba0067af --- /dev/null +++ b/crates/xfl/tests/corpus/symbols/LIBRARY/Parts/Badge.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/symbols/LIBRARY/Parts/Blink.xml b/crates/xfl/tests/corpus/symbols/LIBRARY/Parts/Blink.xml new file mode 100644 index 00000000..b21664cf --- /dev/null +++ b/crates/xfl/tests/corpus/symbols/LIBRARY/Parts/Blink.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/symbols/LIBRARY/Parts/Dot.xml b/crates/xfl/tests/corpus/symbols/LIBRARY/Parts/Dot.xml new file mode 100644 index 00000000..a7d5c28a --- /dev/null +++ b/crates/xfl/tests/corpus/symbols/LIBRARY/Parts/Dot.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/symbols/LIBRARY/Ui/Play Button.xml b/crates/xfl/tests/corpus/symbols/LIBRARY/Ui/Play Button.xml new file mode 100644 index 00000000..a4bf96ab --- /dev/null +++ b/crates/xfl/tests/corpus/symbols/LIBRARY/Ui/Play Button.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/symbols/golden/frame-000.png b/crates/xfl/tests/corpus/symbols/golden/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oRm z+B_erNlL;Mgbc{fVh$xf6LiJPbb-x?-@7TIG72iMn=%!fFx)WR#a{+#+vwyWNbQXv z*h9yzJCwdJT7E96hCbD7O@%L5ofcoE>%dy&EAHI*baM`E(3P9BeZq!h@VNA$<4DT^ ze=F7^!>56MIa$^!YzZoJvyycQ+Wu@uh|T^=%O00o{Tq37zsn1H<_&1w{OIJC;I^it zyNW@3i5iKDJ-K~>YS=coxJ@4lna&%n$&+;_$nkl}x>YiU g(pCR>8Di?0P-P{Q{S!#tr=hJ~z2TkWx3?Yn4-pNE7XSbN literal 0 HcmV?d00001 diff --git a/crates/xfl/tests/corpus/symbols/golden/frame-005.png b/crates/xfl/tests/corpus/symbols/golden/frame-005.png new file mode 100644 index 0000000000000000000000000000000000000000..3284d917225c041e8b0982f9d3fb262402b20b1e GIT binary patch literal 6976 zcmcgxc~leU+K*yO)r(ZE(yEXuTI%IuY+a%fGTjs{)pWU*)+N(wTdzfoOKlPoGA>nA zuEc6JDni;?%kff))+H=ShCM2Vs8oY28Au=jAxsvMOp;l?3EF=5exLV`?|jF5PL@f| zbKd#A&+>bI&pQX+U6C3!YSJhMgAuiC>09s9-`~^kRnI(4e**Pu=|3h%E_>_szlw%A zDkHw1{_*j87bP4xbnRx*wzTynnXOkJy*B>6@c7%R!dK@^8wh-@{xa+5oaBtVJjK4z zwtp0plJC=Mp4xtQC6#jPZ0GK>2mherdhTqgTH~c|oYh9iP#!gLedF5F+Gwg@72#|Y z1cIlz;y+F0TPJ`=)+evV6W$zJi1G}S`=`Lc3aDO58OCErVc8Vc!St+Nz1z+5{>|*1 z2kx3&l45{{f3>mnlae6NcZZyc-~?chQ`G_wuEEa4-9P}>M#djk96&&Qp)y3mq1D?r zNsdylJ;VjAXpz=#kj{gGCb@N&d2k1~*Cals=sX7c>P{H53YB-WI^>j_iJb?6i82?P z+8>!!r;z;x^oyCxm*SDHJ;eJ#-tj~(K1X*DmQ*(}n%h2d>QL-wP19;!+$CMSU%6r+ zr6A^|ujAg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2GLm@;@SLAM<$XU(_-6%-kvS?<{%dMk4)W QjInI-inmJM_+ + + + + + + + + + + + + + + Corpus + + + + self-authored, line two + + + + + + + + + A fixed-width field wraps its words onto lines. + + + + + + + + + Score 0042 + + + + + + + + + type here + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/text/golden/frame-000.png b/crates/xfl/tests/corpus/text/golden/frame-000.png new file mode 100644 index 0000000000000000000000000000000000000000..1252f495b959746a92e0aea775936c17e7ba37b1 GIT binary patch literal 1730 zcmeAS@N?(olHy`uVBq!ia0vp^3xGI^gAGX9ABzPFuyuO6IEGX(zCFOaKqYe8v5)`D z-}Rn2v%JVVd0p=9ZBUfiGjE#L`gumiO7DJ_ZO^J&)^44B)qmUB(D1+C9q?1!20ha) zqV66xk)1Se$E#K1p(}!3t4V);{bG0W9)=U!D((2Dmly8X)4Y1!ukW{F?i_jch;1H! z%59tJiF=N``zO5f)vEs*$G6M7-j{v6Q{ncrop0XRPXtNI^csh8E`raf=Unf<)zeyjb{RjdCkjxGKqTB!%LPVal{kKlE?UfJI= zRga%Is%SI_V5#8Uqj+!%{jag`)JtLg)5VV4&KBRiTd#Duq7#@n`!AIrx7hbrV;=XW z+pprd2_UrqtJ9l)RJ<4k%4@`87 zZ6Af)S69zi=6p#QD7T0!H0y3ka-D2#d5<{5O*5d-eP;ZW{(*ZBYwuLQJ1MhP&v2_L z$dFa3$BzAxxIV9r#d`Mj4@|(k@pH%TH^Mt!zj+MIH1+GH&)KxSK5sMYIne0ysqa77 z&HK}1{{WO3Y#uqTKX&e!sf{=&pQ+nF=D%URryu0UO`9uu`ztQ22Ky%F-?PsBC$3xr z`!XtR&y~gZrhqfdC-MH@n&3Qi+V)#+1vp#Pf7~(u5yo<=V0}IeN z^Es6~*XLK7oM+#Z8`rS+@b4Yp?@YFgicQMO2I_PTJ>Ap$({P>bUyd@f^$%GIl>bCj f5g;WG + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/tweens/LIBRARY/Ball.xml b/crates/xfl/tests/corpus/tweens/LIBRARY/Ball.xml new file mode 100644 index 00000000..1db5c596 --- /dev/null +++ b/crates/xfl/tests/corpus/tweens/LIBRARY/Ball.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/tweens/LIBRARY/Box.xml b/crates/xfl/tests/corpus/tweens/LIBRARY/Box.xml new file mode 100644 index 00000000..58481187 --- /dev/null +++ b/crates/xfl/tests/corpus/tweens/LIBRARY/Box.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/crates/xfl/tests/corpus/tweens/golden/frame-000.png b/crates/xfl/tests/corpus/tweens/golden/frame-000.png new file mode 100644 index 0000000000000000000000000000000000000000..29770ccebd04aea444a96ddd5b13432ebc11dc99 GIT binary patch literal 2150 zcmdUxdrT7t9LL)g5k>5#7@QbR#EH&e6G`ag(fS-B4Ca(IQ)xGGAu5EaQz(=k!VGhO zAPlCfwD=fIP&#n~)RyBRuR^J4urzfP1X^I0J`UO*?cMEQxMU{FNcP9FYBOdSdOrGuUNRnf9(Wvw)S{RSys@A-l!URGz+zEo0oy_dO0%; zp7kYweMB>Su75C>^PR%>lQr&{_3)WqXnA#luyeTxThedNWL{*|AIqfIZRFk&1d{l= ziJ(fHE#8g4qocN8X<=V1pJXpx6R-y9?qiFmSh9d0TB zka61Z4*cP0iMHN6bZU&~p;(_O_EU6{KLmSIa?ZBS-IUXx{i&!yJiC@JF;!>XP z7j~<8eZIy}Lv{0Q@mDdz!`qno@$N}wsYzF!e^J6nr>E*!L$6ZhrOKXi1ys8eHX3vG@(T8kXEIsHwGjTe zXMIi^!{I$ck6fMLH4wuXFYIH~<%(1E3us+!4od-g=aB817+Llw0c9Sz%rMy_l9fZ| zjM}v1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3# ztVDBIL9@@Pf$Sek4oa@wief(wmaYk59`OV_|NHkz?OF4DYC*(HdrQIxV1hyqqMyZd zWQ~Om4qb#s*8-UX`^DmOLkh-ji&*_b+x7h%m+>d*jmoDSsPGZ3`Xng9YmWxh-&@S# Z&HGo83)RwK><_L}#O7_A%ENYN{s+72UQhr4 literal 0 HcmV?d00001 diff --git a/crates/xfl/tests/corpus/tweens/golden/frame-012.png b/crates/xfl/tests/corpus/tweens/golden/frame-012.png new file mode 100644 index 0000000000000000000000000000000000000000..25d1775c92eb4afe74c72d52040eb020f4658c48 GIT binary patch literal 2376 zcmb`JYfw{X8pjh*Kq+RyGO-{;!LGHeWJjvF10+^ufU3k6yBVt_IL0pm;7iw(UUe5%uG_v!K0H$UWL%>wqwoS4PANeir}>XGa_}dD)O^fyRFiEJZvcs>=M-O*D}g>x@Je#}1cZ8+_2{%NYS zI)ytP*?3+~f>tIkou&6}LWhJ}=BP-7V}8 zNi4;6Cs}f31hgumw0D z65ekO7%}x73X;@EaqYo;$>(Ia(trimIt#F~#G^N`$oO z!ORwsKQ4C)Ze{A|!vjQkC+yynOsGVdHd{yryGROl8cD8vU)vjRTvygzf?}J?4I{&A8hBz+8AgIvOW_) zMSo_SsoHt3qx%NkWu|6{?0dRv%U$98gtr<9=wB~#(aM5P^8i=mBdd*|n6s%SFCKo8 z_yFqBjFjvK^b^M>vq|r)nls$A|B=01BkeZ9F__DKm>TQ@a|ENKOWjCFPsYzW^4ru? zeDIrUD&s8#om8F)#`r21D>>=zaqz)`MDk^Ps2A{Jhfyt*@y@6koz=kE*|!)Pa8O-GzJLaaPg=JWg!(IBd*QOwM~qh}TUNM|VF3yUExwaz&At zo8(ZaM(B$??!X#5n^K~32P}(3*F5o)nD>JbxM4ch_vrC*olY3Y%+`~8L*&{uLhQMV zzO}j}#wrv;8cA~!%{xp%1nBT=&7j$bSkw5Xa;1f?56#go5(ccKE$|wS)=HlE(`?Ti z#FwKaI$`a8HgXGl~iZqK{J|8+N zS&ryWAln)SJ3#|MIUgLa@h3x-P-UT^vV>4boL{mSO>vwh7$h(8fO-uV%x8Yf9kF9s zdNH(-=e9*;G(zzd%|i2?mCrfefFr|5>fStLSS7=q>c2CH5$fNA;}M zgPy(98nE}#LLxgMPwBw<+LFt3%J=;;Ny&aCWw|TPP?y>~e@K{&)Xc55oA(v}7g(N2 AHUIzs literal 0 HcmV?d00001 diff --git a/crates/xfl/tests/corpus/tweens/tweens.xfl b/crates/xfl/tests/corpus/tweens/tweens.xfl new file mode 100644 index 00000000..860a820e --- /dev/null +++ b/crates/xfl/tests/corpus/tweens/tweens.xfl @@ -0,0 +1 @@ +PROXY-CS5 \ No newline at end of file From e4de73b5ce5d8b90c0490cd4ff9dec28d6770fc7 Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Mon, 9 Nov 2026 22:17:53 -0700 Subject: [PATCH 4/8] test(engine): golden renders of the XFL corpus with a reusable golden-image helper (M4) 20 frames of the corpus rendered by the CPU oracle at 160x90 and compared with committed PNGs (a pixel differs past 3 per channel; at most 0.2 % may), plus hand-worked colour probes, and every package opened with file.open and round-tripped through .anicraft. UPDATE_GOLDENS=1 rewrites the goldens; a mismatch writes the render and a diff image and names them. Rendering and comparing all 20 frames takes about 20 ms. --- crates/engine/tests/golden/mod.rs | 124 ++++++++++++++++++++++ crates/engine/tests/xfl_corpus.rs | 167 ++++++++++++++++++++++++++++++ 2 files changed, 291 insertions(+) create mode 100644 crates/engine/tests/golden/mod.rs create mode 100644 crates/engine/tests/xfl_corpus.rs diff --git a/crates/engine/tests/golden/mod.rs b/crates/engine/tests/golden/mod.rs new file mode 100644 index 00000000..55505757 --- /dev/null +++ b/crates/engine/tests/golden/mod.rs @@ -0,0 +1,124 @@ +//! Golden image checks (ADR 0035): a render is compared with a committed PNG, pixel by pixel, +//! within a tolerance. +//! +//! * `UPDATE_GOLDENS=1 cargo test …` writes the renders as the new goldens (look at them before +//! committing: a golden is only as right as the eyes that accepted it). +//! * A missing golden fails (CI never makes its own), and says how to make it. +//! * On a mismatch the render and a diff image (the golden faded, with the pixels that differ +//! in red, brighter the more they differ) are written under Cargo's temporary folder for +//! integration tests, and the failure names both paths. + +use std::path::{Path, PathBuf}; + +/// How far a render may stray from its golden: a pixel differs when any channel (RGBA, 0-255, +/// not premultiplied) is off by more than `channel`; the check fails when more than `pixels` +/// (a fraction of the image) differ. The default absorbs floating-point differences between +/// computers on anti-aliased edges, and catches a shape moved by a pixel or a colour changed +/// anywhere it covers. +#[derive(Clone, Copy, Debug)] +pub struct Tolerance { + pub channel: u8, + pub pixels: f32, +} + +pub const DEFAULT: Tolerance = Tolerance { channel: 3, pixels: 0.002 }; + +/// Whether this run writes goldens instead of checking them. +pub fn updating() -> bool { + std::env::var("UPDATE_GOLDENS").is_ok_and(|v| v.trim() == "1") +} + +/// Where failed checks leave their render and diff images. +fn out_dir() -> PathBuf { + Path::new(env!("CARGO_TARGET_TMPDIR")).join("golden-diffs") +} + +fn decode(bytes: &[u8]) -> Result<(u32, u32, Vec), String> { + let mut reader = png::Decoder::new(bytes).read_info().map_err(|e| e.to_string())?; + let mut buf = vec![0; reader.output_buffer_size()]; + let info = reader.next_frame(&mut buf).map_err(|e| e.to_string())?; + if info.color_type != png::ColorType::Rgba || info.bit_depth != png::BitDepth::Eight { + return Err(format!("expected 8-bit RGBA, found {:?} {:?}", info.color_type, info.bit_depth)); + } + buf.truncate(info.buffer_size()); + Ok((info.width, info.height, buf)) +} + +fn write(path: &Path, width: u32, height: u32, rgba: &[u8]) { + if let Some(dir) = path.parent() { + std::fs::create_dir_all(dir).unwrap(); + } + std::fs::write(path, anicraft_render::encode_png(width, height, rgba).unwrap()).unwrap(); +} + +/// Checks `rgba` (`width` × `height`, straight alpha) against the golden at `golden`, or writes +/// it there when updating. `name` names the leftovers of a failure. +pub fn check(golden: &Path, name: &str, width: u32, height: u32, rgba: &[u8], tol: Tolerance) -> Result<(), String> { + if updating() { + assert_eq!(rgba.len(), (width * height * 4) as usize); + write(golden, width, height, rgba); + return Ok(()); + } + compare(golden, name, width, height, rgba, tol) +} + +/// The comparison [`check`] makes when it isn't updating. +fn compare(golden: &Path, name: &str, width: u32, height: u32, rgba: &[u8], tol: Tolerance) -> Result<(), String> { + assert_eq!(rgba.len(), (width * height * 4) as usize); + let keep = |why: String| -> String { + let actual = out_dir().join(format!("{name}.actual.png")); + write(&actual, width, height, rgba); + format!("{name}: {why}\n golden: {}\n render: {}", golden.display(), actual.display()) + }; + let bytes = std::fs::read(golden).map_err(|e| keep(format!("no golden ({e}); run with UPDATE_GOLDENS=1 to make it, then look at it")))?; + let (gw, gh, want) = decode(&bytes).map_err(|e| keep(format!("unreadable golden: {e}")))?; + if (gw, gh) != (width, height) { + return Err(keep(format!("the golden is {gw}×{gh}, the render {width}×{height}"))); + } + let mut bad = 0usize; + let mut worst = 0u8; + let mut diff = Vec::with_capacity(rgba.len()); + for (a, b) in rgba.chunks_exact(4).zip(want.chunks_exact(4)) { + let d = a.iter().zip(b).map(|(x, y)| x.abs_diff(*y)).max().unwrap_or(0); + worst = worst.max(d); + if d > tol.channel { + bad += 1; + diff.extend_from_slice(&[128u8.saturating_add(d / 2), 0, 0, 255]); + } else { + // The golden, faded towards white, for context. + let fade = |c: u8| 192 + c / 4; + diff.extend_from_slice(&[fade(b[0]), fade(b[1]), fade(b[2]), 255]); + } + } + let allowed = (tol.pixels * (width * height) as f32).floor() as usize; + if bad > allowed { + let diff_path = out_dir().join(format!("{name}.diff.png")); + write(&diff_path, width, height, &diff); + return Err(format!("{}\n diff: {}", keep(format!("{bad} pixels differ (at most {allowed} may), by up to {worst}")), diff_path.display())); + } + Ok(()) +} + +#[test] +fn the_check_passes_within_the_tolerance_and_fails_past_it() { + let dir = out_dir().join("self-test"); + let golden = dir.join("g.png"); + let (w, h) = (20, 10); + let base: Vec = (0..w * h).flat_map(|i| [i as u8, 100, 200, 255]).collect(); + write(&golden, w, h, &base); + assert!(compare(&golden, "self-test-same", w, h, &base, DEFAULT).is_ok()); + // Small differences everywhere are within the channel tolerance. + let near: Vec = base.iter().map(|c| c.saturating_sub(2)).collect(); + assert!(compare(&golden, "self-test-near", w, h, &near, DEFAULT).is_ok()); + // A whole row changed is not. + let mut off = base.clone(); + for px in off.chunks_exact_mut(4).take(w as usize) { + px[1] = 0; + } + let err = compare(&golden, "self-test-off", w, h, &off, DEFAULT).unwrap_err(); + assert!(err.contains("20 pixels differ") && err.contains("self-test-off.diff.png"), "{err}"); + assert!(out_dir().join("self-test-off.diff.png").exists() && out_dir().join("self-test-off.actual.png").exists()); + // A missing golden fails and says how to make one. + let err = compare(&dir.join("none.png"), "self-test-missing", w, h, &base, DEFAULT).unwrap_err(); + assert!(err.contains("UPDATE_GOLDENS=1"), "{err}"); +} diff --git a/crates/engine/tests/xfl_corpus.rs b/crates/engine/tests/xfl_corpus.rs new file mode 100644 index 00000000..8e142475 --- /dev/null +++ b/crates/engine/tests/xfl_corpus.rs @@ -0,0 +1,167 @@ +//! Golden renders of the self-authored XFL corpus (`crates/xfl/tests/corpus/`, ADR 0035). +//! +//! Each package is imported (without fonts, so text is reported rather than drawn in whatever +//! fonts this computer has, and the renders match everywhere), chosen frames are rendered by +//! the CPU oracle at half size (160 × 90), and each is compared with the golden PNG in the +//! package's `golden/` folder. Probes then check, by hand-worked colours, what the golden +//! should show. `UPDATE_GOLDENS=1` rewrites the goldens (see `golden/mod.rs`). +//! +//! The report and structure of each package, and its hostile variants, are checked in the xfl +//! crate (`crates/xfl/tests/corpus.rs`). + +mod golden; + +use anicraft_engine::Session; +use anicraft_engine::doc::Document; +use anicraft_engine::text::Fonts; +use serde_json::json; +use std::path::{Path, PathBuf}; + +fn corpus() -> PathBuf { + Path::new(env!("CARGO_MANIFEST_DIR")).join("../xfl/tests/corpus") +} + +/// The frames rendered for each package (frames count across scenes, from 0). +const FRAMES: &[(&str, &[u32])] = &[ + ("bitmaps", &[0]), + ("filters", &[0]), + ("gradients", &[0]), + ("guides", &[0, 6, 12]), + ("masks", &[0]), + ("primitives", &[0]), + ("scenes", &[0, 3, 7, 8, 10]), + ("shapes", &[0]), + ("symbols", &[0, 5]), + ("text", &[0]), + ("tweens", &[0, 6, 12]), +]; + +/// Render scale: the corpus stages are 320 × 180. +const SCALE: f32 = 0.5; + +/// What a frame must show at a stage point: (package, frame, x, y, colour). +const PROBES: &[(&str, u32, f32, f32, u32)] = &[ + // Both sides of a shared edge, the hole, the hex-coordinate triangle. + ("shapes", 0, 45.0, 50.0, 0xD9452B), + ("shapes", 0, 80.0, 30.0, 0x2B6CD9), + ("shapes", 0, 95.0, 50.0, 0xF4F1EA), + ("shapes", 0, 270.0, 60.0, 0xF29E1F), + ("primitives", 0, 40.0, 50.0, 0xF2CC8F), + ("primitives", 0, 210.0, 40.0, 0xE07A5F), + ("primitives", 0, 6.0, 170.0, 0xFFFFFF), + // The checker's transparent corner, then a teal and a cream square, four times as large. + ("bitmaps", 0, 14.0, 14.0, 0xFFFFFF), + ("bitmaps", 0, 34.0, 18.0, 0x2A9D8F), + ("bitmaps", 0, 34.0, 34.0, 0xE9C46A), + // Loop modes: frame 0, then frame 5. + ("symbols", 0, 30.0, 40.0, 0xE63946), + ("symbols", 0, 80.0, 40.0, 0x2A9D8F), + ("symbols", 0, 130.0, 40.0, 0x457B9D), + ("symbols", 0, 180.0, 40.0, 0xE9C46A), + ("symbols", 5, 30.0, 40.0, 0x2A9D8F), + ("symbols", 5, 80.0, 40.0, 0xE9C46A), + ("symbols", 5, 130.0, 40.0, 0x457B9D), + // The button's Up frame. + ("symbols", 0, 82.0, 130.0, 0x2A9D8F), + // Brightness +60% and -50% of #6D597A. + ("symbols", 0, 230.0, 130.0, 0xC5BDCA), + ("symbols", 0, 260.0, 130.0, 0x372D3D), + ("tweens", 0, 20.0, 25.0, 0xF4A261), + ("tweens", 12, 300.0, 25.0, 0xF4A261), + // Masked stripes: inside the spot, and outside it. + ("masks", 0, 60.0, 22.0, 0x264653), + ("masks", 0, 60.0, 27.0, 0xFFFFFF), + ("masks", 0, 10.0, 22.0, 0xFFFFFF), + ("masks", 0, 145.0, 10.0, 0xFFFFFF), + ("masks", 0, 270.0, 70.0, 0xCB997E), + // Guide artwork never draws. + ("guides", 0, 5.0, 5.0, 0xFFFFFF), + ("guides", 0, 160.0, 60.0, 0xFFFFFF), + ("scenes", 0, 160.0, 165.0, 0xFCA311), + ("scenes", 7, 160.0, 90.0, 0xE5E5E5), + ("scenes", 8, 160.0, 90.0, 0xFCA311), + ("scenes", 10, 160.0, 90.0, 0x14213D), + ("text", 0, 300.0, 80.0, 0xE9EDC9), +]; + +fn import(case: &str) -> Document { + let dir = corpus().join(case); + let read = |p: &str| -> Result>, anicraft_xfl::XflError> { + match std::fs::read(dir.join(p)) { + Ok(b) => Ok(Some(b)), + Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(None), + Err(e) => Err(e.into()), + } + }; + anicraft_xfl::import_with_fonts(&read, &Fonts::from_faces(Vec::new())).unwrap_or_else(|e| panic!("{case}: {e}")).0 +} + +fn render(doc: &Document, frame: u32) -> (u32, u32, Vec) { + let pm = anicraft_render::render_frame(doc, frame, SCALE).unwrap(); + (pm.width, pm.height, pm.to_rgba8()) +} + +#[test] +fn every_package_has_golden_frames() { + let mut cases: Vec = std::fs::read_dir(corpus()).unwrap().flatten().filter(|e| e.path().is_dir()).map(|e| e.file_name().to_string_lossy().into_owned()).collect(); + cases.sort(); + assert_eq!(cases, FRAMES.iter().map(|(c, _)| *c).collect::>(), "give the new package its frames here and its report in crates/xfl/tests/corpus.rs"); +} + +#[test] +fn corpus_frames_match_their_goldens() { + let mut failures = Vec::new(); + let mut checked = 0; + let start = std::time::Instant::now(); + for (case, frames) in FRAMES { + let doc = import(case); + for &f in *frames { + assert!(f < doc.frame_count(), "{case}: frame {f} of {}", doc.frame_count()); + let (w, h, rgba) = render(&doc, f); + assert_eq!((w, h), (160, 90), "{case}"); + let golden = corpus().join(case).join("golden").join(format!("frame-{f:03}.png")); + if let Err(e) = golden::check(&golden, &format!("{case}-frame-{f:03}"), w, h, &rgba, golden::DEFAULT) { + failures.push(e); + } + checked += 1; + } + } + eprintln!("{checked} corpus frames rendered and compared in {:?}", start.elapsed()); + assert!(failures.is_empty(), "{} of {checked} frames differ from their goldens:\n{}", failures.len(), failures.join("\n")); +} + +#[test] +fn corpus_frames_show_what_the_files_describe() { + let mut wrong = Vec::new(); + for &(case, frame, x, y, want) in PROBES { + let (w, _, rgba) = render(&import(case), frame); + let (px, py) = ((x * SCALE) as u32, (y * SCALE) as u32); + let i = ((py * w + px) * 4) as usize; + let got = &rgba[i..i + 3]; + let want = [(want >> 16) as u8, (want >> 8) as u8, want as u8]; + if got.iter().zip(want).any(|(g, w)| g.abs_diff(w) > 6) { + wrong.push(format!("{case} frame {frame} at ({x}, {y}): #{:02X}{:02X}{:02X}, want #{:02X}{:02X}{:02X}", got[0], got[1], got[2], want[0], want[1], want[2])); + } + } + assert!(wrong.is_empty(), "{}", wrong.join("\n")); +} + +/// Opening a package is one command, like opening any file, and what it imports saves and +/// opens again as the same document. +#[test] +fn every_package_opens_with_file_open_and_round_trips_through_the_file_format() { + let dir = Path::new(env!("CARGO_TARGET_TMPDIR")).join("xfl-corpus-round-trip"); + std::fs::create_dir_all(&dir).unwrap(); + for (case, _) in FRAMES { + let mut s = Session::default(); + let info = s.execute("file.open", &json!({"path": corpus().join(case).display().to_string()})).unwrap_or_else(|e| panic!("{case}: {e}")); + assert!(info["imported"].is_string(), "{case}: {info}"); + assert!(s.path.is_none(), "an imported document is untitled"); + let path = dir.join(format!("{case}.anicraft")); + // A rerun saves over the last run's file, which asks first (ADR 0004). + s.execute("file.save", &json!({"path": path.display().to_string(), "confirm": true})).unwrap(); + let mut t = Session::default(); + t.execute("file.open", &json!({"path": path.display().to_string()})).unwrap(); + assert!(s.doc == t.doc, "{case}: the saved document opens differently"); + } +} From a629801d086d283df3cb9cbaede074c5b8465c16 Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Mon, 9 Nov 2026 22:17:53 -0700 Subject: [PATCH 5/8] docs: ADR 0035 for the XFL corpus and golden renders, ADR 0009 testing, roadmap, changelog and attribution (M4) --- ATTRIBUTION.md | 2 + CHANGELOG.md | 21 ++++ docs/adr/0009-xfl-import.md | 11 ++ .../adr/0035-xfl-corpus-and-golden-renders.md | 100 ++++++++++++++++++ docs/roadmap.md | 8 +- 5 files changed, 138 insertions(+), 4 deletions(-) create mode 100644 docs/adr/0035-xfl-corpus-and-golden-renders.md diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index 41c168d9..a21cfcca 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -43,6 +43,8 @@ shaders or SDK code). | File | Use | Author | Source | Licence | |---|---|---|---|---| +| `crates/xfl/tests/corpus/` (11 XFL packages: XML, `.xfl` proxies, `bitmaps/LIBRARY/art/checker.png` and `sunset.jpg`) | XFL import corpus (never shipped in the app) | AniCraft contributors | Original work, written by hand from the public description of the XFL format; the two images made for it (a 16×16 checker drawn in a script, and a 32×16 ramp encoded to JPEG with ffmpeg) | MIT OR Apache-2.0 | +| `crates/xfl/tests/corpus/*/golden/*.png` (20 frames, 160×90) | Golden renders of the corpus | AniCraft contributors | Original work: AniCraft's own CPU renders of the corpus (`UPDATE_GOLDENS=1`) | MIT OR Apache-2.0 | | `crates/audio/tests/data/tone.ogg`, `tone.mp3` | Decoder tests (never shipped in the app) | AniCraft contributors | Generated for these tests: half a second of a 440 Hz sine made by ffmpeg's `sine` source, encoded with libvorbis and libmp3lame | MIT OR Apache-2.0 | ### Optional build input: craft-fonts (not files in this repo) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72e688aa..0e48f39c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,27 @@ ## Unreleased +* **Opening Animate files is checked against a corpus of test files** (XFL import, ADR 0035). + Eleven hand-written Animate documents cover everything the importer brings across: shapes + and strokes, primitives and groups, gradients, bitmaps, symbols in every loop mode, movie + clips and buttons, colour effects, classic and shape tweens with eases and shape hints, + masks (also in folders and symbols), guides and motion guides, text, filters, blend modes, + scenes, labels and frame scripts. Each is imported, and chosen frames are rendered and + compared with reference images, so a change that alters how an imported file looks is + caught. Each file is also cut short and garbled thousands of ways to make sure opening a + damaged file never crashes. + + Fixed while building it: + * Symbols saved without a type now open as movie clips (Animate leaves the default out), + not graphics. + * Brightness on an instance now comes across (it was dropped). + * Instance names of movie clips and buttons now come across, so actions can address them. + * A frame comment no longer becomes a frame label. + * A custom ease with one curve now comes across exactly. + * The import report now also lists what is drawn differently from Animate: square and flat + line ends and corners (drawn round), gradient strokes (one colour), repeating and + reflecting, off-centre, stretched and linear-RGB gradients, advanced colour effects, + reverse loop modes and extra spins on tweens. * **Brush tool** (B, ADR 0033, first slice). The brush paints filled shapes in the fill colour, as Animate's Brush tool does: the shape is exactly the area the tip sweeps along the drag. * Tip options: round or square, size, angle and roundness (for oval and flat calligraphic diff --git a/docs/adr/0009-xfl-import.md b/docs/adr/0009-xfl-import.md index 63fd0a6b..1ab28451 100644 --- a/docs/adr/0009-xfl-import.md +++ b/docs/adr/0009-xfl-import.md @@ -48,3 +48,14 @@ own timelines, nested to any depth. missing fonts named in the report). * Next slices: bitmaps (needs bitmap fills, M5), masks (M2), motion tweens, shape tweens, more scenes, and a corpus of larger self-authored files. + +## Testing + +* Unit tests on inline snippets in `crates/xfl/src/tests.rs`, `text_tests.rs` and + `edges.rs` pin single behaviours (edge decoding, fill rebuilding, each mapping). +* **The corpus** (ADR 0035): eleven self-authored XFL packages in `crates/xfl/tests/corpus/` + that together use every feature the importer claims. Each has an exact report expectation, + structural checks and about 270 hostile variants (cut short, garbled, files missing) that + must never panic (`crates/xfl/tests/corpus.rs`), and golden renders of chosen frames by the + CPU oracle with hand-worked colour probes (`crates/engine/tests/xfl_corpus.rs`, regenerated + with `UPDATE_GOLDENS=1`). A feature the importer learns gets a corpus file in the same change. diff --git a/docs/adr/0035-xfl-corpus-and-golden-renders.md b/docs/adr/0035-xfl-corpus-and-golden-renders.md new file mode 100644 index 00000000..0d924936 --- /dev/null +++ b/docs/adr/0035-xfl-corpus-and-golden-renders.md @@ -0,0 +1,100 @@ +# ADR 0035: The XFL corpus and golden render tests + +* Status: accepted (2026-11-09) +* Relates to: ADR 0009 (XFL import), ADR 0014 (XFL text), ADR 0023 (shape hints), ADR 0002 + (render pipeline: the CPU renderer is the oracle), roadmap M4 + +## Context + +XFL import had grown feature by feature (shapes, symbols, bitmaps, masks, folders, scenes, +text, filters, blend modes, shape tweens and hints), each tested with a small inline snippet +that checked the model. Nothing checked what an imported file *looks like*, nothing exercised +the features together in files shaped like Animate's (namespaces, declarations, comments, +library folders, `.xfl` proxy files, attributes we ignore), and the hostile-input test was one +hand-written document. A regression in edge chaining, a gradient matrix or a mask link would +pass every test as long as the model kept its shape. + +We may not use Animate's own files (clean room, ADR 0009), so the corpus has to be written by +hand from the public descriptions of the format. + +## Decision + +1. **A corpus of self-authored packages** in `crates/xfl/tests/corpus//`, each a real + XFL folder: `DOMDocument.xml`, `LIBRARY/` (symbols and images), and `.xfl`. Eleven + packages, one per area, together covering every feature the importer claims: `shapes` + (every edge command, both selectors of lines and curves, `S` marks, hex fixed point, a fill + on both sides of an edge, a hole, alpha, every cap and join, strokes continuing across + edges and with gaps), `primitives` (rectangles, ovals, nested groups, a hidden layer), + `gradients` (linear and radial with matrices, rotation, repeat and reflect, a focal point, an + ellipse, linear-RGB, a gradient stroke), `bitmaps` (PNG and JPEG instances, repeating and + clipped fills, a missing image), `symbols` (graphics in every loop mode, nesting, a movie + clip, a button, every colour effect, a missing symbol), `tweens` (classic with eases, a + custom ease, extra spins, a shape tween with a hint, a motion tween), `masks` (top level, in + a folder, inside a symbol), `guides` (plain and motion guides), `text` (static, dynamic and + input fields, several runs), `filters` (every filter, a stack, switched off, unknown, and + blend modes) and `scenes` (three scenes, labels, a comment, an anchor, frame scripts). Every + image is original (made for the corpus, listed in `ATTRIBUTION.md`). +2. **Three kinds of check per package.** + * *Report and structure* (`crates/xfl/tests/corpus.rs`): the exact report each package + must produce (every line is something it uses on purpose), and targeted checks of the + model (loops per fill, loop modes, eases, mask and guide links, labels, scenes). + * *Hostile variants* (same file): every file of every package cut short at 26 points, + garbled 96 ways (deterministic xorshift: overwritten bytes, inserted markup and edge + commands and out-of-range numbers, deleted and repeated spans, changed digits), and every + file removed in turn. Import may fail, never panic, and what it imports must evaluate. + About 3,000 variants, run in a quarter of a second. + * *Golden renders* (`crates/engine/tests/xfl_corpus.rs`): chosen frames of every package + rendered by the CPU oracle at half size (160 × 90) and compared with committed PNGs in + the package's `golden/` folder, plus probes that check hand-worked colours at chosen + points, so a golden that drifted from what the file describes can't be accepted quietly. + Each package also opens with `file.open` and round-trips through `.anicraft`. +3. **Goldens live in the engine's tests, the corpus in the xfl crate.** The renderer and the + importer are both L2, and a crate may not depend on its own layer (dev-dependencies + included, `src/architecture_tests.rs`). The engine (L3) already depends on both and is + where `file.open` imports, so its integration tests render the corpus in place. We chose + this over relaxing the layering rule for dev-dependencies (a rule with exceptions stops + being checked) or moving rendering checks into the CLI (L4, further from the importer). +4. **The golden helper** (`crates/engine/tests/golden/mod.rs`, reusable by any future corpus): + * compares straight-alpha RGBA8; a pixel differs when a channel is off by more than 3, and + the check fails when more than 0.2 % of pixels differ. That absorbs floating-point + differences on anti-aliased edges between computers, and catches a shape moved by a + pixel or a colour changed anywhere it covers; + * `UPDATE_GOLDENS=1` writes the renders as the goldens; a missing golden fails (CI never + makes its own) and says how to make it; + * on a mismatch it writes the render and a diff image (the golden faded, differing pixels + in red) under Cargo's integration-test temporary folder and names both paths. +5. **Text renders without fonts.** Text is laid out with the fonts on the computer, which no + two computers share and which we may not commit. The golden renders import with no fonts + (text reported, the rest drawn), so they match everywhere; the text package's blocks are + checked structurally with whatever fonts the computer has. +6. **Importer fixes the corpus found** (each covered by the corpus and unit tests): + * a library symbol without `symbolType` is a **movie clip** (the format leaves defaults out; + only graphics and buttons say what they are). It was imported as a graphic; + * **brightness** colour effects were dropped; they are now a tint towards white or black by + that amount (the same colour change). Advanced colour effects keep their alpha and are + reported; + * **instance names** of movie clips and buttons were dropped, so actions couldn't address + imported instances (ADR 0024); names that are identifiers are now kept, others reported; + * a **frame comment** (`labelType="comment"`) was imported as a label that actions could + go to; it is now left out and reported (anchors stay labels); + * a **custom ease** of one segment is now the cubic Bézier it is; longer curves and + per-property curves keep the slider's ease and are reported; + * reverse loop modes play forward and are reported; + * what AniCraft draws the nearest way is now reported instead of silently changed: caps and + joins other than round, gradient and bitmap strokes, repeating and reflecting gradients, + focal points, elliptical radial gradients, linear-RGB gradients, and extra tween spins. + +## Consequences + +* An importer or renderer change that alters how a corpus file looks fails with the paths of + the render and the diff; an intended change is accepted by rerunning with + `UPDATE_GOLDENS=1` and looking at the new PNGs (they are small: 20 frames, about 120 KB). +* The corpus is the place to add a feature's file when the importer learns it. Two tests + refuse a package without report expectations or golden frames. +* The corpus is written from the format's public description, not from Animate's output, so + it can share our misreadings of the format. Where we were unsure (the default symbol type, + the custom ease and shape-hint forms) this ADR says so, and a file saved by Animate that + disagrees should become a corpus fix, not a special case. +* Not in this slice: `.fla` (zip) variants of the corpus, sound and video items, motion tweens + with property curves, and per-character text styles (all reported, and kept for their own + slices). diff --git a/docs/roadmap.md b/docs/roadmap.md index 9ee4a142..fcc0390a 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -16,7 +16,7 @@ milestone ends with a green tree: build, tests, clippy, a `--screenshot` check a | Interactivity | **Frame actions, frame scripts and Test Movie, first slice** (ADR 0024): a typed timeline action IR (`anicraft-actions`: stop, play, go to a frame or label in a scene, next/previous frame and scene, trace, set x/y/alpha/visible/rotation/scale, instance-name target paths) on keyframes and on button and movie clip instances (click, press, release, over, out); a pure, deterministic, budgeted player in `anicraft-doc` (`step(doc, &state, &events)`; movie clip playheads, button Up/Over/Down states with Hit-frame hit tests, script-set properties) drawn by `evaluate_player`, while `evaluate` and exports stay script-free. **Actions panel** (F9: structured lists, targets/labels/scenes picked from the document; movie clip timelines too), instance name and events in Properties, an "a" on keyframes with actions. **Frame scripts** on the plug-in host (`kind: "frame-script"`, entry points, `player`/`action` ops, 20 M instructions per frame shared, no document access). **Test Movie** (Control › Test Movie, Ctrl+Enter): the player at the document frame rate in its own window with the pointer, restart/pause/step and an Output panel. Headless: `actions.set/clear/list`, `instance.set_name`, `control.test_movie` (timed pointer events, returns output and state). **HTML canvas export** (ADR 0028, `file.export_html`, File › Export › Export HTML Canvas…): one self-contained page (data, player and drawing code inline; images and sounds embedded) that plays in any browser with canvas 2D; every used timeline baked frame by frame (tweens of every kind exact, identical paths, paints and frames stored once), movie clips, buttons with Hit areas and every action run by `player.js`, a port of the Rust player checked against it step by step in Boa (state, output and display list); masks and fading/blending groups on offscreen layers; Web Audio for Event/Start/Stop/Stream sounds; filters, Subtract/Invert, bitmap tints and plug-in frame scripts reported. Not yet: ActionScript (ADR 0013 tiers), filters and keyboard focus in the HTML page, sound actions, keyboard events, variables, persistent script state, masks in hit tests, a separate OS window. | | Headless | CLI: info, render, render-seq, **gif**, commands, exec, run, serve (JSON-lines). **MCP server** (`anicraft-cli mcp`, `docs/mcp.md`): stdio JSON-RPC, protocol 2025-06-18 (and 2025-03-26, 2024-11-05); five tools over the command registry (list, run, run a script, describe the document, render a frame as a PNG picture); confirmation tiers and undo apply as in the app. | | Sound | **Audio layers, first slice** (ADR 0020): WAV (own reader), Ogg Vorbis (`lewton`) and MP3 (`nanomp3`) import, bounded and crash-proof; sounds live in the library, stored in `.anicraft` as imported, decoded once in the background. A sound belongs to a keyframe as in Animate (Properties › Sound: name, Sync Event/Start/Stop/Stream, Repeat ×N or Loop); Import to Stage puts one on a new layer spanning its length, Import to Library only adds it, the Library previews, places and deletes sounds. The timeline draws each sound's waveform over its span. Stage playback plays the mix through `cpal` (default feature `sound-output`) and the playhead follows the audio clock; stream sounds resync after a jump and scrubbing plays one-frame snippets. Mixing is pure and sample-exact (`doc::sound::voices` + `audio::mix`, Catmull-Rom resampling between rates). Headless: `sound.place/set/remove/rename/delete`, `file.import_to_library`, **`file.export_audio`** (WAV, 16/24-bit or float, any rate), and Export Video carries the soundtrack (Opus in WebM, AAC in MP4, by the user's ffmpeg). Not yet: sound effects (fades, panning, envelopes) and per-layer volume/mute, sounds inside symbols, sounds from XFL, audio in Lottie, stream sounds that follow go-tos in the HTML page, lossless compression of stored WAVs, latency compensation. | -| Files | `.anicraft` JSON load/save (v3, with scenes; v1 and v2 files open as one scene), PNG frame and sequence export, **animated GIF export** (parallel render and quantize, exact frame timing, looping), **SVG frame export** (from the same evaluated frame as the renderer: stage-space paths, renderer-matched stroke widths, gradients under `gradientTransform`, colour effects baked in, masks as nested `clipPath`s). **Opens Animate documents** (`.fla`, `.xfl`, XFL folders; ADR 0009): stage, first scene, layers, keyframes, labels, classic tweens with ease, shapes (solid/linear/radial fills, strokes), groups, primitives, symbol instances (matrix, alpha, tint, loop, blend mode, all seven filters), library symbols, **shape tweens**, **layer folders** and **mask layers** (masks inside folders too); imported files are untitled so Save never overwrites them; what isn't supported yet is reported after opening. Every scene comes across. **Bitmaps**: library items whose image is in the package as PNG or JPEG (the original in `LIBRARY/`, else the `bin/` data file when it is PNG or JPEG), instances, and bitmap fills with their matrix (twips scale removed; repeating unless clipped); Animate's own bitmap encodings are not public and are reported, not decoded. **Text** (ADR 0014): static, dynamic and input text fields become text blocks laid out by `anicraft-text`, with face (by PostScript name, family, or the family the name suggests; `_sans`/`_serif`/`_typewriter`), size, colour, bold/italic, alignment, letter and line spacing, margins, matrix, fixed width (wraps) or auto-size, and several lines; runs in different styles become one block per run of same-style lines, stacked as in Animate; a line mixing styles takes its main style and is counted; missing families fall back and are named in the report; dynamic/input fields come across as static text (reported). **Shape hints** on shape tweens (a tolerant self-authored `shapeHints` reader, ADR 0023). No per-character styles or motion tweens from XFL yet; frame scripts are counted in the import report but not kept yet (ADR 0013); **Import to Stage (Ctrl+R) for SVG drawings**: editable shapes on a new layer at the playhead, with groups, use and symbols, transforms, viewBox, styles, opacity and gradients; **clip paths and opaque masks** (ADR 0021) become mask layers in a folder named after the file (clips that cut nothing dropped, clips inside clips intersected exactly when all but one are convex polygons, curves kept), and **text** becomes text blocks, one per text chunk (position, anchor, font family list, size, weight, style, letter spacing, fill), with missing fonts named; soft masks, per-character positions, text on a path and dashes are reported, as is anything else unsupported. **Sprite sheet export**: movie frames on one PNG grid (parallel render, columns/padding/scale, transparent or stage background) with a "JSON hash" frame map (rectangles, sizes, per-frame durations). **Video export**: WebM (VP9) or MP4 (H.264) by streaming raw frames, in order and rendered in parallel batches, to the user's own ffmpeg (no encoder bundled; ffmpeg from a parameter, `ANICRAFT_FFMPEG` or the PATH; argument lists, never a shell). **Lottie export** (`file.export_lottie`): frame-accurate rather than re-keyed: each frame is evaluated, artwork that persists (same layer, element, occurrence and path structure) becomes one shape layer with outlines baked to stage space, and whatever changes (outlines, colours, gradient points, stroke width, opacity, masks as layer masks) is written as hold keyframes where it changes; one layer order consistent with every frame (topological); checked against the reference web player (matches the renderer). Reported, not exported: bitmap fills, nested masks (innermost kept), group fades (per shape), stretched radial gradients (circles). **HTML canvas export** (`file.export_html`, ADR 0028): one self-contained web page that plays the movie, buttons and actions included (see Interactivity). | +| Files | `.anicraft` JSON load/save (v3, with scenes; v1 and v2 files open as one scene), PNG frame and sequence export, **animated GIF export** (parallel render and quantize, exact frame timing, looping), **SVG frame export** (from the same evaluated frame as the renderer: stage-space paths, renderer-matched stroke widths, gradients under `gradientTransform`, colour effects baked in, masks as nested `clipPath`s). **Opens Animate documents** (`.fla`, `.xfl`, XFL folders; ADR 0009): stage, first scene, layers, keyframes, labels, classic tweens with ease, shapes (solid/linear/radial fills, strokes), groups, primitives, symbol instances (matrix, alpha, tint, loop, blend mode, all seven filters), library symbols, **shape tweens**, **layer folders** and **mask layers** (masks inside folders too); imported files are untitled so Save never overwrites them; what isn't supported yet is reported after opening. Every scene comes across. **Bitmaps**: library items whose image is in the package as PNG or JPEG (the original in `LIBRARY/`, else the `bin/` data file when it is PNG or JPEG), instances, and bitmap fills with their matrix (twips scale removed; repeating unless clipped); Animate's own bitmap encodings are not public and are reported, not decoded. **Text** (ADR 0014): static, dynamic and input text fields become text blocks laid out by `anicraft-text`, with face (by PostScript name, family, or the family the name suggests; `_sans`/`_serif`/`_typewriter`), size, colour, bold/italic, alignment, letter and line spacing, margins, matrix, fixed width (wraps) or auto-size, and several lines; runs in different styles become one block per run of same-style lines, stacked as in Animate; a line mixing styles takes its main style and is counted; missing families fall back and are named in the report; dynamic/input fields come across as static text (reported). **Shape hints** on shape tweens (a tolerant self-authored `shapeHints` reader, ADR 0023). Brightness colour effects (as a tint towards white or black), movie clip and button instance names, one-segment custom eases (as cubic Béziers); a symbol without `symbolType` is a movie clip; frame comments aren't labels. Reported rather than silently changed: non-round caps and joins, gradient strokes, repeating/reflecting, focal-point, elliptical and linear-RGB gradients, advanced colour effects, reverse loop modes, extra tween spins. A self-authored corpus with golden renders covers all of it (ADR 0035). No per-character styles or motion tweens from XFL yet; frame scripts are counted in the import report but not kept yet (ADR 0013); **Import to Stage (Ctrl+R) for SVG drawings**: editable shapes on a new layer at the playhead, with groups, use and symbols, transforms, viewBox, styles, opacity and gradients; **clip paths and opaque masks** (ADR 0021) become mask layers in a folder named after the file (clips that cut nothing dropped, clips inside clips intersected exactly when all but one are convex polygons, curves kept), and **text** becomes text blocks, one per text chunk (position, anchor, font family list, size, weight, style, letter spacing, fill), with missing fonts named; soft masks, per-character positions, text on a path and dashes are reported, as is anything else unsupported. **Sprite sheet export**: movie frames on one PNG grid (parallel render, columns/padding/scale, transparent or stage background) with a "JSON hash" frame map (rectangles, sizes, per-frame durations). **Video export**: WebM (VP9) or MP4 (H.264) by streaming raw frames, in order and rendered in parallel batches, to the user's own ffmpeg (no encoder bundled; ffmpeg from a parameter, `ANICRAFT_FFMPEG` or the PATH; argument lists, never a shell). **Lottie export** (`file.export_lottie`): frame-accurate rather than re-keyed: each frame is evaluated, artwork that persists (same layer, element, occurrence and path structure) becomes one shape layer with outlines baked to stage space, and whatever changes (outlines, colours, gradient points, stroke width, opacity, masks as layer masks) is written as hold keyframes where it changes; one layer order consistent with every frame (topological); checked against the reference web player (matches the renderer). Reported, not exported: bitmap fills, nested masks (innermost kept), group fades (per shape), stretched radial gradients (circles). **HTML canvas export** (`file.export_html`, ADR 0028): one self-contained web page that plays the movie, buttons and actions included (see Interactivity). | | Tests | 133 tests (adds point editing, closed-path anchors, curve fitting, pen/pencil/subselection commands, the Pen's path data, frame ranges, keyframe moves, range confirmations, frame selection and the frame clipboard): unit, analytic render, band/determinism, robustness fuzz over all commands, round trip (v1 and v2 files), structural sharing and history budget, render-service equivalence, confirmations, clipboard, transforms and align, GIF decode and timing, free-transform maths, UI-guideline enforcement, CLI. | | Ease of use & safety | **Visual language** (ADR 0008, revised): graphite palette, corners by role (square structure, softened controls, rounder menus and dialogs with soft depth), borders only between layout regions, flat buttons with a visible focus ring, vibrant timeline blocks (mint artwork, violet tweens), sentence-case headings, **collapsible sections with rules** (Preferences, Properties, dock, shortcut sheet), **Lucide icons** stroked as vectors via a new full SVG path reader; click targets ≥ 28 px (tools 40, rows 28, toggles 24); palette contrast, target sizes and "no raw colours or radii" are enforced by tests. Product principles written (`docs/product-principles.md`). Tiered destructive-action confirmations, enforced in the engine (ADR 0004). Unsaved-changes guard on close/new/open. **Crash-recovery autosave** (ADR 0015): unsaved work is copied in the background (every minute or 25 changes by default; Preferences › Files › Autosave, with an off switch) to `Recovery` in the settings folder, atomically and never over the user's file; an OS file lock per running window tells crashed sessions from open ones; the next start offers what was left behind in a non-blocking window (Restore as unsaved work with its original path, Discard with a second click, Later; File › Recover Autosaved Documents… brings it back); saves and clean exits remove the copy; headless `file.recovery_list/recover/discard_recovery/autosave`. Not yet: several open documents, older copies, the undo history. Overwrite checks for saves and exports. "Ctrl+Z to undo" hints. Command palette (Ctrl+K). Shortcut sheet (F1). Right-click menus on stage, frames and layers. Save As (Ctrl+Shift+S). **Shortcut editor** (F1): every menu command, tool and view key can be rebound, given extra keys or unbound; recording asks before taking a key from another action, reserved keys (palette, editor, Preferences, quit, play, Esc, Space, Tab) stay fixed, per-action and global reset; only the changes are saved in preferences, so untouched actions follow new defaults; menus, tooltips and the palette show the keys in effect. | | Platforms & preferences | ADR 0006 platform layer: ⌘ shortcut labels and an AniCraft app menu with a unified title bar on macOS; Exit and Preferences (Ctrl+U) on Windows and Linux; native file dialogs (XDG portal on Linux, with a fallback switch); wgpu with automatic OpenGL fallback; per-OS settings folder. **Preferences** window: theme (Graphite or High contrast), interface and data fonts (bundled default or any installed font), interface scale (75–200 %), stage render mode, file dialogs, reset confirmations. Edits render live (fixed the missing-repaint bug). Not yet: native macOS NSMenu, macOS/Linux CI runners. Verified on Windows only so far. | @@ -33,7 +33,7 @@ milestone ends with a green tree: build, tests, clippy, a `--screenshot` check a | **M1** | Authoring core ✅ *(v0.1.0)* | ~~Free transform tool with handles~~ ✅; ~~subselection and Bézier point editing~~ ✅; ~~Pen and Pencil~~ ✅; ~~Paint bucket / Ink bottle~~ ✅; ~~copy/paste~~ ✅, ~~duplicate, arrange~~ ✅, ~~align~~ ✅ (commands and menus; and the dock's Align panel ✅); ~~onion skin~~ ✅ (basic); ~~frame selection ranges in the timeline (multi-frame insert/remove/move keyframes by drag)~~ ✅ (including between layers); ~~PNG sequence + animated GIF export~~ ✅; ~~keyboard shortcut map editor~~ ✅. | | **M2** | Model at scale | ~~`Arc` structural sharing (O(changed) undo)~~ done early (ADR 0001); ~~scenes~~ ✅ (ADR 0011); ~~layer folders~~ ✅, ~~guide and motion-guide layers~~ ✅; ~~mask layers~~ ✅; ~~Movie Clip and Button behaviours~~ ✅ (playback; button states and scripting come with M6); ~~group alpha / offscreen compositing~~ ✅; ~~shape tween~~ ✅, ~~shape hints~~ ✅ (ADR 0023); ~~motion tween + Motion Editor curves~~ ✅ first slice (ADR 0016); ~~motion paths on the stage with orient to path~~ ✅ first slice (ADR 0030; spatial keys, point add/delete, 3D and XFL import later); ~~MCP server~~ ✅; perf budgets ✅ (machine-independent ones gate every PR; timing via `bench --check` on a known machine, CI once a benchmark runner exists); ~~layering check~~ ✅ (`src/architecture_tests.rs`, runs with `cargo test`). | | **M3** | GPU stage *(in progress; the default stage renderer since ADR 0032)* | ~~wgpu renderer behind a feature flag~~ ✅ first slice (ADR 0019: the oracle's fills, CPU tile binning with backdrops, compute coverage; gradient tables in a storage buffer); ~~per-pixel parity tests vs the CPU oracle~~ ✅ (max 1/255, mean < 0.0001/255); ~~4K at 60 fps for 1,000 shapes~~ ✅ (8.8–9.0 ms); ~~no-readback textures, masks/groups/blend modes on the GPU~~ ✅ second slice (ADR 0029: window's device, 4K 10k shapes in 10.2 ms as tiles); GPU binning deferred (not the bottleneck as tiles); ~~bitmaps and filters on the GPU~~ ✅ third slice (ADR 0032: bitmaps byte-identical, filters max 1/255; 4K filtered sample 3.9 ms, 200 bitmaps 4.4 ms); ~~hardware breadth~~ ✅ Vulkan and DX12 (FXC), software adapters refused, oracle-checked self-test; ~~GPU as the default stage renderer~~ ✅ (`gpu-stage` on by default for the app, automatic CPU fallback); next: shared filtered layers across tiles, an image atlas, GPU exports. | -| **M4** | Interchange *(in progress)* | **XFL import** (DOMDocument.xml, symbols, edges/fill styles decoded from the public format descriptions) with a corpus of self-authored files: first slice ✅ (see Files above); ~~SVG import (Import to Stage)~~ ✅, ~~SVG frame export~~ ✅; ~~Lottie export~~ ✅ (frame-accurate; easing curves instead of per-frame keys later); ~~sprite sheet + JSON~~ ✅; ~~MP4/WebM via ffmpeg pipe~~ ✅. | +| **M4** | Interchange *(in progress)* | **XFL import** (DOMDocument.xml, symbols, edges/fill styles decoded from the public format descriptions) with a corpus of self-authored files: first slice ✅ (see Files above); ~~larger self-authored corpus with golden render tests~~ ✅ (ADR 0035: eleven packages covering every mapped feature, exact report expectations, hostile variants, CPU-oracle goldens); not yet: `.fla` variants of the corpus, sound and video items; ~~SVG import (Import to Stage)~~ ✅, ~~SVG frame export~~ ✅; ~~Lottie export~~ ✅ (frame-accurate; easing curves instead of per-frame keys later); ~~sprite sheet + JSON~~ ✅; ~~MP4/WebM via ffmpeg pipe~~ ✅. | | **M5** | Rich media | ~~Text engine~~ ✅ first slice (ADR 0012: `harfrust` shaping, `skrifa` outlines, line wrapping, outlines stored with the text; per-character styles, text on a path and input fields later); ~~bitmap import and bitmap fills~~ ✅; ~~audio layers, waveform display, stream sync~~ ✅ first slice (ADR 0020: WAV, Ogg Vorbis, MP3; `cpal` output; effects, volume and sounds in symbols later); ~~filters (blur, drop shadow, glow, colour matrix)~~ ✅, ~~bevel, gradient glow and gradient bevel~~ ✅ (ADR 0025; SVG export and XFL import; filter presets, reordering, on/off and tweened filter values later) and ~~blend modes~~ ✅ on Movie Clips. | | **M6** | Interactivity & extensibility | **Plug-ins: the Craft-family WebAssembly system** (same host model as PhotoCraft: `wasmi` sandbox, `plugin.*` commands; AniCraft ABI for vector/timeline operations and exporters): first slice ✅ (command plug-ins over the registry, ADR 0017; exporter and easing kinds later); ~~frame scripts on the same sandbox~~ ✅ and ~~button states in test-movie preview~~ ✅ first slice (ADR 0024: action IR, pure player, Actions panel, Test Movie); ~~HTML canvas runtime export~~ ✅ first slice (ADR 0028: one self-contained page, baked frames, a JS port of the player tested against it); command macros. **ActionScript compatibility, low priority** (ADR 0013), last in M6 and free to slip past M8: tier 1 keeps scripts (XFL frame scripts and class names stored verbatim, Actions panel, `script.*` commands); tier 2 runs the ActionScript 3 timeline subset (stop, play, go to frame or label, named instances, button events) in Test Movie and HTML canvas export through the same action IR as WebAssembly frame scripts. The full language, the `flash.*` API and SWF bytecode are not planned. | | **M7** | Advanced animation | Bone/IK tool; ~~camera layer with depth~~ ✅ first slice (ADR 0027: one camera layer per scene, pan/zoom/rotate/tint, classic and motion tweens, pan-only layer depth, Camera tool, Preview Through Camera, every export; not yet: editing while previewing, perspective depth, brightness/advanced colour, attaching layers to the camera, XFL camera import); ~~variable-width strokes~~ ✅ first slice (ADR 0018: width profiles, Width tool, exports, tweens); ~~Brush tool~~ ✅ first slice (ADR 0033: filled sweeps, tips, pressure, Paint Normal/Fills/Behind; not yet: Paint Selection/Inside, Eraser, Eyedropper) and brush library; asset warp; graph-based easing presets library. | @@ -80,8 +80,8 @@ Next, in order: 1. M4 **XFL import, next slices**: ~~masks (with M2 mask layers)~~ ✅, ~~shape tweens~~ ✅, ~~every scene~~ ✅, ~~bitmaps~~ ✅ (PNG/JPEG data), ~~text~~ ✅ (one style per line; per-character styles with - the text model), motion tweens, and a larger self-authored - corpus checked by render tests. + the text model), motion tweens, and ~~a larger self-authored + corpus checked by render tests~~ ✅ (ADR 0035). 2. ~~SVG import~~ ✅ and ~~SVG frame export~~ ✅, ~~text, clip paths and masks (onto mask layers)~~ ✅ (ADR 0021). Next for SVG: dashes, soft (luminance) masks, per-character text positions and text on a path. ## Risks From 3862732928bde8687a7448b52ab0b0f673cba6df Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Mon, 9 Nov 2026 22:18:41 -0700 Subject: [PATCH 6/8] feat(shell): Eraser (E) with erase modes, Faucet and Erase Everything, and Eyedropper (I) (M7) The Eraser sweeps the brush tip with a live preview in the stage colour, [ and ] size it, and a double-click on its tool button (or Erase Everything in its options) clears the stage at this frame after asking. The Eyedropper picks a fill (solid, gradient, bitmap) or a line into the tool style, applies it to selected shapes, then becomes the Paint Bucket or the Ink Bottle; Shift-click picks into the other swatch. New original icons; --open eraser|erasing|eyedropper for screenshots. --- assets/icons/anicraft-eraser.svg | 5 + assets/icons/anicraft-eyedropper.svg | 6 ++ src/a11y.rs | 2 +- src/app.rs | 48 +++++++++- src/brushtool.rs | 99 ++++++++++++-------- src/erasertool.rs | 131 +++++++++++++++++++++++++++ src/icons.rs | 12 ++- src/keymap.rs | 4 + src/main.rs | 3 +- src/panels.rs | 56 +++++++++++- src/stage.rs | 19 +++- 11 files changed, 340 insertions(+), 45 deletions(-) create mode 100644 assets/icons/anicraft-eraser.svg create mode 100644 assets/icons/anicraft-eyedropper.svg create mode 100644 src/erasertool.rs diff --git a/assets/icons/anicraft-eraser.svg b/assets/icons/anicraft-eraser.svg new file mode 100644 index 00000000..ab003160 --- /dev/null +++ b/assets/icons/anicraft-eraser.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/assets/icons/anicraft-eyedropper.svg b/assets/icons/anicraft-eyedropper.svg new file mode 100644 index 00000000..15242dab --- /dev/null +++ b/assets/icons/anicraft-eyedropper.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/a11y.rs b/src/a11y.rs index bc1095f0..38161b62 100644 --- a/src/a11y.rs +++ b/src/a11y.rs @@ -348,7 +348,7 @@ mod tests { fn every_interactive_node_has_a_name_and_a_role() { let mut found = Vec::new(); found.extend(check("default", |_, _| {})); - for tool in [Tool::Rect, Tool::Star, Tool::Text, Tool::Pencil, Tool::Brush, Tool::PaintBucket, Tool::InkBottle, Tool::Pen] { + for tool in [Tool::Rect, Tool::Star, Tool::Text, Tool::Pencil, Tool::Brush, Tool::Eraser, Tool::PaintBucket, Tool::InkBottle, Tool::Eyedropper, Tool::Pen] { found.extend(check(&format!("{tool:?} tool"), |a, _| a.tool = tool)); } for panel in ["select", "motion", "motionspan", "motionpath", "motionpoints", "camera", "cameraview", "sound", "prefs", "shortcuts", "palette", "about", "files", "licenses", "confirm", "recovery", "frames"] { diff --git a/src/app.rs b/src/app.rs index ef36be63..99a1fd52 100644 --- a/src/app.rs +++ b/src/app.rs @@ -20,12 +20,14 @@ pub enum Tool { Text, Pencil, Brush, + Eraser, Rect, Oval, Star, Line, PaintBucket, InkBottle, + Eyedropper, Camera, Hand, Zoom, @@ -63,7 +65,7 @@ impl GapSize { } impl Tool { - pub const ALL: [Tool; 17] = [Tool::Select, Tool::Subselect, Tool::Transform, Tool::Width, Tool::Pen, Tool::Text, Tool::Pencil, Tool::Brush, Tool::Rect, Tool::Oval, Tool::Star, Tool::Line, Tool::PaintBucket, Tool::InkBottle, Tool::Camera, Tool::Hand, Tool::Zoom]; + pub const ALL: [Tool; 19] = [Tool::Select, Tool::Subselect, Tool::Transform, Tool::Width, Tool::Pen, Tool::Text, Tool::Pencil, Tool::Brush, Tool::Eraser, Tool::Rect, Tool::Oval, Tool::Star, Tool::Line, Tool::PaintBucket, Tool::InkBottle, Tool::Eyedropper, Tool::Camera, Tool::Hand, Tool::Zoom]; pub fn label(self) -> &'static str { match self { @@ -75,12 +77,14 @@ impl Tool { Tool::Text => "Text", Tool::Pencil => "Pencil", Tool::Brush => "Brush", + Tool::Eraser => "Eraser", Tool::Rect => "Rectangle", Tool::Oval => "Oval", Tool::Star => "PolyStar", Tool::Line => "Line", Tool::PaintBucket => "Paint Bucket", Tool::InkBottle => "Ink Bottle", + Tool::Eyedropper => "Eyedropper", Tool::Camera => "Camera", Tool::Hand => "Hand", Tool::Zoom => "Zoom", @@ -97,12 +101,14 @@ impl Tool { Tool::Text => Some("T"), Tool::Pencil => Some("Shift+Y"), Tool::Brush => Some("B"), + Tool::Eraser => Some("E"), Tool::Rect => Some("R"), Tool::Oval => Some("O"), Tool::Star => None, Tool::Line => Some("N"), Tool::PaintBucket => Some("K"), Tool::InkBottle => Some("S"), + Tool::Eyedropper => Some("I"), Tool::Camera => Some("C"), Tool::Hand => Some("H"), Tool::Zoom => Some("Z"), @@ -116,6 +122,7 @@ impl Tool { Tool::Text => "Click to type new text, or click text to edit it. Esc or a click elsewhere finishes. The options set the font, size and colour; double-click text with the Selection tool to edit it too.", Tool::Pencil => "Drag to draw freehand. The options bar sets Smooth, Straighten or Ink.", Tool::Brush => "Drag to paint filled shapes in the fill colour (a click paints a dab). [ and ] change the size; the options set the shape, smoothing and paint mode.", + Tool::Eraser => "Drag to erase lines and fills drawn with Object Drawing off (drawing objects and symbols are kept). [ and ] change the size; the options set the shape and erase mode, and the Faucet deletes a whole fill or line with a click. Double-click the tool to erase everything on the stage.", Tool::Width => "Hover a stroke to see its width points. Drag a point's handle to widen or narrow the stroke there (Alt: one side only), drag its dot to slide it along, or drag anywhere on the stroke to add a point. Click a point and press Delete to remove it.", Tool::Transform => "Drag a corner or edge to scale (Shift keeps proportions, Alt scales from the centre), just outside a corner to rotate (Shift snaps 15°), inside to move.", Tool::Rect => "Drag to draw a rectangle. Shift draws a square.", @@ -124,6 +131,7 @@ impl Tool { Tool::Line => "Drag to draw a line. Shift snaps to 45°.", Tool::PaintBucket => "Click inside an outline to fill it (on the layer's lines), or on a fill to recolour it. The gap size closes small openings.", Tool::InkBottle => "Click a shape to give it the current stroke colour and width.", + Tool::Eyedropper => "Click a fill to pick its colour, gradient or bitmap (then pour it with the Paint Bucket), or a line to pick its colour, width and profile (then apply it with the Ink Bottle). With shapes selected, the picked style goes onto them. Shift-click picks into the other swatch only.", Tool::Camera => "Drag on the stage to pan the camera, drag the round handle to turn it, and use the wheel to zoom (each drag is one undo step). Picking the tool adds a camera if the scene has none.", Tool::Hand => "Drag to pan the stage. Space works with any tool.", Tool::Zoom => "Click to zoom in, Alt-click to zoom out. Ctrl+wheel zooms anywhere.", @@ -177,6 +185,8 @@ pub enum Drag { Pencil, /// Brush stroke; the samples are in `App::brush_samples`. Brush, + /// Eraser stroke; the samples are in `App::brush_samples` too (ADR 0034). + Eraser, /// Width tool: resizing (or sliding) width point `index` of shape `id`, found on subpath /// `sub`; `start` is its left and right width when the drag began. Width { id: anicraft_engine::doc::ElementId, sub: usize, index: usize, grip: crate::widthtool::Grip, start: (f32, f32) }, @@ -291,6 +301,8 @@ pub struct App { pub brush: crate::brushtool::BrushOptions, pub brush_samples: Vec<(anicraft_engine::geom::Vec2, Option)>, pub pen_pressure: Option, + /// Eraser tool options (ADR 0034); its stroke's samples are `brush_samples`. + pub eraser: crate::erasertool::EraserOptions, pub bucket_gap: GapSize, /// Align panel: align to the stage rather than the selection's bounds. pub align_to_stage: bool, @@ -443,6 +455,7 @@ impl App { brush: crate::brushtool::BrushOptions::default(), brush_samples: Vec::new(), pen_pressure: None, + eraser: crate::erasertool::EraserOptions::default(), bucket_gap: GapSize::default(), align_to_stage: false, points: Vec::new(), @@ -777,6 +790,35 @@ impl App { self.drag = Drag::Brush; } } + Some(which @ ("eraser" | "erasing")) => { + // Erased artwork on a new layer (ADR 0034): a band through an outlined raw + // rectangle (Erase Normal), the outline of a raw oval erased but not its fill + // (Erase Lines), a fill deleted by the Faucet, and a drawing object the eraser + // passed over untouched; "erasing" also has a stroke in progress. + self.run("layer.new", json!({"name": "Ink"})); + self.run("draw.object_drawing", json!({"on": false})); + self.run("draw.rect", json!({"x": 140, "y": 150, "w": 380, "h": 230, "fill": "#f2c14e", "stroke": "#1b2a4a", "stroke_width": 4})); + let band: Vec<[f32; 2]> = (0..=80).map(|i| [100.0 + i as f32 * 5.5, 265.0 + (i as f32 * 0.12).sin() * 60.0]).collect(); + self.run("draw.erase", json!({"points": band, "size": 30})); + self.run("draw.ellipse", json!({"x": 600, "y": 160, "w": 260, "h": 200, "fill": "#3d8bfd", "stroke": "#1b2a4a", "stroke_width": 6})); + self.run("draw.erase", json!({"points": [[560, 260], [900, 260]], "size": 40, "mode": "lines"})); + self.run("draw.rect", json!({"x": 940, "y": 160, "w": 200, "h": 200, "fill": "#e8553b", "stroke": "#1b2a4a", "stroke_width": 4})); + self.run("draw.faucet", json!({"x": 1040, "y": 260})); + self.run("draw.rect", json!({"x": 300, "y": 430, "w": 300, "h": 120, "fill": "#8a79c9", "stroke": null, "object": true})); + self.run("draw.erase", json!({"points": [[260, 490], [640, 490]], "size": 30})); + self.run("edit.deselect", json!({})); + self.tool = Tool::Eraser; + self.eraser = crate::erasertool::EraserOptions { size: 30.0, ..Default::default() }; + if which == "erasing" { + self.brush_samples = (0..=40).map(|i| (anicraft_engine::geom::Vec2::new(700.0 + i as f32 * 9.0, 470.0 - (i as f32 * 0.2).sin() * 40.0), None)).collect(); + self.drag = Drag::Eraser; + } + } + Some("eyedropper") => { + // The sample's sky gradient picked with the Eyedropper: the fill swatch holds it. + self.run("paint.pick", json!({"x": 640, "y": 40})); + self.tool = Tool::Eyedropper; + } Some("frames") => { // Frames 8–20 selected on the top three layers, with a keyframe drag in progress: // 6 frames later and one layer down. @@ -1055,6 +1097,10 @@ impl App { "edit.redo" => self.status_ok(format!("Redid {}", v["redone"].as_str().unwrap_or(""))), "edit.delete" => self.status_ok(format!("Deleted {} {} — Ctrl+Z to undo", selected, if selected == 1 { "element" } else { "elements" })), "layer.delete" => self.status_ok("Deleted layer — Ctrl+Z to undo"), + "draw.erase_all" => { + let n = v["erased"].as_u64().unwrap_or(0); + self.status_ok(format!("Erased everything at frame {} ({n} {}). {} to undo.", self.s.frame + 1, if n == 1 { "element" } else { "elements" }, platform::shortcut_label("Ctrl+Z"))); + } "scene.delete" => { self.frame_sel = None; self.status_ok("Deleted scene — Ctrl+Z to undo"); diff --git a/src/brushtool.rs b/src/brushtool.rs index 567614ea..8a0eafc6 100644 --- a/src/brushtool.rs +++ b/src/brushtool.rs @@ -39,7 +39,7 @@ pub const SIZE_MAX: f32 = 400.0; impl BrushOptions { /// The tip mapped onto the stage, for previews: unit circle or square → the tip at `at`. - fn tip_to_stage(&self, at: Vec2, factor: f32) -> Affine { + pub fn tip_to_stage(&self, at: Vec2, factor: f32) -> Affine { let tip = anicraft_engine::geom::brush::Tip { shape: self.shape, size: self.size * factor, angle: self.angle, roundness: self.roundness / 100.0 }; Affine::translate(at.x, at.y).mul(&tip.to_stage()) } @@ -63,13 +63,19 @@ pub fn step_size(size: f32, larger: bool) -> f32 { ((next / g).round() * g).clamp(SIZE_MIN, SIZE_MAX) } -/// Changes the size from the keyboard and says so. +/// Changes the Brush's or the Eraser's size from the keyboard and says so. pub fn resize(app: &mut App, larger: bool) { - if app.tool != Tool::Brush { - return; + match app.tool { + Tool::Brush => { + app.brush.size = step_size(app.brush.size, larger); + app.status_ok(format!("Brush size {} px", app.brush.size)); + } + Tool::Eraser => { + app.eraser.size = step_size(app.eraser.size, larger); + app.status_ok(format!("Eraser size {} px", app.eraser.size)); + } + _ => {} } - app.brush.size = step_size(app.brush.size, larger); - app.status_ok(format!("Brush size {} px", app.brush.size)); } /// The pen's pressure this frame, when a tablet reports it (egui gives it with touch events). @@ -89,6 +95,20 @@ pub fn start(app: &mut App, p: Vec2, pressure: Option) -> Drag { Drag::Brush } +/// The stroke's samples as command points (with pressure when a pen gave any). +pub fn points(samples: &[(Vec2, Option)]) -> Vec { + let pen = samples.iter().any(|(_, p)| p.is_some()); + samples.iter().map(|(v, p)| if pen { json!([v.x, v.y, p.unwrap_or(1.0)]) } else { json!([v.x, v.y]) }).collect() +} + +/// A tip shape's name in commands. +pub fn shape_key(s: TipShape) -> &'static str { + match s { + TipShape::Round => "round", + TipShape::Square => "square", + } +} + /// Adds a sample (closer than half a screen point adds nothing unless the pressure moved). pub fn sample(app: &mut App, p: Vec2, pressure: Option, xf: Xf) { if pressure.is_some() { @@ -107,14 +127,9 @@ pub fn commit(app: &mut App, xf: Xf) { if samples.is_empty() { return; } - let pen = samples.iter().any(|(_, p)| p.is_some()); - let points: Vec = samples.iter().map(|(v, p)| if pen { json!([v.x, v.y, p.unwrap_or(1.0)]) } else { json!([v.x, v.y]) }).collect(); + let points = points(&samples); let o = app.brush; - let shape = match o.shape { - TipShape::Round => "round", - TipShape::Square => "square", - }; - let params = json!({"points": points, "size": o.size, "shape": shape, "angle": o.angle, "roundness": o.roundness, "smoothing": o.smoothing, "mode": o.mode.key(), "unit": xf.unit()}); + let params = json!({"points": points, "size": o.size, "shape": shape_key(o.shape), "angle": o.angle, "roundness": o.roundness, "smoothing": o.smoothing, "mode": o.mode.key(), "unit": xf.unit()}); if let Some(v) = app.run("draw.brush", params) && v["elements"].as_array().is_some_and(Vec::is_empty) { @@ -159,38 +174,50 @@ pub fn draw_overlay(app: &App, painter: &egui::Painter, xf: Xf, hover: Option)], color: egui::Color32) { + if samples.is_empty() { + return; + } let unit = o.unit_outline(); let screen = |at: Vec2, pressure: Option| -> Vec { let m = o.tip_to_stage(at, size_factor(pressure.unwrap_or(1.0))); unit.iter().map(|u| xf.to_screen(m.apply(*u))).collect() }; - if app.drag == Drag::Brush && !app.brush_samples.is_empty() { - // Opaque, so overlapping pieces don't darken each other. - let color = to_color32(anicraft_engine::doc::Rgba { a: 1.0, ..app.s.style.fill }); - let step = app.brush_samples.len().div_ceil(MAX_PREVIEW).max(1); - let picked: Vec<&(Vec2, Option)> = app.brush_samples.iter().step_by(step).chain(app.brush_samples.last()).collect(); - if let [only] = picked.as_slice() { - painter.add(egui::Shape::convex_polygon(hull(screen(only.0, only.1)), color, Stroke::NONE)); - } - for pair in picked.windows(2) { - let &[a, b] = pair else { continue }; - let mut pts = screen(a.0, a.1); - pts.extend(screen(b.0, b.1)); - painter.add(egui::Shape::convex_polygon(hull(pts), color, Stroke::NONE)); - } + let step = samples.len().div_ceil(MAX_PREVIEW).max(1); + let picked: Vec<&(Vec2, Option)> = samples.iter().step_by(step).chain(samples.last()).collect(); + if let [only] = picked.as_slice() { + painter.add(egui::Shape::convex_polygon(hull(screen(only.0, only.1)), color, Stroke::NONE)); } - if let Some(h) = hover { - // The tip's size and shape at the pointer, as Animate shows it. - let at = xf.to_stage(h); - let mut outline = screen(at, None); - if let Some(first) = outline.first().copied() { - outline.push(first); - } - painter.add(egui::Shape::line(outline, Stroke::new(1.0, T.selection))); + for pair in picked.windows(2) { + let &[a, b] = pair else { continue }; + let mut pts = screen(a.0, a.1); + pts.extend(screen(b.0, b.1)); + painter.add(egui::Shape::convex_polygon(hull(pts), color, Stroke::NONE)); } } +/// The tip's outline at stage point `at`. +pub fn draw_tip(painter: &egui::Painter, xf: Xf, o: &BrushOptions, at: Vec2) { + let m = o.tip_to_stage(at, 1.0); + let mut outline: Vec = o.unit_outline().iter().map(|u| xf.to_screen(m.apply(*u))).collect(); + if let Some(first) = outline.first().copied() { + outline.push(first); + } + painter.add(egui::Shape::line(outline, Stroke::new(1.0, T.selection))); +} + #[cfg(test)] mod tests { use super::*; diff --git a/src/erasertool.rs b/src/erasertool.rs new file mode 100644 index 00000000..8d270b4b --- /dev/null +++ b/src/erasertool.rs @@ -0,0 +1,131 @@ +//! The Eraser (E) and the Eyedropper (I), ADR 0034: view state over `draw.erase`, `draw.faucet` +//! and `paint.pick`. An eraser drag collects samples like the Brush, shows the stage colour +//! where it goes and sends one command when the pointer lifts, so a stroke is one undo step. + +use crate::app::{App, Drag, Tool}; +use crate::brushtool::{BrushOptions, draw_sweep, draw_tip, points, shape_key}; +use crate::pathtools::Xf; +use crate::theme::to_color32; +use anicraft_engine::cmds_erase::EraseMode; +use anicraft_engine::doc::ElementKind; +use anicraft_engine::geom::Vec2; +use anicraft_engine::geom::brush::TipShape; +use egui::Pos2; +use serde_json::json; + +/// The Eraser's options (view state: the tool's, not the document's). +#[derive(Clone, Copy, Debug, PartialEq)] +pub struct EraserOptions { + /// Diameter (or side), stage units. + pub size: f32, + pub shape: TipShape, + pub mode: EraseMode, + /// The Faucet: a click deletes a whole fill or line. + pub faucet: bool, +} + +impl Default for EraserOptions { + fn default() -> Self { + EraserOptions { size: 16.0, shape: TipShape::Round, mode: EraseMode::Normal, faucet: false } + } +} + +impl EraserOptions { + /// The tip as the Brush draws it (for the shared previews). + fn tip(&self) -> BrushOptions { + BrushOptions { size: self.size, shape: self.shape, ..BrushOptions::default() } + } +} + +/// Starts an eraser stroke at stage point `p` (the eraser ignores pen pressure). +pub fn start(app: &mut App, p: Vec2) -> Drag { + app.pen_pressure = None; + app.brush_samples = vec![(p, None)]; + Drag::Eraser +} + +/// Sends the stroke: one command, one undo step. +pub fn commit(app: &mut App, xf: Xf) { + let samples = std::mem::take(&mut app.brush_samples); + if samples.is_empty() { + return; + } + let o = app.eraser; + let params = json!({"points": points(&samples), "size": o.size, "shape": shape_key(o.shape), "mode": o.mode.key(), "unit": xf.unit()}); + let undo = crate::platform::shortcut_label("Ctrl+Z"); + match app.run("draw.erase", params) { + Some(v) if v["erased"] == true => app.status_ok(format!("Erased. {undo} to undo.")), + Some(v) => { + let why = v["reason"].as_str().unwrap_or("nothing to erase there"); + app.status_ok(format!("Nothing erased: {why}. The eraser works on lines and fills drawn with Object Drawing off; drawing objects and symbols are kept.")); + } + None => {} + } +} + +/// The Faucet: deletes the whole fill or line under the click. +pub fn faucet(app: &mut App, p: Vec2, zoom: f32) { + if let Some(v) = app.run("draw.faucet", json!({"x": p.x, "y": p.y, "slop": 4.0 / zoom.max(1e-3)})) { + let what = if v["kind"] == "line" { "line" } else { "fill" }; + app.status_ok(format!("Deleted the {what}. {} to undo.", crate::platform::shortcut_label("Ctrl+Z"))); + } +} + +/// Double-clicking the Eraser tool: erase everything on the stage at this frame (asks first). +pub fn erase_everything(app: &mut App) { + // The engine asks only when there is something to erase. + if app.s.confirmation("draw.erase_all", &json!({})).is_none() { + app.status_ok("Nothing to erase: the visible, unlocked layers are empty at this frame."); + return; + } + app.request("draw.erase_all", json!({})); +} + +/// The stroke as it goes (in the stage colour, as if erased) and the tip under the pointer. +pub fn draw_overlay(app: &App, painter: &egui::Painter, xf: Xf, hover: Option) { + if app.tool != Tool::Eraser { + return; + } + let tip = app.eraser.tip(); + if app.drag == Drag::Eraser { + let bg = to_color32(anicraft_engine::doc::Rgba { a: 1.0, ..app.s.doc.stage.background }); + draw_sweep(painter, xf, &tip, &app.brush_samples, bg); + } + if let Some(h) = hover + && !app.eraser.faucet + { + draw_tip(painter, xf, &tip, xf.to_stage(h)); + } +} + +/// The Eyedropper's click. It picks the fill or line under the point into the tool settings +/// (Shift: into the other swatch only). As in Animate, it then becomes the Paint Bucket (a +/// fill) or the Ink Bottle (a line), and with shapes selected it gives them the picked style. +pub fn eyedropper(app: &mut App, p: Vec2, shift: bool, zoom: f32) { + let Some(v) = app.run("paint.pick", json!({"x": p.x, "y": p.y, "other": shift, "slop": 3.0 / zoom.max(1e-3)})) else { return }; + let color = v["color"].as_str().unwrap_or("").to_string(); + let into_fill = v["into"] == "fill"; + if shift { + app.status_ok(format!("Picked {color} into the {} colour.", if into_fill { "fill" } else { "stroke" })); + return; + } + let what = match v["paint"].as_str() { + Some("linear") => "linear gradient".to_string(), + Some("radial") => "radial gradient".to_string(), + Some("bitmap") => "bitmap fill".to_string(), + _ if into_fill => format!("fill {color}"), + _ => format!("line {color}, {} px", v["width"].as_f64().map_or(String::new(), |w| format!("{w:.1}"))), + }; + let sel = &app.s.selection; + let shapes = app.s.visible_elements().iter().filter(|e| sel.contains(&e.id) && matches!(e.kind, ElementKind::Shape(_))).count(); + if shapes > 0 { + if let Some(r) = app.run("paint.apply_style", json!({"fill": into_fill, "stroke": !into_fill})) { + let n = r["changed"].as_u64().unwrap_or(0); + app.status_ok(format!("Applied the picked {what} to {n} {}. {} to undo.", if n == 1 { "shape" } else { "shapes" }, crate::platform::shortcut_label("Ctrl+Z"))); + } + } else { + let next = if into_fill { "Click a fill or an enclosed area to pour it" } else { "Click a shape to give it this line" }; + app.status_ok(format!("Picked the {what}. {next}.")); + } + app.tool = if into_fill { Tool::PaintBucket } else { Tool::InkBottle }; +} diff --git a/src/icons.rs b/src/icons.rs index dac0243d..04f8fc9c 100644 --- a/src/icons.rs +++ b/src/icons.rs @@ -20,6 +20,8 @@ pub enum Icon { Pen, Pencil, Brush, + Eraser, + Eyedropper, Rect, Oval, PolyStar, @@ -66,7 +68,7 @@ pub enum Icon { impl Icon { #[cfg(test)] - pub const ALL: [Icon; 48] = [ + pub const ALL: [Icon; 50] = [ Icon::Camera, Icon::Width, Icon::Sound, @@ -93,6 +95,8 @@ impl Icon { Icon::Pen, Icon::Pencil, Icon::Brush, + Icon::Eraser, + Icon::Eyedropper, Icon::Rect, Icon::Oval, Icon::PolyStar, @@ -136,6 +140,10 @@ impl Icon { Icon::Pencil => ("pencil", false), // A round brush: handle, ferrule and a painted tip (AniCraft original, on Lucide's grid). Icon::Brush => ("anicraft-brush", false), + // A block eraser on its edge, its sleeve marked off (AniCraft original). + Icon::Eraser => ("anicraft-eraser", false), + // A dropper: bulb, collar, glass tube and a drop (AniCraft original). + Icon::Eyedropper => ("anicraft-eyedropper", false), Icon::Rect => ("rectangle-horizontal", false), Icon::Oval => ("circle", false), Icon::PolyStar => ("pentagon", false), @@ -228,6 +236,8 @@ static FILES: &[(&str, &str)] = &[ ("anicraft-mask", include_str!("../assets/icons/anicraft-mask.svg")), ("anicraft-width", include_str!("../assets/icons/anicraft-width.svg")), ("anicraft-brush", include_str!("../assets/icons/anicraft-brush.svg")), + ("anicraft-eraser", include_str!("../assets/icons/anicraft-eraser.svg")), + ("anicraft-eyedropper", include_str!("../assets/icons/anicraft-eyedropper.svg")), ("anicraft-masked", include_str!("../assets/icons/anicraft-masked.svg")), ("anicraft-camera", include_str!("../assets/icons/anicraft-camera.svg")), ("folder", include_str!("../assets/icons/folder.svg")), diff --git a/src/keymap.rs b/src/keymap.rs index 75597da7..5d47a49a 100644 --- a/src/keymap.rs +++ b/src/keymap.rs @@ -51,12 +51,14 @@ pub fn tool_id(t: Tool) -> &'static str { Tool::Text => "tool.text", Tool::Pencil => "tool.pencil", Tool::Brush => "tool.brush", + Tool::Eraser => "tool.eraser", Tool::Rect => "tool.rectangle", Tool::Oval => "tool.oval", Tool::Star => "tool.polystar", Tool::Line => "tool.line", Tool::PaintBucket => "tool.paint_bucket", Tool::InkBottle => "tool.ink_bottle", + Tool::Eyedropper => "tool.eyedropper", Tool::Camera => "tool.camera", Tool::Hand => "tool.hand", Tool::Zoom => "tool.zoom", @@ -360,6 +362,8 @@ mod tests { assert_eq!(m.keys("edit.delete"), ["Delete", "Backspace"], "aliases are second keys"); assert_eq!(m.primary("tool.pen"), Some("P")); assert_eq!(m.primary("tool.brush"), Some("B")); + assert_eq!(m.primary("tool.eraser"), Some("E")); + assert_eq!(m.primary("tool.eyedropper"), Some("I")); assert_eq!(m.keys("view.brush_smaller"), ["["]); assert_eq!(m.keys("view.brush_larger"), ["]"]); assert_eq!(m.primary("view.onion"), Some("Alt+Shift+O")); diff --git a/src/main.rs b/src/main.rs index 4ed1a90f..7eb15402 100644 --- a/src/main.rs +++ b/src/main.rs @@ -17,6 +17,7 @@ mod actions_panel; mod app; mod autosave; mod brushtool; +mod erasertool; mod camera_tool; mod dialogs; mod gpu_stage; @@ -136,7 +137,7 @@ fn main() -> eframe::Result { } "--help" | "-h" => { println!( - "anicraft [file.anicraft|file.fla|file.xfl] [--version] [--screenshot out.png] [--renderer wgpu|gl] [--theme graphite|high-contrast] [--scale ] [--open palette|shortcuts|lastscene|select|about|files|confirm|transform|points|merge|brush|brushing|pen|frames|span|bucket|tlzoom|tlwide|motion|motionspan|motionpath|motionpoints|hints|hintsend|camera|cameraview|filters|prefs|licenses|zoom|recovery|plugins|actions|testmovie|exporthtml]\n\ + "anicraft [file.anicraft|file.fla|file.xfl] [--version] [--screenshot out.png] [--renderer wgpu|gl] [--theme graphite|high-contrast] [--scale ] [--open palette|shortcuts|lastscene|select|about|files|confirm|transform|points|merge|brush|brushing|eraser|erasing|eyedropper|pen|frames|span|bucket|tlzoom|tlwide|motion|motionspan|motionpath|motionpoints|hints|hintsend|camera|cameraview|filters|prefs|licenses|zoom|recovery|plugins|actions|testmovie|exporthtml]\n\ --renderer force the GPU backend (also ANICRAFT_RENDERER); default wgpu, falling back to OpenGL\n\ --open shows a panel at start (handy with --screenshot for visual checks)\n\ ANICRAFT_STAGE_RENDERER=gpu|cpu stage renderer (default gpu, falling back to cpu; ADR 0032)\n\ diff --git a/src/panels.rs b/src/panels.rs index f6b3442b..3d66b91b 100644 --- a/src/panels.rs +++ b/src/panels.rs @@ -22,12 +22,14 @@ fn tool_icon(tool: Tool) -> Icon { Tool::Text => Icon::Type, Tool::Pencil => Icon::Pencil, Tool::Brush => Icon::Brush, + Tool::Eraser => Icon::Eraser, Tool::Rect => Icon::Rect, Tool::Oval => Icon::Oval, Tool::Star => Icon::PolyStar, Tool::Line => Icon::Line, Tool::PaintBucket => Icon::Bucket, Tool::InkBottle => Icon::Ink, + Tool::Eyedropper => Icon::Eyedropper, Tool::Camera => Icon::Camera, Tool::Hand => Icon::Hand, Tool::Zoom => Icon::Zoom, @@ -66,10 +68,15 @@ fn tool_column(app: &mut App, ui: &mut egui::Ui, area: Rect) { if active { a11y::anchor(ui, a11y::Region::Tools, area, &resp); } - if resp.on_hover_text(format!("{name}\n{}", tool.hint())).clicked() { + let resp = resp.on_hover_text(format!("{name}\n{}", tool.hint())); + if resp.clicked() { app.tool = tool; } - if matches!(tool, Tool::Width | Tool::Brush | Tool::Line | Tool::InkBottle) { + // Animate: double-clicking the Eraser erases everything on the stage (it asks first). + if tool == Tool::Eraser && resp.double_clicked() { + crate::erasertool::erase_everything(app); + } + if matches!(tool, Tool::Width | Tool::Eraser | Tool::Line | Tool::Eyedropper) { // Tool groups: select, draw by hand, shapes, view. ui.add_space(3.0); let y = ui.cursor().top(); @@ -334,7 +341,7 @@ fn properties(app: &mut App, ui: &mut egui::Ui) { let sel: Vec<_> = elements.iter().filter(|e| app.s.selection.contains(&e.id)).cloned().collect(); // ---- tool options first while a drawing tool is in hand: they're what you reach for ---- - if matches!(app.tool, Tool::Rect | Tool::Oval | Tool::Star | Tool::Line | Tool::Pen | Tool::Text | Tool::Pencil | Tool::Brush | Tool::PaintBucket | Tool::InkBottle) { + if matches!(app.tool, Tool::Rect | Tool::Oval | Tool::Star | Tool::Line | Tool::Pen | Tool::Text | Tool::Pencil | Tool::Brush | Tool::Eraser | Tool::PaintBucket | Tool::InkBottle | Tool::Eyedropper) { let title = format!("{} tool", app.tool.label()); section(ui, "prop_tool", Section::Rule, &title, None, |ui| tool_props(app, ui)); } @@ -1230,6 +1237,10 @@ fn sound_rows(app: &mut App, ui: &mut egui::Ui, current: Option>().join(" / "); + let o = &mut app.eraser; + row_prose(ui, "Faucet", |ui| { + crate::theme::checkbox(ui, &mut o.faucet, "Delete whole fills and lines").on_hover_text("On: a click deletes the whole fill or line under it. Off: drag to erase"); + }); + ui.add_enabled_ui(!o.faucet, |ui| { + row(ui, "Size", |ui| { + let r = ui.add(egui::DragValue::new(&mut o.size).suffix(" px").speed(0.25).range(SIZE_MIN..=SIZE_MAX).max_decimals(1)).named("Eraser size"); + if !keys.is_empty() { + r.on_hover_text(format!("Eraser size ({keys})")); + } + }); + row(ui, "Shape", |ui| { + for (shape, label, hint) in [(TipShape::Round, "Round", "A round eraser"), (TipShape::Square, "Square", "A square eraser")] { + ui.selectable_value(&mut o.shape, shape, label).on_hover_text(hint); + } + }); + row_prose(ui, "Mode", |ui| { + egui::ComboBox::from_id_salt("erase_mode").width(170.0).selected_text(o.mode.label()).show_ui(ui, |ui| { + for m in EraseMode::ALL { + ui.selectable_value(&mut o.mode, m, m.label()).on_hover_text(m.hint()); + } + }) + .response + .set_name("Erase mode"); + }); + }); + row_prose(ui, "Stage", |ui| { + if ui.button("Erase Everything…").on_hover_text("Clears every visible, unlocked layer at this frame, as double-clicking the Eraser tool does. You can undo it").clicked() { + crate::erasertool::erase_everything(app); + } + }); +} + /// The Brush tool's options (ADR 0033): what Animate's brush offers in its options. fn brush_props(app: &mut App, ui: &mut egui::Ui) { use crate::brushtool::{SIZE_MAX, SIZE_MIN}; diff --git a/src/stage.rs b/src/stage.rs index a89fd6d9..3f3f7ac1 100644 --- a/src/stage.rs +++ b/src/stage.rs @@ -310,7 +310,7 @@ pub fn show(app: &mut App, ui: &mut egui::Ui) { None => CursorIcon::Default, } } - Tool::Rect | Tool::Oval | Tool::Star | Tool::Line | Tool::Pen | Tool::Pencil | Tool::Brush | Tool::PaintBucket | Tool::InkBottle => CursorIcon::Crosshair, + Tool::Rect | Tool::Oval | Tool::Star | Tool::Line | Tool::Pen | Tool::Pencil | Tool::Brush | Tool::Eraser | Tool::PaintBucket | Tool::InkBottle | Tool::Eyedropper => CursorIcon::Crosshair, Tool::Text => CursorIcon::Text, Tool::Zoom => { if alt { @@ -386,7 +386,9 @@ pub fn show(app: &mut App, ui: &mut egui::Ui) { Drag::Pencil } Tool::Brush => crate::brushtool::start(app, to_v(sp), pressure), - Tool::Pen | Tool::Text | Tool::PaintBucket | Tool::InkBottle => Drag::None, + // With the Faucet on, the eraser deletes on a click instead. + Tool::Eraser if !app.eraser.faucet => crate::erasertool::start(app, to_v(sp)), + Tool::Pen | Tool::Text | Tool::PaintBucket | Tool::InkBottle | Tool::Eyedropper | Tool::Eraser => Drag::None, Tool::Rect | Tool::Oval | Tool::Star | Tool::Line => Drag::Shape { start: sp, cur: sp }, Tool::Camera => crate::camera_tool::drag_start(app, &cam_geo, press), Tool::Hand => Drag::Pan, @@ -451,6 +453,7 @@ pub fn show(app: &mut App, ui: &mut egui::Ui) { } (Drag::Pencil, Some(c)) => crate::pathtools::pencil_sample(app, to_v(c), xf), (Drag::Brush, Some(c)) => crate::brushtool::sample(app, to_v(c), pressure, xf), + (Drag::Eraser, Some(c)) => crate::brushtool::sample(app, to_v(c), None, xf), (Drag::Marquee { cur: m, .. }, Some(c)) => *m = c, (Drag::Shape { start, cur: m }, Some(c)) => *m = constrain(app.tool, *start, c, shift), _ => {} @@ -469,6 +472,7 @@ pub fn show(app: &mut App, ui: &mut egui::Ui) { Drag::PointMarquee { start, cur } => crate::pathtools::marquee_points(app, start, cur, shift), Drag::Pencil => crate::pathtools::commit_pencil(app, xf), Drag::Brush => crate::brushtool::commit(app, xf), + Drag::Eraser => crate::erasertool::commit(app, xf), Drag::Marquee { start, cur } => { let r = Rect::from_two_pos(start, cur); let ids: Vec = app @@ -515,6 +519,16 @@ pub fn show(app: &mut App, ui: &mut egui::Ui) { crate::brushtool::start(app, to_v(sp), pressure); crate::brushtool::commit(app, xf); } + Tool::Eraser if !panning => { + if app.eraser.faucet { + crate::erasertool::faucet(app, to_v(sp), zoom); + } else { + // A click erases a dab. + crate::erasertool::start(app, to_v(sp)); + crate::erasertool::commit(app, xf); + } + } + Tool::Eyedropper if !panning => crate::erasertool::eyedropper(app, to_v(sp), shift, zoom), Tool::InkBottle if !panning => { app.run("paint.ink", json!({"x": sp.x, "y": sp.y, "slop": 4.0 / zoom.max(1e-3)})); } @@ -851,6 +865,7 @@ pub fn show(app: &mut App, ui: &mut egui::Ui) { crate::pathtools::draw_overlay(app, &painter, xf, pointer.filter(|p| canvas.contains(*p))); crate::widthtool::draw_overlay(app, &painter, xf, pointer.filter(|p| canvas.contains(*p))); crate::brushtool::draw_overlay(app, &painter, xf, pointer.filter(|p| canvas.contains(*p) && !panning && !paused)); + crate::erasertool::draw_overlay(app, &painter, xf, pointer.filter(|p| canvas.contains(*p) && !panning && !paused)); // After this frame's edits, so a drag on the path shows where it is now. if !preview && let Some(shown) = crate::motion_path::shown(app) From 690e0311f4d8a084d9ab05f7dc969fd1bbf5f8bf Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Mon, 9 Nov 2026 22:21:07 -0700 Subject: [PATCH 7/8] docs: Eraser and Eyedropper ADR 0034, roadmap, changelog and attribution (M7) --- ATTRIBUTION.md | 3 +- CHANGELOG.md | 20 ++++ docs/adr/0034-eraser-and-eyedropper.md | 143 +++++++++++++++++++++++++ docs/roadmap.md | 6 +- 4 files changed, 168 insertions(+), 4 deletions(-) create mode 100644 docs/adr/0034-eraser-and-eyedropper.md diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index 41c168d9..9f8367a3 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -19,7 +19,7 @@ shaders or SDK code). | Hack Regular (via `epaint_default_fonts`) | UI monospace font | Source Foundry Authors; Bitstream (Vera) | | MIT + Bitstream Vera licence, [`licenses/fonts/LICENSE-Hack.txt`](licenses/fonts/LICENSE-Hack.txt) | | Noto Emoji (via `epaint_default_fonts`) | Symbol fallback | Google | | SIL OFL 1.1, [`licenses/fonts/OFL-1.1-NotoEmoji.txt`](licenses/fonts/OFL-1.1-NotoEmoji.txt) | | emoji-icon-font (via `epaint_default_fonts`) | Symbol fallback | John Slegers | | MIT, [`licenses/fonts/LICENSE-emoji-icon-font.txt`](licenses/fonts/LICENSE-emoji-icon-font.txt) | -| `assets/icons/anicraft-*.svg` (13 files: align, distribute, mask and masked layer, width tool, camera, brush) | Align panel, layer-type, Width tool, Camera and Brush tool icons | AniCraft contributors | Original work, drawn on Lucide's 24-unit grid and stroke style | MIT OR Apache-2.0 | +| `assets/icons/anicraft-*.svg` (15 files: align, distribute, mask and masked layer, width tool, camera, brush, eraser, eyedropper) | Align panel, layer-type, Width tool, Camera, Brush, Eraser and Eyedropper tool icons | AniCraft contributors | Original work, drawn on Lucide's 24-unit grid and stroke style | MIT OR Apache-2.0 | | `crates/svg/fixtures/clips-masks-text.svg` | SVG import test drawing (clip paths, a mask, text) | AniCraft contributors | Original work | MIT OR Apache-2.0 | | `assets/icons/*.svg` except `anicraft-*` (33 files: tools, transport, layer toggles, folders, guide, image, text, sound, chevrons) | UI icons, stroked by `src/icons.rs` | Lucide Icons and Contributors (some derived from Feather by Cole Bemis) | (`icons/.svg`), copied unchanged from the PhotoCraft sibling project's set (`volume-2.svg` from Lucide 0.512.0) | ISC (Lucide) and MIT (Feather), [`licenses/icons/LICENSE-lucide.txt`](licenses/icons/LICENSE-lucide.txt) | | `assets/app-icon/` (`anicraft.svg`, `anicraft-small.svg` and every render: PNGs, `anicraft.ico`, `hicolor/`) | App icon (engraved rabbit): window, Dock, taskbar, `anicraft.exe`, Help › About | Project owner (ArtCraft team) | Original artwork drawn in ArtCraft for AniCraft, vectorised by `assets/app-icon/trace.py` and rendered by `scripts/icons.sh` | MIT OR Apache-2.0 ([`assets/app-icon/LICENSE.txt`](assets/app-icon/LICENSE.txt)) | @@ -95,6 +95,7 @@ OR Apache-2.0) is noted in the table. | Monotone cubic interpolation of stroke widths (width profiles) | `crates/doc/src/width.rs` | F. N. Fritsch and R. E. Carlson, *Monotone Piecewise Cubic Interpolation*, SIAM J. Numer. Anal. 17(2), 1980 | Published algorithm (harmonic-mean tangents). | | Variable-width stroke outlines (trapezoids, outer round joins, caps) | `crates/render/src/stroke.rs` | Standard stroking construction from the public computer-graphics literature | Own implementation (ADR 0018); built-in profiles are AniCraft's own. | | Brush outlines (the swept tip as a signed distance field: exact distance to the convex hull of two tips, L2 for round and L∞ for square tips, minimised in closed form; traced at level zero) | `crates/geom/src/brush.rs` | Standard sweep and distance-field constructions from the public computer-graphics literature; behaviour of Animate's Brush tool learned from Adobe's public help and observation | Own implementation (ADR 0033); no Adobe code or presets. | +| Eraser (the swept tip as a fill in the planar merge whose regions are dropped; exact fill areas by Green's theorem with five-point Gauss–Legendre quadrature) and Eyedropper | `crates/engine/src/cmds_erase.rs`, `crates/engine/src/cmds_paint.rs` | Green's theorem and Gauss–Legendre quadrature (public mathematical results); behaviour of Animate's Eraser and Eyedropper learned from Adobe's public help and observation | Own implementation (ADR 0034); no Adobe code or presets. | | WebAssembly plug-in host (module validation, limits, fuel, resumable host calls) | `crates/plugins` | W3C WebAssembly Core Specification 1.0 / 2.0 (W3C Royalty-Free Patent Policy); the `wasmi` interpreter (MIT OR Apache-2.0) | Host model ported from PhotoCraft's filter plug-ins (same project family and licence) and extended with the AniCraft request ABI (ADR 0017). | | De Casteljau subdivision, Ramer–Douglas–Peucker simplification | `crates/geom/src/edit.rs` | Public mathematical results (de Casteljau 1959; Ramer 1972; Douglas & Peucker 1973) | | | WAV (RIFF WAVE) reading and writing: PCM 8/16/24/32-bit, IEEE float, `WAVE_FORMAT_EXTENSIBLE` | `crates/audio/src/wav.rs` | Microsoft/IBM, *Multimedia Programming Interface and Data Specifications 1.0* (1991), and Microsoft's public `WAVE_FORMAT_EXTENSIBLE` description | Public file format descriptions. | diff --git a/CHANGELOG.md b/CHANGELOG.md index 72e688aa..f7131d20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,26 @@ ## Unreleased +* **Eraser and Eyedropper** (E and I, ADR 0034, first slice). + * The Eraser sweeps the same tip as the Brush and takes what it covers out of the lines and + fills on the active layer that were drawn with Object Drawing off. Drawing objects, + symbols and text are kept, as in Animate. + * Erase modes: Erase Normal, Erase Fills, Erase Lines, Erase Selected Fills and Erase Inside + (only the fill where the stroke starts). + * The Faucet option deletes a whole fill or line with one click. + * Double-clicking the Eraser tool, or Erase Everything… in its options, clears the visible, + unlocked layers at this frame. It asks first, and you can undo it. + * The erased area shows as you drag, `[` and `]` change the size, and each stroke is one + undo step. A stroke that erases nothing leaves no undo step. + * The Eyedropper picks a fill's colour, gradient or bitmap into the fill swatch, or a line's + colour, width and width profile into the stroke settings. It then becomes the Paint Bucket + or the Ink Bottle. + * A picked gradient stays where it is on the stage, so it carries on across the shapes you + pour it into. + * With shapes selected, the Eyedropper applies the picked style to them. Shift-click picks + into the other swatch only. + * For scripts and AI assistants: `draw.erase`, `draw.faucet`, `draw.erase_all`, + `paint.pick` and `paint.apply_style`. * **Brush tool** (B, ADR 0033, first slice). The brush paints filled shapes in the fill colour, as Animate's Brush tool does: the shape is exactly the area the tip sweeps along the drag. * Tip options: round or square, size, angle and roundness (for oval and flat calligraphic diff --git a/docs/adr/0034-eraser-and-eyedropper.md b/docs/adr/0034-eraser-and-eyedropper.md new file mode 100644 index 00000000..990db1c4 --- /dev/null +++ b/docs/adr/0034-eraser-and-eyedropper.md @@ -0,0 +1,143 @@ +# ADR 0034: Eraser and Eyedropper + +* Status: accepted (2026-11-09) +* Relates to: ADR 0033 (Brush tool), ADR 0031 (merge drawing), ADR 0018 (variable-width + strokes), ADR 0004 (destructive actions) + +## Context + +Animate's Brush has two companions that artists reach for constantly: + +* **Eraser (E).** It sweeps a tip over the drawing and takes away what it covers, on the active + layer only. Its modes choose what it takes: *Erase Normal* (lines and fills), *Erase Fills*, + *Erase Lines*, *Erase Selected Fills* and *Erase Inside* (only the fill where the stroke + starts). The *Faucet* option deletes a whole fill or line with one click. Drawing objects and + symbols are not erased. Double-clicking the tool erases everything on the stage. +* **Eyedropper (I).** A click on a fill picks its colour, gradient or bitmap; a click on a line + picks its colour, width and style. The tool then becomes the Paint Bucket or the Ink Bottle, + and with shapes selected the picked style goes onto them. + +We learned the behaviour from Adobe's public help pages and by watching the program. Nothing +was copied. + +## Decision + +1. **The eraser is a fill in the merge that comes out empty.** The eraser's outline is the + Brush's swept tip (`anicraft_geom::brush::outline`, the same tip model: size, round or + square, angle, roundness, pressure), with almost no smoothing (a third of a screen point). + It goes into the planar merge (ADR 0031) as one more item with a reserved fill style. The + merge already gives each face the topmost fill over it and hides a line that a later fill + covers on both sides, so whatever sits under the eraser is replaced by "erased", which is + then dropped. The rest comes back as ordinary raw shapes: one element per fill region and + per stroke run, lines rejoined through the cut points. There is no new geometry and no + format change. + + The mode is only **where the eraser goes in the stack**, among the raw shapes its bounds + touch: + + | Mode | Bottom to top | + | --- | --- | + | Erase Normal | everything, eraser | + | Erase Fills | fills, eraser, lines | + | Erase Lines | lines, eraser (the fills stay out of the merge, exactly as they are) | + | Erase Selected Fills | selected fills, eraser, other fills, lines | + | Erase Inside | the fill under the stroke's first point, eraser, other fills, lines | + + Fills don't overlap in a merged drawing, so a fill above the eraser keeps its whole area. + Lines above it are only cut at the eraser's edge and joined again. In Erase Lines the fills + are left out of the merge, because a fill above a line that ends inside it would hide that + line. + + *Rejected:* a general boolean subtraction on paths. The merge already is that operation for + raw shapes, with snapping, exact sub-curves and the selection model. A second engine would + disagree with it at the edges. + +2. **Only raw shapes are erased.** Drawing objects, gradient or bitmap fills and width-profiled + strokes (which the merge keeps whole, ADR 0031), symbols and text are left alone, as in + Animate. AniCraft has no "edit inside a symbol" mode yet, so symbols are never erased. + +3. **Nothing erased, nothing changed.** A stroke that only comes near the artwork must not + create a keyframe or an undo step. The command compares the total fill area and line length + of the shapes it took in with what came out. Areas are exact (Green's theorem with + five-point Gauss–Legendre nodes, exact for the degree-5 integrand of a cubic) and lengths use + the same nodes. A shape that the merge returns unchanged comes back as the same sub-curves, + so it measures the same. If nothing changed, the document is put back as it was. + +4. **Commands** (everything is a command, so it works over the CLI and MCP): + * `draw.erase {points, size?, shape?, angle?, roundness?, mode?, unit?}`: one stroke is one + undo step. It returns `erased: false` and a reason when there was nothing to erase. + * `draw.faucet {x, y, slop?}` deletes the raw fill or line under the point on the active + layer. It refuses objects, symbols and text with a message saying how to delete them. + * `draw.erase_all {}` clears every visible, unlocked layer's keyframe at the playhead + (raw shapes, objects, symbols, text). Tweens on those keyframes are removed, since nothing + is left to tween. Locked and hidden layers are kept. ADR 0004: this is a large undoable + deletion, so `confirm.rs` asks first, with the counts. The engine doesn't require + `"confirm": true` (undo brings it back). The shell runs it on a double-click of the Eraser + tool button and from "Erase Everything…" in the Eraser's options. + * `paint.pick {x, y, other?, slop?}` (non-mutating, like `draw.object_drawing`) picks from + the topmost item drawn under the point on any visible layer, including locked ones. + Picking reads; it changes nothing. On a line it picks the colour, the width as drawn + (times the transform's scale) and the width profile (a preset when it matches one, + otherwise kept as a custom profile). In a fill it picks the paint. `other: true` + (Shift-click) puts the picked colour into the other swatch only. + * `paint.apply_style {fill?, stroke?}` gives the selected shapes the fill swatch (shapes + with a fill) and the stroke settings (shapes with a line, and drawing objects without + one). Raw fills don't gain strokes, because their lines are elements of their own. + + All of these are in the existing `draw` and `paint` namespaces, which plug-ins may call. + +5. **A picked gradient or bitmap stays where it is on the stage.** `ToolStyle` gains + `fill_paint: Option`, in stage space, with `fill` kept as its first colour for the + swatch. It also gains `custom_profile` for a picked profile that is none of the presets. + Whatever uses the fill swatch maps the paint into the shape's local space + (`Paint::transformed`): the Paint Bucket, `paint.apply_style`, and the shape tools. So the + gradient carries on across the shapes it is poured into, which is Animate's *Lock Fill* + after the Eyedropper. Choosing a colour in the swatch drops it. Linear gradient ends and + radial centres are mapped exactly; a radial radius scales by the mean scale, so a skewed or + unevenly scaled source picks a near match. + +6. **The tools** are view state over those commands. + * **Eraser (E, after the Brush).** A drag collects samples like the Brush and shows the + sweep in the stage colour as it goes. Letting go sends one command; a click erases a dab. + `[` and `]` step the size. + * **Eraser options:** Faucet, Size, Shape, Mode and Erase Everything…. + * **Eyedropper (I, after the Ink Bottle).** A click picks. With shapes selected, it also + applies the picked style. It then becomes the Paint Bucket (after a fill) or the Ink + Bottle (after a line). Shift-click picks into the other swatch and stays. + * The Fill row in the tool options says when the swatch holds a gradient or a bitmap. + * The icons are original, drawn on Lucide's grid. + +## Consequences + +* Measured in release, 32 threads, median of 7. The eraser's outline is computed once per + stroke, when it ends, and the merge only takes in what its bounds touch. + + | Stroke | Raw shapes | Median | + | --- | --- | --- | + | 1000 px wave, size 20, through a grid of 40 outlined rectangles | 200 | 6.4 ms | + | Same, Erase Lines | 200 | 6.0 ms | + | Same, size 80 | 200 | 4.0 ms | + | Same wave through 30 brushed waves | 30 | 22 ms | + +* Tested: + * A 20 wide band through a 200 × 100 rectangle leaves 18 000 units², within 40. + * Each mode's area and line length are analytic. + * The faucet; objects and symbols untouched, with no undo step. + * Erase Everything asks and keeps locked layers. + * Solid, gradient and line picks; picking into the other swatch; applying to the selection. + * The every-command fuzz and the file round trip. +* The eraser cuts lines by their centre line. A thin eraser grazing the edge of a thick line + without crossing its centre takes nothing, and the cut ends keep their round caps. +* The live preview paints the stage colour over everything, including objects and other layers + that the stroke will keep. + +## Not yet + +* Erasing inside symbols (needs an edit-in-place mode). +* Erasing gradient, bitmap or width-profiled shapes (needs them in the merge). +* Eraser pressure. +* A preview through the merge. +* The Eyedropper picking a bitmap's pixel colour (it picks the bitmap fill itself) and text + styles. +* An eyedropper cursor. +* Showing a gradient in the toolbar swatch. diff --git a/docs/roadmap.md b/docs/roadmap.md index 9ee4a142..85fcf8c9 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -11,7 +11,7 @@ milestone ends with a green tree: build, tests, clippy, a `--screenshot` check a | Architecture | M0 skeleton in place: geom → doc → render → engine → cli → shell, layering enforced by `cargo test` (`src/architecture_tests.rs`: lower layers only, no UI crates below the shell, and the AGENTS.md map must match). | | Rendering | CPU oracle with analytic AA, non-zero/even-odd, solid + linear/radial gradients, round-join strokes. **Mask clipping**: the display list carries nested clips; a clip is the anti-aliased union of its mask fills (strokes and opacity ignored), intersected with any enclosing clip, computed once per render band; an empty mask hides everything under it. **Group alpha**: a symbol instance below full opacity is a group in the display list; each render band composites the group's run of ops into its own buffer (nested groups stack) and blends it once at the group's alpha, so overlaps don't show through; SVG export writes ``. **Blend modes** (Animate's 14, on movie clip and button instances): an instance with one is an isolated group that blends at its close with the W3C separable formulas on premultiplied colour (Alpha and Erase keep or clear the backdrop); SVG gets CSS `mix-blend-mode`, Lottie the layer `bm`. **Bitmaps**: `Paint::Bitmap` fills (once or tiled) with bilinear sampling in premultiplied space, colour effects per sample; PNG/JPEG import to stage (a rectangle of the image's size); stored in the document as PNG (base64 in `.anicraft`), decoded once on first use; SVG export embeds each image once as a pattern. **Filters**: a filtered group is drawn on its own (by the same renderer, recursively, so nested filters work) into a buffer over its artwork grown by the filters' reach, filtered (box-blur passes; shadow and glow from the blurred, offset opacity; **bevel and gradient bevel** from the difference of the blurred opacity offset towards and away from the light, **gradient glow** from the glow's intensity, both through a colour ramp whose rest stop is pinned transparent, inner/outer/full and knockout, ADR 0025; colour matrix), and composited back as one image in its group, so alpha and blend apply; clips from inside the symbol apply before filtering and the instance's own clip after. **GPU stage, first slice** (M3, ADR 0019; `--features gpu-stage`, off by default): Preferences › Stage › Renderer *GPU (preview)* draws the stage with wgpu compute from the oracle's own prepared fills (tile binning with per-row backdrops on the CPU, exact area coverage and src-over per pixel on the GPU): solid and gradient fills and strokes, non-zero and even-odd; masks, group opacity, blend modes, filters and bitmaps fall back to the CPU per tile, and the status bar says so. Parity with the oracle: max 1/255, mean < 0.0001/255 on the sample, stress and analytic scenes (tests skip without an adapter). 4K with 1,000 shapes: 8.8–9.0 ms vs the CPU's 17.4–17.8 ms. **Second slice** (ADR 0029): on the window's wgpu device the stage tiles are drawn straight into textures egui shows (no readback; a headless device with readback when the window is on OpenGL); **masks** (nested, united artwork), **group opacity** and **all 14 blend modes** on the GPU, same parity (max 1/255, mean ≤ 0.0011/255); 4K: 1,000 shapes in 2.1–2.4 ms, 10k shapes in 10.2 ms as stage tiles, masked scenes 7× the CPU. **Third slice** (ADR 0032): **bitmap fills** (textures uploaded once per image and cached under a 256 MB budget, sampled with the oracle's own bilinear filter, colour effect and repeat rules: byte-identical) and **all seven filters** (each filtered symbol drawn into a layer of its own and filtered by compute passes that run the oracle's resolved steps: max 1/255, mean ≤ 0.007/255) on the GPU; the shaders now build with Direct3D's FXC, so DX12 windows get the GPU stage too (parity suite green on Vulkan and DX12); software adapters are refused (the CPU is faster), the start-up self-test compares with the oracle. **The GPU is the default stage renderer**: the shell's `gpu-stage` feature is on by default, Preferences › Stage › Renderer defaults to *Graphics card (GPU)*, and the CPU draws whenever there is no usable card, a tile is past the GPU's limits (more than 16 images, filters nested deeper than 4) or anything fails. 4K: the filtered sample in 3.9 ms (CPU 31.5), 200 bitmap fills in 4.4 ms (CPU 37.2). Not yet: sharing a filtered layer across a frame's tiles, more than 16 images per tile, GPU binning (ADR 0029), buffer reuse across tiles, GPU exports, a GPU runner in CI; the CPU stays the oracle and the export path. | | Timeline | **Frame selection**: click, Shift-click or drag across frames and layers; F5/Shift+F5, F6/F7 and Shift+F6 (keys, buttons and right-click menu) act on the whole selection; drag selected keyframes left or right to move them, and up or down onto other layers (the source keeps empty frames, as in Animate) (with a drop outline; one undo step; keys they land on are replaced, and spans fill the frames left behind); removing or clearing selected frames that hold artwork asks first. **Cut/Copy/Paste Frames** (Ctrl+Alt+X/C/V, and plain Ctrl+X/C/V after clicking the timeline): own clipboard, copies cut exactly at the selection edges (mid-tween state kept), paste inserts like Animate, several layers paste onto the layers below (missing ones are created), fresh element ids, symbols travel with them. **Span length by dragging its end** (resize cursor, live outline with the length in frames and seconds; later frames move with it). Headless: `layers`/`count` on the frame commands, `timeline.move_keyframes`, `timeline.cut_frames/copy_frames/paste_frames`. Layers (show/lock/outline), keyframes, blank keyframes, insert/remove frames, classic tweens with 8 easing presets + curve preview, **shape tweens** (morph between any two shapes: segments made cubic, subpaths paired by size and grown from or shrunk to a point when counts differ, segment counts equalized by subdivision, windings matched and start points aligned; amber spans; classic ⇄ shape keeps the easing; **shape hints** (ADR 0023): Modify › Shape › Add Shape Hint (Ctrl+Shift+H) adds lettered markers `a`–`z` that the artist drags onto an edge on the first and last keyframe (rose until placed, amber placed on the first, mint on the last; right-click removes), the morph cuts both outlines at the hinted points and matches the pieces in order by length; `tween.add_hint/move_hint/remove_hint/clear_hints/hints`; not yet: View › Show Shape Hints, hints inside symbols edited in place), auto-key when editing inside a tween, frame labels, symbol nesting: graphics keep step with their timeline (loop, play once, single frame, first frame; set in Properties), movie clips loop their own timeline from when the instance appears (continuous across keyframes holding the same instance), buttons show their Up frame, onion skin (±2 frames), looping playback. **Mask layers**: right-click a layer › Mask turns it into a mask over the layer below (Masked adds more layers to it); masked layers are indented under a stencil icon; the mask applies on the stage and in every export alike, and while the mask layer is unlocked its edge shows in the layer colour so it can be picked and reshaped; masked-away parts cannot be picked; layers moved in under a mask join it, moved out leave it, and a mask moves with its whole group; masks inside symbols nest. Headless: `layer.toggle_mask`, `layer.set_type`. **Scenes** (ADR 0011): the movie is an ordered list of scenes, each its own timeline, edited one at a time (scene menu on the edit bar, Insert › Scene, Modify › Scene, Shift+PageUp/PageDown); add, duplicate (fresh ids), rename, reorder and remove (asks when the scene has artwork; undoable); PNG-sequence and GIF exports play every scene in order. **Layer folders**: nestable folders (depth ≤ 16) holding layers and masks through `Layer.parent`, one invariant (`Timeline::repair_masks`: a child sits below its parent inside the parent's unbroken run; broken links fall back to the nearest valid ancestor); hiding or locking a folder hides or locks its contents (rendering, picking, drawing); folders open and close on the timeline (view state); layers move in and out with Up/Down, a folder moves with its contents; deleting a folder deletes its contents (asks first). **Motion tweens** (ADR 0016): a span's object animated property by property (x, y, scale, rotation, skew, alpha, tint), each property its own curve of property keyframes with a per-segment ease (presets or a custom cubic Bézier, overshoot allowed); auto-key turns any edit of the object inside the span into property keys (every command, through the session), F6 keys every property, splits and copies keep the motion; sky-blue spans with property-key diamonds; **Motion Editor** tab beside the timeline: property list with values at the playhead, curve graph with draggable keys and Bézier handles, one undo step per drag. **Motion paths** (ADR 0030): a motion tween may carry a cubic path its object travels by arc length, timed by the X/Y curves (a straight path reproduces them exactly, overshoot included); shown on the stage in the motion colour with a dot per frame when the object or span is selected; Selection drags the path to bend it and its ends to move them, Subselection drags anchors and handles; moving the object reshapes the path; Orient to path and Straighten in Properties; splits cut the path. Headless: `timeline.create_motion_tween`, `motion.*` (`motion.set_path/clear_path/orient`). Not yet: adding/deleting path points on the stage, anchors tied to frames (spatial keys), moving the whole path, retiming keys, rescaling keys with the span, XFL motion-tween import. **Camera layer** (ADR 0027): the camera button in the timeline header or the Camera tool (C) adds a Camera layer on top; its frame shows on the stage in orange; drag to pan, turn with the round handle, wheel to zoom (one undo step per drag); Properties › Camera (position, zoom, rotation, tint, reset); keyframes and classic or motion tweens animate it; layer Depth gives pan parallax; View › Preview Through Camera shows the movie's picture (artwork tools pause there); hiding the camera layer turns it off; every export, Test Movie and the GPU stage see it. Headless: `camera.add/remove/set/info`, `layer.set_depth`. Not yet: editing through the preview, perspective depth, XFL camera import. **Motion guides**: guided layers (children of a guide through `Layer.parent`) have their classic tweens follow the guide's first path by arc length, from the point nearest each start keyframe to the point nearest its end (`geom::walk::PathWalk`), optionally orienting to the path; guide artwork is listed for picking and editing, drawn on the stage as a line, and never rendered or exported. | -| Drawing | Selection (click, shift-add, marquee, drag-move, arrow nudge), **Free Transform (Q)**: scale from corner/edge handles (Shift proportional, Alt from centre), rotate outside corners (Shift snaps 15°), move; one undo step per drag. Rectangle (corner radius), oval, PolyStar, line (45° snap), hand, zoom. **Pen (P)**: click for corners, drag for smooth handles (Alt breaks them), close on the first point, Enter/Esc/last-point click finishes, Backspace takes back a point; one undo step per path. **Pencil (Shift+Y)**: Smooth (Schneider curve fitting with corner detection), Straighten and Ink modes, smoothing relative to the screen. **Subselection (A)**: anchors and handles on selected shapes, drag points/handles (anchors bring their handles; one undo step per drag), point marquee, double-click an edge to add a point, Delete removes points, right-click Make Smooth/Corner; closed shapes' start point and closing edge edit like any other. **Cut/Copy/Paste in Center/Paste in Place** (the clipboard carries symbols across documents). **Rotate 90° CW/CCW, Flip H/V. Align** left/centre/right/top/middle/bottom (Ctrl+Alt+1…6; a single element aligns to the stage) and distribute. Convert to symbol / break apart; arrange; duplicate. Headless: `draw.path`, `draw.freehand`, `path.move_points/add_point/delete_points/convert_point`. **Paint Bucket (K)**: click a fill to recolour it, or inside an outline (one shape or several) to fill the enclosed area; gap size None/Small/Medium/Large closes openings; the fill is traced and curve-fitted into a new shape placed under its lines; open areas say so instead of flooding. **Ink Bottle (S)**: gives the clicked shape the current stroke. Headless: `paint.bucket`, `paint.ink`. Tool options show first in Properties while a drawing tool is active. **Text (T)** (ADR 0012): click to type on the stage, click or double-click text to edit it; font (installed families, plus the embedded Inter), size, colour, bold, italic, alignment, letter/line spacing, wrap width; the last style is kept for new text; laid out by `anicraft-text` (`fontdb` discovery, `harfrust` shaping, `skrifa` outlines) and stored as outlines with the source, so rendering never needs the font; Break Apart makes a shape. **Variable-width strokes** (ADR 0018): a stroke's width varies along it through width points (position by arc length, a width on each side as a factor of the stroke width, smooth monotone interpolation); built-in profiles (Uniform, Taper both ends, Taper start, Taper end, Bulge, Pinch) in Properties › Width with a picture of each, and in the drawing tools' options for new strokes; the **Width tool (U)**: hover a stroke to see its width points, drag a handle to widen or narrow (Alt: one side), drag the dot to slide a point, drag anywhere on the stroke to add one, Delete removes; one undo step per drag; rendered by the oracle as trapezoids with outer round joins and cross-section caps, written by SVG and Lottie export as the same filled outlines; shape tweens blend profiles; `.anicraft` keeps them (older files open as uniform). Headless: `stroke.set_profile`, `stroke.set_width_point`, `stroke.delete_width_point`, `stroke.width_at`, `profile` on `element.set_stroke`, the drawing commands and `paint.ink`. Not yet: width data from or to Animate files, saved custom profiles, pressure. **Merge drawing** (ADR 0031, first slice): with Object Drawing (J) off, the editor's default, the shape tools, Pen and Pencil draw raw strokes and fills that cut and join the raw shapes they touch (a fill on top replaces what it covers or joins the same colour, lines cut each other and the fills they cross, a fill hides the lines under it, points within 0.2 px are one; exact Bézier pieces, `anicraft_geom::planar`); one element per fill region and stroke run, selected with Animate's dot pattern; double-click selects connected strokes, or a fill with its outline; a dragged or nudged raw shape merges where it lands; arrows move 1 screen pixel (Shift 10). Headless: `object` on the drawing commands (scripts draw objects by default), `draw.object_drawing`, `draw.drop`, `element.select_connected`. Not yet: bending segments by dragging, snapping, moving shared points together, partial marquee selection, merging bucket fills and pastes, XFL raw shapes, gradients and width profiles in the merge. **Brush (B)** (ADR 0033, first slice): paints filled shapes in the fill colour, the exact area the tip sweeps (a distance field traced and fitted with cubics); round or square tip with size, angle and roundness (oval and flat calligraphic tips), pen pressure from a tablet (10–100 % of the size; a mouse paints full size), smoothing relative to the screen, Paint Normal, Paint Fills and Paint Behind; a raw shape that merges with the drawing, or a drawing object with Object Drawing on; a click paints a dab; live preview while dragging; `[` and `]` change the size; one undo step per stroke. Headless: `draw.brush`. Not yet: Paint Selection and Paint Inside, a brush library, pressure curves and tilt, Eraser and Eyedropper. | +| Drawing | Selection (click, shift-add, marquee, drag-move, arrow nudge), **Free Transform (Q)**: scale from corner/edge handles (Shift proportional, Alt from centre), rotate outside corners (Shift snaps 15°), move; one undo step per drag. Rectangle (corner radius), oval, PolyStar, line (45° snap), hand, zoom. **Pen (P)**: click for corners, drag for smooth handles (Alt breaks them), close on the first point, Enter/Esc/last-point click finishes, Backspace takes back a point; one undo step per path. **Pencil (Shift+Y)**: Smooth (Schneider curve fitting with corner detection), Straighten and Ink modes, smoothing relative to the screen. **Subselection (A)**: anchors and handles on selected shapes, drag points/handles (anchors bring their handles; one undo step per drag), point marquee, double-click an edge to add a point, Delete removes points, right-click Make Smooth/Corner; closed shapes' start point and closing edge edit like any other. **Cut/Copy/Paste in Center/Paste in Place** (the clipboard carries symbols across documents). **Rotate 90° CW/CCW, Flip H/V. Align** left/centre/right/top/middle/bottom (Ctrl+Alt+1…6; a single element aligns to the stage) and distribute. Convert to symbol / break apart; arrange; duplicate. Headless: `draw.path`, `draw.freehand`, `path.move_points/add_point/delete_points/convert_point`. **Paint Bucket (K)**: click a fill to recolour it, or inside an outline (one shape or several) to fill the enclosed area; gap size None/Small/Medium/Large closes openings; the fill is traced and curve-fitted into a new shape placed under its lines; open areas say so instead of flooding. **Ink Bottle (S)**: gives the clicked shape the current stroke. Headless: `paint.bucket`, `paint.ink`. Tool options show first in Properties while a drawing tool is active. **Text (T)** (ADR 0012): click to type on the stage, click or double-click text to edit it; font (installed families, plus the embedded Inter), size, colour, bold, italic, alignment, letter/line spacing, wrap width; the last style is kept for new text; laid out by `anicraft-text` (`fontdb` discovery, `harfrust` shaping, `skrifa` outlines) and stored as outlines with the source, so rendering never needs the font; Break Apart makes a shape. **Variable-width strokes** (ADR 0018): a stroke's width varies along it through width points (position by arc length, a width on each side as a factor of the stroke width, smooth monotone interpolation); built-in profiles (Uniform, Taper both ends, Taper start, Taper end, Bulge, Pinch) in Properties › Width with a picture of each, and in the drawing tools' options for new strokes; the **Width tool (U)**: hover a stroke to see its width points, drag a handle to widen or narrow (Alt: one side), drag the dot to slide a point, drag anywhere on the stroke to add one, Delete removes; one undo step per drag; rendered by the oracle as trapezoids with outer round joins and cross-section caps, written by SVG and Lottie export as the same filled outlines; shape tweens blend profiles; `.anicraft` keeps them (older files open as uniform). Headless: `stroke.set_profile`, `stroke.set_width_point`, `stroke.delete_width_point`, `stroke.width_at`, `profile` on `element.set_stroke`, the drawing commands and `paint.ink`. Not yet: width data from or to Animate files, saved custom profiles, pressure. **Merge drawing** (ADR 0031, first slice): with Object Drawing (J) off, the editor's default, the shape tools, Pen and Pencil draw raw strokes and fills that cut and join the raw shapes they touch (a fill on top replaces what it covers or joins the same colour, lines cut each other and the fills they cross, a fill hides the lines under it, points within 0.2 px are one; exact Bézier pieces, `anicraft_geom::planar`); one element per fill region and stroke run, selected with Animate's dot pattern; double-click selects connected strokes, or a fill with its outline; a dragged or nudged raw shape merges where it lands; arrows move 1 screen pixel (Shift 10). Headless: `object` on the drawing commands (scripts draw objects by default), `draw.object_drawing`, `draw.drop`, `element.select_connected`. Not yet: bending segments by dragging, snapping, moving shared points together, partial marquee selection, merging bucket fills and pastes, XFL raw shapes, gradients and width profiles in the merge. **Brush (B)** (ADR 0033, first slice): paints filled shapes in the fill colour, the exact area the tip sweeps (a distance field traced and fitted with cubics); round or square tip with size, angle and roundness (oval and flat calligraphic tips), pen pressure from a tablet (10–100 % of the size; a mouse paints full size), smoothing relative to the screen, Paint Normal, Paint Fills and Paint Behind; a raw shape that merges with the drawing, or a drawing object with Object Drawing on; a click paints a dab; live preview while dragging; `[` and `]` change the size; one undo step per stroke. Headless: `draw.brush`. Not yet: Paint Selection and Paint Inside, a brush library, pressure curves and tilt. **Eraser (E)** (ADR 0034, first slice): sweeps the Brush's tip and takes what it covers out of the raw shapes on the active layer (the sweep is a fill in the planar merge that comes out empty); Erase Normal, Erase Fills, Erase Lines, Erase Selected Fills and Erase Inside; the Faucet deletes a whole fill or line with a click; drawing objects, symbols and text are kept; a stroke that erases nothing leaves no undo step; live preview, `[` and `]` sizes, one undo step per stroke; double-clicking the tool (or Erase Everything… in its options) clears the visible, unlocked layers at this frame after asking. **Eyedropper (I)** (first slice): a click on a fill picks its paint (solid, or a gradient or bitmap kept where it is on the stage, as Lock Fill) into the fill swatch, a click on a line picks its colour, width and profile; with shapes selected it applies the style to them; then it becomes the Paint Bucket or the Ink Bottle; Shift-click picks into the other swatch only. Headless: `draw.erase`, `draw.faucet`, `draw.erase_all`, `paint.pick`, `paint.apply_style`. Not yet: erasing inside symbols, erasing gradient or width-profiled shapes, eraser pressure, picking a bitmap's pixel colour or text styles, an eyedropper cursor. | | Plug-ins | **WebAssembly plug-ins** (ADR 0017, `docs/plugins.md`): sandboxed modules run by `wasmi` with no imports but the AniCraft ABI (`anicraft.call`/`anicraft.response`: JSON requests that run registry commands, read a compact document view or the active layer's elements, and log); fuel (10⁹ instructions), memory (256 MiB), wall-clock (5 s), request, size and log limits, a fresh instance per run; file, plug-in, undo and clipboard commands refused. `plugin.install/list/run/remove/reload`; a run is atomic and one undo step named after the plug-in. App: **Commands** menu (Plug-ins, Install, Manage, Reload), palette entries, a dialog generated from the manifest's parameters with a live preview; plug-ins load from `/plugins` or `ANICRAFT_PLUGINS`; CLI `--plugins`. Samples in Rust (Star Field, Jitter Selection, guest SDK) in `examples/plugins`. Frame scripts: see Interactivity. Not yet: exporter and easing kinds, background runs with cancel, a binary document view. | | Interactivity | **Frame actions, frame scripts and Test Movie, first slice** (ADR 0024): a typed timeline action IR (`anicraft-actions`: stop, play, go to a frame or label in a scene, next/previous frame and scene, trace, set x/y/alpha/visible/rotation/scale, instance-name target paths) on keyframes and on button and movie clip instances (click, press, release, over, out); a pure, deterministic, budgeted player in `anicraft-doc` (`step(doc, &state, &events)`; movie clip playheads, button Up/Over/Down states with Hit-frame hit tests, script-set properties) drawn by `evaluate_player`, while `evaluate` and exports stay script-free. **Actions panel** (F9: structured lists, targets/labels/scenes picked from the document; movie clip timelines too), instance name and events in Properties, an "a" on keyframes with actions. **Frame scripts** on the plug-in host (`kind: "frame-script"`, entry points, `player`/`action` ops, 20 M instructions per frame shared, no document access). **Test Movie** (Control › Test Movie, Ctrl+Enter): the player at the document frame rate in its own window with the pointer, restart/pause/step and an Output panel. Headless: `actions.set/clear/list`, `instance.set_name`, `control.test_movie` (timed pointer events, returns output and state). **HTML canvas export** (ADR 0028, `file.export_html`, File › Export › Export HTML Canvas…): one self-contained page (data, player and drawing code inline; images and sounds embedded) that plays in any browser with canvas 2D; every used timeline baked frame by frame (tweens of every kind exact, identical paths, paints and frames stored once), movie clips, buttons with Hit areas and every action run by `player.js`, a port of the Rust player checked against it step by step in Boa (state, output and display list); masks and fading/blending groups on offscreen layers; Web Audio for Event/Start/Stop/Stream sounds; filters, Subtract/Invert, bitmap tints and plug-in frame scripts reported. Not yet: ActionScript (ADR 0013 tiers), filters and keyboard focus in the HTML page, sound actions, keyboard events, variables, persistent script state, masks in hit tests, a separate OS window. | | Headless | CLI: info, render, render-seq, **gif**, commands, exec, run, serve (JSON-lines). **MCP server** (`anicraft-cli mcp`, `docs/mcp.md`): stdio JSON-RPC, protocol 2025-06-18 (and 2025-03-26, 2024-11-05); five tools over the command registry (list, run, run a script, describe the document, render a frame as a PNG picture); confirmation tiers and undo apply as in the app. | @@ -36,7 +36,7 @@ milestone ends with a green tree: build, tests, clippy, a `--screenshot` check a | **M4** | Interchange *(in progress)* | **XFL import** (DOMDocument.xml, symbols, edges/fill styles decoded from the public format descriptions) with a corpus of self-authored files: first slice ✅ (see Files above); ~~SVG import (Import to Stage)~~ ✅, ~~SVG frame export~~ ✅; ~~Lottie export~~ ✅ (frame-accurate; easing curves instead of per-frame keys later); ~~sprite sheet + JSON~~ ✅; ~~MP4/WebM via ffmpeg pipe~~ ✅. | | **M5** | Rich media | ~~Text engine~~ ✅ first slice (ADR 0012: `harfrust` shaping, `skrifa` outlines, line wrapping, outlines stored with the text; per-character styles, text on a path and input fields later); ~~bitmap import and bitmap fills~~ ✅; ~~audio layers, waveform display, stream sync~~ ✅ first slice (ADR 0020: WAV, Ogg Vorbis, MP3; `cpal` output; effects, volume and sounds in symbols later); ~~filters (blur, drop shadow, glow, colour matrix)~~ ✅, ~~bevel, gradient glow and gradient bevel~~ ✅ (ADR 0025; SVG export and XFL import; filter presets, reordering, on/off and tweened filter values later) and ~~blend modes~~ ✅ on Movie Clips. | | **M6** | Interactivity & extensibility | **Plug-ins: the Craft-family WebAssembly system** (same host model as PhotoCraft: `wasmi` sandbox, `plugin.*` commands; AniCraft ABI for vector/timeline operations and exporters): first slice ✅ (command plug-ins over the registry, ADR 0017; exporter and easing kinds later); ~~frame scripts on the same sandbox~~ ✅ and ~~button states in test-movie preview~~ ✅ first slice (ADR 0024: action IR, pure player, Actions panel, Test Movie); ~~HTML canvas runtime export~~ ✅ first slice (ADR 0028: one self-contained page, baked frames, a JS port of the player tested against it); command macros. **ActionScript compatibility, low priority** (ADR 0013), last in M6 and free to slip past M8: tier 1 keeps scripts (XFL frame scripts and class names stored verbatim, Actions panel, `script.*` commands); tier 2 runs the ActionScript 3 timeline subset (stop, play, go to frame or label, named instances, button events) in Test Movie and HTML canvas export through the same action IR as WebAssembly frame scripts. The full language, the `flash.*` API and SWF bytecode are not planned. | -| **M7** | Advanced animation | Bone/IK tool; ~~camera layer with depth~~ ✅ first slice (ADR 0027: one camera layer per scene, pan/zoom/rotate/tint, classic and motion tweens, pan-only layer depth, Camera tool, Preview Through Camera, every export; not yet: editing while previewing, perspective depth, brightness/advanced colour, attaching layers to the camera, XFL camera import); ~~variable-width strokes~~ ✅ first slice (ADR 0018: width profiles, Width tool, exports, tweens); ~~Brush tool~~ ✅ first slice (ADR 0033: filled sweeps, tips, pressure, Paint Normal/Fills/Behind; not yet: Paint Selection/Inside, Eraser, Eyedropper) and brush library; asset warp; graph-based easing presets library. | +| **M7** | Advanced animation | Bone/IK tool; ~~camera layer with depth~~ ✅ first slice (ADR 0027: one camera layer per scene, pan/zoom/rotate/tint, classic and motion tweens, pan-only layer depth, Camera tool, Preview Through Camera, every export; not yet: editing while previewing, perspective depth, brightness/advanced colour, attaching layers to the camera, XFL camera import); ~~variable-width strokes~~ ✅ first slice (ADR 0018: width profiles, Width tool, exports, tweens); ~~Brush tool~~ ✅ first slice (ADR 0033: filled sweeps, tips, pressure, Paint Normal/Fills/Behind; not yet: Paint Selection/Inside); ~~Eraser and Eyedropper~~ ✅ first slice (ADR 0034: five erase modes, Faucet, Erase Everything; picks solid, gradient, bitmap and line styles; not yet: erasing inside symbols, gradients and width profiles in the merge) and brush library; asset warp; graph-based easing presets library. | | **M8** | Release quality | ~~Installers and signing for Windows/macOS/Linux~~ ✅ first slice (ADR 0026: family `packaging/` layout, MSI, DMG, AppImage/deb/rpm/Flatpak/tar.gz, `.anicraft` registered everywhere, signing wired to the release environment; next: opening documents from Finder, AppImage desktop integration, portable mode, store submissions); web build (wasm) of the editor; localisation; accessibility: first pass ✅ (ADR 0022: screen-reader names for every control, Ctrl+F6 panel focus, high-contrast theme, 200 % scale), next: stage elements and frames for screen readers, keyboard menu bar, the OS contrast setting; ~~crash-recovery autosave~~ ✅ (ADR 0015); documentation book. | ## Releases @@ -57,7 +57,7 @@ titled with its milestone. | M4 | Text from Animate files | XFL import, text engine (M5 first slice) | | M5 | Audio layers: import, waveform, playback sync | timeline, layers | | M6 | ~~WebAssembly plug-ins (U2)~~ ✅ first slice (ADR 0017); ~~frame scripts and Test Movie on the plug-in host~~ ✅ first slice (ADR 0024); ~~HTML canvas runtime export~~ ✅ first slice (ADR 0028); next: command macros | command registry, plug-in host, action IR and player | -| M7 | ~~Variable-width strokes~~ ✅ (ADR 0018), ~~camera layer with depth~~ ✅ first slice (ADR 0027), ~~Brush tool~~ ✅ first slice (ADR 0033); next: Eraser and Eyedropper, then Paint Selection/Inside and the brush library | strokes, Pen and Pencil, width profiles, timeline evaluation | +| M7 | ~~Variable-width strokes~~ ✅ (ADR 0018), ~~camera layer with depth~~ ✅ first slice (ADR 0027), ~~Brush tool~~ ✅ first slice (ADR 0033), ~~Eraser and Eyedropper~~ ✅ first slice (ADR 0034); next: Paint Selection/Inside and the brush library | strokes, Pen and Pencil, width profiles, timeline evaluation | | M8 | ~~Crash-recovery autosave~~ ✅, ~~accessibility first pass~~ ✅ (ADR 0022), ~~installers and signing~~ ✅ first slice (ADR 0026); next: the accessibility follow-ups, or macOS document opening | `.anicraft` format, session, AccessKit in eframe | Tasks that wait on an open track: XFL motion tweens (on M2's motion tweens); frame scripts and From 256ab42370eb065a680bd56301b53e66056ab0c9 Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Mon, 9 Nov 2026 22:31:29 -0700 Subject: [PATCH 8/8] fix(engine): golden helper walks pixels with as_chunks for the newer clippy (M4) --- crates/engine/tests/golden/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/engine/tests/golden/mod.rs b/crates/engine/tests/golden/mod.rs index 55505757..4c12430d 100644 --- a/crates/engine/tests/golden/mod.rs +++ b/crates/engine/tests/golden/mod.rs @@ -78,7 +78,7 @@ fn compare(golden: &Path, name: &str, width: u32, height: u32, rgba: &[u8], tol: let mut bad = 0usize; let mut worst = 0u8; let mut diff = Vec::with_capacity(rgba.len()); - for (a, b) in rgba.chunks_exact(4).zip(want.chunks_exact(4)) { + for (a, b) in rgba.as_chunks::<4>().0.iter().zip(want.as_chunks::<4>().0) { let d = a.iter().zip(b).map(|(x, y)| x.abs_diff(*y)).max().unwrap_or(0); worst = worst.max(d); if d > tol.channel { @@ -112,7 +112,7 @@ fn the_check_passes_within_the_tolerance_and_fails_past_it() { assert!(compare(&golden, "self-test-near", w, h, &near, DEFAULT).is_ok()); // A whole row changed is not. let mut off = base.clone(); - for px in off.chunks_exact_mut(4).take(w as usize) { + for px in off.as_chunks_mut::<4>().0.iter_mut().take(w as usize) { px[1] = 0; } let err = compare(&golden, "self-test-off", w, h, &off, DEFAULT).unwrap_err();