chore: merge main (eraser, eyedropper, XFL corpus) into the web build (M8)
No files matched your search
@@ -19,7 +19,7 @@ shaders or SDK code).
|
||||
| Hack Regular (via `epaint_default_fonts`) | UI monospace font | Source Foundry Authors; Bitstream (Vera) | <https://github.com/source-foundry/Hack> | MIT + Bitstream Vera licence, [`licenses/fonts/LICENSE-Hack.txt`](licenses/fonts/LICENSE-Hack.txt) |
|
||||
| Noto Emoji (via `epaint_default_fonts`) | Symbol fallback | Google | <https://github.com/googlefonts/noto-emoji> | 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 | <https://github.com/jslegers/emoji-icon-font> | 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) | <https://github.com/lucide-icons/lucide> (`icons/<name>.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)) |
|
||||
@@ -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)
|
||||
@@ -95,6 +97,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. |
|
||||
|
||||
@@ -17,6 +17,47 @@
|
||||
builds for `wasm32-unknown-unknown` in CI, and the engine's tests also run inside
|
||||
WebAssembly in Node.
|
||||
|
||||
* **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.
|
||||
* **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
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M13.5 4.5 L20.5 11.5 L11 21 L4 14 Z" />
|
||||
<path d="M7.3 10.7 L14.3 17.7" />
|
||||
<path d="M14 21 H20" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 302 B |
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M11 6 L18 13" />
|
||||
<path d="M12.5 7.5 L15.5 4.5 A2.85 2.85 0 0 1 19.5 8.5 L16.5 11.5" />
|
||||
<path d="M13 9 L5 17 L5 19 L7 19 L15 11" />
|
||||
<path d="M3 21 L3.01 21" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 365 B |
@@ -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<Vec<GradientStop>> {
|
||||
(a.len() == b.len()).then(|| {
|
||||
|
||||
@@ -72,7 +72,7 @@ impl PaintMode {
|
||||
}
|
||||
}
|
||||
|
||||
fn samples(p: &Value) -> Result<Vec<Sample>> {
|
||||
pub(crate) fn samples(p: &Value) -> Result<Vec<Sample>> {
|
||||
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<Vec<Sample>> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn ranged(p: &Value, key: &str, range: std::ops::RangeInclusive<f32>, default: f32) -> Result<f32> {
|
||||
pub(crate) fn ranged(p: &Value, key: &str, range: std::ops::RangeInclusive<f32>, default: f32) -> Result<f32> {
|
||||
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<f32>, default: f
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_brush(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
/// The stroke's samples, refused when they reach too far.
|
||||
pub(crate) fn bounded_samples(p: &Value) -> Result<Vec<Sample>> {
|
||||
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<Tip> {
|
||||
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<Value> {
|
||||
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<Value> {
|
||||
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
|
||||
|
||||
@@ -55,7 +55,8 @@ pub(crate) fn style(s: &Session, p: &Value, closed: bool) -> Result<(Option<Pain
|
||||
} else {
|
||||
match opt_color(p, "fill")? {
|
||||
Some(c) => 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<Pain
|
||||
Some(_) => 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<Paint>, stroke: Option<Stroke>, object: bool) -> Result<Value> {
|
||||
// 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<Value> {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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<CommandSpec> {
|
||||
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> {
|
||||
EraseMode::ALL.into_iter().find(|m| m.key() == k)
|
||||
}
|
||||
}
|
||||
|
||||
fn erase(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
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<Value> {
|
||||
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<usize> = (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<usize> = touching.iter().copied().filter(is_fill).collect();
|
||||
let lines: Vec<usize> = 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<usize>, Vec<usize>) = 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<usize> = members.iter().copied().filter(|i| !targets.contains(i)).collect();
|
||||
let (rest_fills, rest_lines): (Vec<usize>, Vec<usize>) = 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<Part> = 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<u64> = out.iter().map(|e| e.id.0).collect();
|
||||
let gone: Vec<ElementId> = 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<Item = &'a Element>) -> (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::<f64>()).sum::<f64>() * 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::<f64>()).sum()
|
||||
}
|
||||
|
||||
/// `draw.faucet`: Animate's Faucet deletes a whole fill or stroke with one click.
|
||||
fn faucet(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
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<Value> {
|
||||
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<Element>]) -> (f64, f64) {
|
||||
measure(els.iter().map(|e| e.as_ref()))
|
||||
}
|
||||
@@ -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<CommandSpec> {
|
||||
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<Value> {
|
||||
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<Value> {
|
||||
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<Value> {
|
||||
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<Value> {
|
||||
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<Value> {
|
||||
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<Value> {
|
||||
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}))
|
||||
}
|
||||
@@ -144,6 +144,17 @@ pub fn confirmation(s: &Session, id: &str, p: &Value) -> Option<Confirmation> {
|
||||
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)?;
|
||||
|
||||
@@ -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<Rgba> {
|
||||
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<Rgba> {
|
||||
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::<Vec<_>>();
|
||||
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<usize> = 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::<usize>(), 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}");
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
@@ -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;
|
||||
@@ -108,6 +109,7 @@ pub fn commands() -> Vec<CommandSpec> {
|
||||
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());
|
||||
@@ -135,15 +137,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<anicraft_doc::Paint>,
|
||||
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<anicraft_doc::WidthProfile>,
|
||||
/// 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.
|
||||
@@ -152,7 +159,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<anicraft_doc::WidthProfile> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,7 +322,7 @@ impl Session {
|
||||
|
||||
/// Replaces the document (new/open), clearing history.
|
||||
pub fn replace_document(&mut self, doc: Document, path: Option<PathBuf>) {
|
||||
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);
|
||||
@@ -709,3 +737,7 @@ mod merge_tests;
|
||||
mod brush_tests;
|
||||
#[cfg(test)]
|
||||
mod web_tests;
|
||||
#[cfg(test)]
|
||||
mod erase_tests;
|
||||
#[cfg(test)]
|
||||
mod eyedropper_tests;
|
||||
@@ -19,7 +19,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
}
|
||||
|
||||
/// 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<Element>, 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<Part> = 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<Path> = Vec::with_capacity(all.len());
|
||||
let mut styles: Vec<(Option<u32>, Option<u32>, anicraft_geom::FillRule)> = Vec::with_capacity(all.len());
|
||||
let mut fresh: Vec<bool> = 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<Item> = 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<Element>, 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<Arc<Element>>, Vec<ElementId>)> {
|
||||
// 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<Path> = Vec::with_capacity(parts.len());
|
||||
let mut styles: Vec<(Option<u32>, Option<u32>, anicraft_geom::FillRule)> = Vec::with_capacity(parts.len());
|
||||
let mut marked: Vec<bool> = 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<Item> = 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<Arc<Element>> = 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<Element>, 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<Element>, 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<Arc<Element>>, 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.
|
||||
|
||||
@@ -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::<Vec<_>>(), "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.");
|
||||
|
||||
@@ -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<u8>), 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.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 {
|
||||
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<u8> = (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<u8> = 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.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();
|
||||
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}");
|
||||
}
|
||||
@@ -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<Option<Vec<u8>>, 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<u8>) {
|
||||
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<String> = 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::<Vec<_>>(), "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");
|
||||
}
|
||||
}
|
||||
@@ -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<String, BitmapId>, 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<String, BitmapId>, 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<Arc<Element>>) {
|
||||
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<Arc<Element>>, 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<Vec2> = 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);
|
||||
|
||||
@@ -358,3 +358,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#"<DOMFrame index="0" duration="4" tweenType="motion" {attrs}>{inner}<elements><DOMSymbolInstance libraryItemName="Clip" name="my clip" loop="loop reverse"/></elements></DOMFrame><DOMFrame index="4"><elements/></DOMFrame>"#);
|
||||
let pts = |p: &[(f32, f32)]| p.iter().map(|(x, y)| format!(r#"<Point x="{x}" y="{y}"/>"#)).collect::<String>();
|
||||
let layers = [
|
||||
// Seven points: a curve of two segments, drawn with the slider's ease.
|
||||
frame(r#"hasCustomEase="true" acceleration="30""#, &format!(r#"<tweens><CustomEase target="all">{}</CustomEase></tweens>"#, 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#"<tweens><CustomEase target="position">{0}</CustomEase><CustomEase target="rotation">{0}</CustomEase></tweens>"#, 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#"<DOMLayer name="L"><frames>{f}</frames></DOMLayer>"#)).collect();
|
||||
let doc = format!(r#"<DOMDocument><symbols><Include href="Clip.xml"/></symbols><timelines><DOMTimeline name="Scene 1"><layers>{layers}</layers></DOMTimeline></timelines></DOMDocument>"#);
|
||||
let doc: &'static str = Box::leak(doc.into_boxed_str());
|
||||
let clip = r#"<DOMSymbolItem name="Clip"><timeline><DOMTimeline name="Clip"/></timeline></DOMSymbolItem>"#;
|
||||
let (d, report) = import(&HashMap::from([("DOMDocument.xml", doc), ("LIBRARY/Clip.xml", clip)])).unwrap();
|
||||
let eases: Vec<anicraft_doc::Easing> = 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));
|
||||
}
|
||||
@@ -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<String> {
|
||||
let mut out: Vec<String> = 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<String, Vec<u8>> {
|
||||
fn walk(dir: &Path, prefix: &str, out: &mut BTreeMap<String, Vec<u8>>) {
|
||||
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<String, Vec<u8>>, fonts: &Fonts) -> Result<(Document, Report), XflError> {
|
||||
let read = |p: &str| -> Result<Option<Vec<u8>>, 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<String, usize> = 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::<Vec<_>>(), [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<LayerKind> = 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<Option<usize>> = 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::<Vec<_>>());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scenes_labels_and_scripts() {
|
||||
let (doc, _) = import("scenes");
|
||||
assert_eq!(doc.scenes.iter().map(|s| s.name.as_str()).collect::<Vec<_>>(), ["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<usize> = 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::<Vec<_>>(), 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] = &["<", ">", "\"", "/>", "</", "
", "&bogus;", "!", "|", "[", "]", "#", "#FFFFFFFF.FF", "S9", "-", "1e39", "-nan", "inf", "99999999999", "-2147483649", " ", "\u{0}", "\u{2028}", "é", "parentLayerIndex=\"0\" ", "duration=\"100001\" ", "index=\"4294967295\" "];
|
||||
|
||||
/// `bytes` garbled one of several ways.
|
||||
fn garble(bytes: &[u8], rng: &mut Rng) -> Vec<u8> {
|
||||
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<u8> = 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<String, Vec<u8>>, 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());
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- AniCraft XFL corpus: bitmaps. The images (LIBRARY/art/checker.png, a 16x16 checker with a
|
||||
transparent corner, and LIBRARY/art/sunset.jpg, a 32x16 ramp) are original. Instances
|
||||
(scaled, rotated), a repeating bitmap fill and a clipped one; a bitmap whose file is
|
||||
missing, used by an instance. Self-authored. -->
|
||||
<DOMDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" width="320" height="180" frameRate="24" backgroundColor="#FFFFFF">
|
||||
<folders>
|
||||
<DOMFolderItem name="art" itemID="00000000-0000-0000-0000-000000000001"/>
|
||||
</folders>
|
||||
<media>
|
||||
<DOMBitmapItem name="art/checker.png" itemID="00000000-0000-0000-0000-000000000002" sourceExternalFilepath="./LIBRARY/art/checker.png" allowSmoothing="false" useImportedJPEGData="false" compressionType="lossless" originalCompressionType="lossless" quality="50" href="art/checker.png" bitmapDataHRef="M 1 1.dat" frameRight="320" frameBottom="320"/>
|
||||
<DOMBitmapItem name="art/sunset.jpg" itemID="00000000-0000-0000-0000-000000000003" sourceExternalFilepath="./LIBRARY/art/sunset.jpg" quality="80" href="art/sunset.jpg" bitmapDataHRef="M 2 2.dat" isJPEG="true" frameRight="640" frameBottom="320"/>
|
||||
<DOMBitmapItem name="art/gone.png" itemID="00000000-0000-0000-0000-000000000004" href="art/gone.png" bitmapDataHRef="M 3 3.dat"/>
|
||||
</media>
|
||||
<timelines>
|
||||
<DOMTimeline name="Scene 1">
|
||||
<layers>
|
||||
<DOMLayer name="Instances" color="#4F80FF">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMBitmapInstance libraryItemName="art/checker.png">
|
||||
<matrix><Matrix a="4" d="4" tx="10" ty="10"/></matrix>
|
||||
</DOMBitmapInstance>
|
||||
<DOMBitmapInstance libraryItemName="art/sunset.jpg">
|
||||
<matrix><Matrix a="3" d="3" tx="90" ty="10"/></matrix>
|
||||
</DOMBitmapInstance>
|
||||
<DOMBitmapInstance libraryItemName="art/checker.png">
|
||||
<matrix><Matrix a="2.598" b="1.5" c="-1.5" d="2.598" tx="250" ty="104"/></matrix>
|
||||
</DOMBitmapInstance>
|
||||
<DOMBitmapInstance libraryItemName="art/gone.png">
|
||||
<matrix><Matrix tx="300" ty="160"/></matrix>
|
||||
</DOMBitmapInstance>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Fills" color="#FF4F4F">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMShape>
|
||||
<fills>
|
||||
<FillStyle index="1">
|
||||
<BitmapFill bitmapPath="art/checker.png">
|
||||
<matrix><Matrix a="30" d="30" tx="200" ty="10"/></matrix>
|
||||
</BitmapFill>
|
||||
</FillStyle>
|
||||
<FillStyle index="2">
|
||||
<BitmapFill bitmapPath="art/sunset.jpg" bitmapIsClipped="true">
|
||||
<matrix><Matrix a="40" d="40" tx="20" ty="110"/></matrix>
|
||||
</BitmapFill>
|
||||
</FillStyle>
|
||||
</fills>
|
||||
<edges>
|
||||
<Edge fillStyle1="1" edges="!4000 200|6200 200|6200 1600|4000 1600|4000 200"/>
|
||||
<Edge fillStyle1="2" edges="!200 2000|3000 2000|3000 3400|200 3400|200 2000"/>
|
||||
</edges>
|
||||
</DOMShape>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
</timelines>
|
||||
</DOMDocument>
|
||||
|
After Width: | Height: | Size: 104 B |
|
After Width: | Height: | Size: 315 B |
@@ -0,0 +1 @@
|
||||
PROXY-CS5
|
||||
|
After Width: | Height: | Size: 8.9 KiB |
@@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- AniCraft XFL corpus: filters and blend modes. One instance per filter (drop shadow, blur,
|
||||
glow, bevel, adjust colour, gradient glow, gradient bevel, a stack of two, a switched-off
|
||||
one, an unknown one) on the top row; blend modes over a striped ground on the bottom row.
|
||||
Self-authored. -->
|
||||
<DOMDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" width="320" height="180" frameRate="24" backgroundColor="#F1FAEE">
|
||||
<symbols>
|
||||
<Include href="Chip.xml" loadImmediate="false"/>
|
||||
</symbols>
|
||||
<timelines>
|
||||
<DOMTimeline name="Scene 1">
|
||||
<layers>
|
||||
<DOMLayer name="Filters" color="#4F80FF">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMSymbolInstance libraryItemName="Chip" ><matrix><Matrix tx="30" ty="30"/></matrix><filters><DropShadowFilter blurX="4" blurY="4" distance="6" angle="45" color="#000000" alpha="0.6"/></filters></DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Chip" ><matrix><Matrix tx="80" ty="30"/></matrix><filters><BlurFilter blurX="8" blurY="2" quality="2"/></filters></DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Chip" ><matrix><Matrix tx="130" ty="30"/></matrix><filters><GlowFilter blurX="10" blurY="10" color="#E63946" strength="2"/></filters></DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Chip" ><matrix><Matrix tx="180" ty="30"/></matrix><filters><BevelFilter blurX="4" blurY="4" distance="4" angle="45" highlightColor="#FFFFFF" shadowColor="#000000" shadowAlpha="0.8"/></filters></DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Chip" ><matrix><Matrix tx="230" ty="30"/></matrix><filters><AdjustColorFilter brightness="-20" contrast="30" saturation="-100" hue="0"/></filters></DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Chip" ><matrix><Matrix tx="280" ty="30"/></matrix><filters><GradientGlowFilter blurX="8" blurY="8" distance="0" type="outer"><GradientEntry color="#FFFFFF" alpha="0" ratio="0"/><GradientEntry color="#457B9D" ratio="0.5"/><GradientEntry color="#1D3557" ratio="1"/></GradientGlowFilter></filters></DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Chip" ><matrix><Matrix tx="30" ty="85"/></matrix><filters><GradientBevelFilter blurX="4" blurY="4" distance="3"><GradientEntry color="#FFFFFF" ratio="0"/><GradientEntry color="#FF0000" alpha="0" ratio="0.5"/><GradientEntry color="#000000" ratio="1"/></GradientBevelFilter></filters></DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Chip" ><matrix><Matrix tx="80" ty="85"/></matrix><filters><DropShadowFilter distance="4" color="#264653" knockout="true"/><GlowFilter blurX="6" blurY="6" color="#2A9D8F" inner="true"/></filters></DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Chip" ><matrix><Matrix tx="130" ty="85"/></matrix><filters><BlurFilter blurX="20" blurY="20" enabled="false"/></filters></DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Chip" ><matrix><Matrix tx="180" ty="85"/></matrix><filters><ConvolutionFilter matrixX="3" matrixY="3"/></filters></DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Chip" name="fading"><matrix><Matrix tx="230" ty="85"/></matrix><color><Color alphaMultiplier="0.5"/></color><filters><DropShadowFilter distance="5" alpha="0.8" hideObject="true"/></filters></DOMSymbolInstance>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Blends" color="#FF4F4F">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMSymbolInstance libraryItemName="Chip" blendMode="multiply"><matrix><Matrix tx="25" ty="145"/></matrix></DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Chip" blendMode="screen"><matrix><Matrix tx="65" ty="145"/></matrix></DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Chip" blendMode="difference"><matrix><Matrix tx="105" ty="145"/></matrix></DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Chip" blendMode="add"><matrix><Matrix tx="145" ty="145"/></matrix></DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Chip" blendMode="subtract"><matrix><Matrix tx="185" ty="145"/></matrix></DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Chip" blendMode="overlay"><matrix><Matrix tx="225" ty="145"/></matrix></DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Chip" blendMode="hardlight"><matrix><Matrix tx="265" ty="145"/></matrix></DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Chip" blendMode="invert"><matrix><Matrix tx="300" ty="145"/></matrix></DOMSymbolInstance>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Ground" color="#808080">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMShape>
|
||||
<fills><FillStyle index="1"><SolidColor color="#1D3557"/></FillStyle><FillStyle index="2"><SolidColor color="#A8DADC"/></FillStyle></fills>
|
||||
<edges>
|
||||
<Edge fillStyle1="1" edges="!0 2400|6400 2400|6400 2900|0 2900|0 2400"/>
|
||||
<Edge fillStyle1="2" edges="!0 2900|6400 2900|6400 3600|0 3600|0 2900"/>
|
||||
</edges>
|
||||
</DOMShape>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
</timelines>
|
||||
</DOMDocument>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- A movie clip: a rounded orange chip with a dark centre. Self-authored. -->
|
||||
<DOMSymbolItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" name="Chip" itemID="00000000-0000-0000-0000-000000000601" symbolType="movie clip">
|
||||
<timeline>
|
||||
<DOMTimeline name="Chip">
|
||||
<layers>
|
||||
<DOMLayer name="Layer 1" color="#4F80FF">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMOvalObject x="-6" y="-6" objectWidth="12" objectHeight="12"><fill><SolidColor color="#264653"/></fill></DOMOvalObject>
|
||||
<DOMRectangleObject x="-18" y="-18" objectWidth="36" objectHeight="36" topLeftRadius="8"><fill><SolidColor color="#F4A261"/></fill></DOMRectangleObject>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
</timeline>
|
||||
</DOMSymbolItem>
|
||||
@@ -0,0 +1 @@
|
||||
PROXY-CS5
|
||||
|
After Width: | Height: | Size: 9.4 KiB |
@@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- AniCraft XFL corpus: gradient fills and strokes. Gradients are defined on the square
|
||||
-819.2..819.2 px and placed by their matrix. Linear (scaled, rotated, repeating), radial
|
||||
(round, and an elliptical one with a focal point that reflects), stops with alpha, linear-RGB
|
||||
interpolation, and a gradient stroke. Self-authored. -->
|
||||
<DOMDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" width="320" height="180" frameRate="24" backgroundColor="#FFFFFF">
|
||||
<timelines>
|
||||
<DOMTimeline name="Scene 1">
|
||||
<layers>
|
||||
<DOMLayer name="Gradients" color="#4F80FF">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMShape>
|
||||
<fills>
|
||||
<FillStyle index="1">
|
||||
<LinearGradient>
|
||||
<matrix><Matrix a="0.06103516" d="0.06103516" tx="70" ty="50"/></matrix>
|
||||
<GradientEntry color="#1D3557" ratio="0"/>
|
||||
<GradientEntry color="#E63946" ratio="0.5"/>
|
||||
<GradientEntry color="#F1FAEE" alpha="0.2" ratio="1"/>
|
||||
</LinearGradient>
|
||||
</FillStyle>
|
||||
<FillStyle index="2">
|
||||
<LinearGradient>
|
||||
<matrix><Matrix a="0.03668" b="0.03668" c="-0.03668" d="0.03668" tx="170" ty="50"/></matrix>
|
||||
<GradientEntry color="#FFB703" ratio="0"/>
|
||||
<GradientEntry color="#023047" ratio="1"/>
|
||||
</LinearGradient>
|
||||
</FillStyle>
|
||||
<FillStyle index="3">
|
||||
<RadialGradient>
|
||||
<matrix><Matrix a="0.036621" d="0.036621" tx="280" ty="50"/></matrix>
|
||||
<GradientEntry color="#FFFFFF" ratio="0"/>
|
||||
<GradientEntry color="#8ECAE6" ratio="0.4"/>
|
||||
<GradientEntry color="#219EBC" ratio="1"/>
|
||||
</RadialGradient>
|
||||
</FillStyle>
|
||||
<FillStyle index="4">
|
||||
<RadialGradient spreadMethod="reflect" focalPointRatio="0.6">
|
||||
<matrix><Matrix a="0.03" d="0.015" tx="70" ty="130"/></matrix>
|
||||
<GradientEntry color="#6A994E" ratio="0"/>
|
||||
<GradientEntry color="#F2E8CF" ratio="1"/>
|
||||
</RadialGradient>
|
||||
</FillStyle>
|
||||
<FillStyle index="5">
|
||||
<LinearGradient spreadMethod="repeat" interpolationMethod="linearRGB">
|
||||
<matrix><Matrix a="0.0122" d="0.0122" tx="170" ty="130"/></matrix>
|
||||
<GradientEntry color="#BC4749" ratio="0"/>
|
||||
<GradientEntry color="#386641" ratio="1"/>
|
||||
</LinearGradient>
|
||||
</FillStyle>
|
||||
</fills>
|
||||
<strokes>
|
||||
<StrokeStyle index="1">
|
||||
<SolidStroke scaleMode="normal" weight="6">
|
||||
<fill>
|
||||
<LinearGradient>
|
||||
<matrix><Matrix a="0.0366" d="0.0366" tx="280" ty="130"/></matrix>
|
||||
<GradientEntry color="#7209B7" ratio="0"/>
|
||||
<GradientEntry color="#F72585" ratio="1"/>
|
||||
</LinearGradient>
|
||||
</fill>
|
||||
</SolidStroke>
|
||||
</StrokeStyle>
|
||||
</strokes>
|
||||
<edges>
|
||||
<Edge fillStyle1="1" edges="!400 400|2400 400|2400 1600|400 1600|400 400"/>
|
||||
<Edge fillStyle1="2" edges="!2800 400|4000 400|4000 1600|2800 1600|2800 400"/>
|
||||
<Edge fillStyle1="3" edges="!6200 1000[6200 1600 5600 1600[5000 1600 5000 1000[5000 400 5600 400[6200 400 6200 1000"/>
|
||||
<Edge fillStyle1="4" edges="!400 2000|2400 2000|2400 3200|400 3200|400 2000"/>
|
||||
<Edge fillStyle1="5" edges="!2800 2000|4000 2000|4000 3200|2800 3200|2800 2000"/>
|
||||
<Edge strokeStyle="1" edges="!4800 2200|6000 3000!4800 3000|6000 2200"/>
|
||||
</edges>
|
||||
</DOMShape>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
</timelines>
|
||||
</DOMDocument>
|
||||
|
After Width: | Height: | Size: 11 KiB |
@@ -0,0 +1 @@
|
||||
PROXY-CS5
|
||||
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- AniCraft XFL corpus: guides. A plain guide layer (never drawn), and a motion guide (an arc,
|
||||
never drawn) that two classic tweens follow, one turning with the path. The guided layers
|
||||
name the guide as their parent. Self-authored. -->
|
||||
<DOMDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" width="320" height="180" frameRate="24" backgroundColor="#FFFFFF">
|
||||
<symbols>
|
||||
<Include href="Ball.xml" loadImmediate="false"/>
|
||||
<Include href="Box.xml" loadImmediate="false"/>
|
||||
</symbols>
|
||||
<timelines>
|
||||
<DOMTimeline name="Scene 1">
|
||||
<layers>
|
||||
<DOMLayer name="Notes" color="#FF00FF" layerType="guide">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="13" keyMode="9728">
|
||||
<elements>
|
||||
<DOMRectangleObject x="0" y="0" objectWidth="320" objectHeight="180">
|
||||
<fill><SolidColor color="#FF00FF"/></fill>
|
||||
</DOMRectangleObject>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Arc" color="#4F80FF" layerType="guide" locked="true">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="13" keyMode="9728">
|
||||
<elements>
|
||||
<DOMShape>
|
||||
<strokes><StrokeStyle index="1"><SolidStroke weight="1"><fill><SolidColor color="#FF00FF"/></fill></SolidStroke></StrokeStyle></strokes>
|
||||
<edges><Edge strokeStyle="1" edges="!600 2800[3200 -400 5800 2800"/></edges>
|
||||
</DOMShape>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Rider" color="#FF4F4F" parentLayerIndex="1">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="12" tweenType="motion" motionTweenSnap="true" motionTweenOrientToPath="true" keyMode="22017">
|
||||
<elements><DOMSymbolInstance libraryItemName="Box" symbolType="graphic" loop="loop"><matrix><Matrix tx="30" ty="140"/></matrix></DOMSymbolInstance></elements>
|
||||
</DOMFrame>
|
||||
<DOMFrame index="12" keyMode="9728">
|
||||
<elements><DOMSymbolInstance libraryItemName="Box" symbolType="graphic" loop="loop"><matrix><Matrix tx="290" ty="140"/></matrix></DOMSymbolInstance></elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Second rider" color="#4FFF4F" parentLayerIndex="1">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="12" tweenType="motion" motionTweenSnap="true" keyMode="22017" acceleration="100">
|
||||
<elements><DOMSymbolInstance libraryItemName="Ball" symbolType="graphic" loop="loop"><matrix><Matrix tx="30" ty="140"/></matrix></DOMSymbolInstance></elements>
|
||||
</DOMFrame>
|
||||
<DOMFrame index="12" keyMode="9728">
|
||||
<elements><DOMSymbolInstance libraryItemName="Ball" symbolType="graphic" loop="loop"><matrix><Matrix tx="290" ty="140"/></matrix></DOMSymbolInstance></elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Ground" color="#808080">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="13" keyMode="9728">
|
||||
<elements>
|
||||
<DOMShape>
|
||||
<fills><FillStyle index="1"><SolidColor color="#E9EDC9"/></FillStyle></fills>
|
||||
<edges><Edge fillStyle1="1" edges="!0 3000|6400 3000|6400 3600|0 3600|0 3000"/></edges>
|
||||
</DOMShape>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
</timelines>
|
||||
</DOMDocument>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Self-authored corpus symbol. -->
|
||||
<DOMSymbolItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" name="Ball" itemID="00000000-0000-0000-0000-000000000301" symbolType="graphic">
|
||||
<timeline>
|
||||
<DOMTimeline name="Ball">
|
||||
<layers>
|
||||
<DOMLayer name="Layer 1" color="#4F80FF">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMOvalObject x="-12" y="-12" objectWidth="24" objectHeight="24"><fill><SolidColor color="#F4A261"/></fill><stroke><SolidStroke weight="2"><fill><SolidColor color="#264653"/></fill></SolidStroke></stroke></DOMOvalObject>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
</timeline>
|
||||
</DOMSymbolItem>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Self-authored corpus symbol. -->
|
||||
<DOMSymbolItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" name="Box" itemID="00000000-0000-0000-0000-000000000302" symbolType="graphic">
|
||||
<timeline>
|
||||
<DOMTimeline name="Box">
|
||||
<layers>
|
||||
<DOMLayer name="Layer 1" color="#4F80FF">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMRectangleObject x="-12" y="-12" objectWidth="24" objectHeight="24"><fill><SolidColor color="#2A9D8F"/></fill></DOMRectangleObject><DOMRectangleObject x="4" y="-12" objectWidth="8" objectHeight="8"><fill><SolidColor color="#264653"/></fill></DOMRectangleObject>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
</timeline>
|
||||
</DOMSymbolItem>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1 @@
|
||||
PROXY-CS5
|
||||
@@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- AniCraft XFL corpus: masks. A mask at the top of the scene, a mask inside a folder (with a
|
||||
layer in the folder it doesn't mask), a mask inside a symbol, and a mask's artwork that
|
||||
must never draw. parentLayerIndex counts every layer in the list, folders too.
|
||||
Self-authored. -->
|
||||
<DOMDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" width="320" height="180" frameRate="24" backgroundColor="#FFFFFF">
|
||||
<symbols>
|
||||
<Include href="Peephole.xml" loadImmediate="false"/>
|
||||
</symbols>
|
||||
<timelines>
|
||||
<DOMTimeline name="Scene 1">
|
||||
<layers>
|
||||
<DOMLayer name="Spot" color="#4F80FF" layerType="mask" locked="true">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMOvalObject x="20" y="20" objectWidth="80" objectHeight="80">
|
||||
<fill><SolidColor color="#FF0000"/></fill>
|
||||
</DOMOvalObject>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Stripes" color="#FF4F4F" parentLayerIndex="0" locked="true">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMShape><fills><FillStyle index="1"><SolidColor color="#264653"/></FillStyle></fills><edges><Edge fillStyle1="1" edges="!0 400|2600 400|2600 500|0 500|0 400"/><Edge fillStyle1="1" edges="!0 600|2600 600|2600 700|0 700|0 600"/><Edge fillStyle1="1" edges="!0 800|2600 800|2600 900|0 900|0 800"/><Edge fillStyle1="1" edges="!0 1000|2600 1000|2600 1100|0 1100|0 1000"/><Edge fillStyle1="1" edges="!0 1200|2600 1200|2600 1300|0 1300|0 1200"/><Edge fillStyle1="1" edges="!0 1400|2600 1400|2600 1500|0 1500|0 1400"/><Edge fillStyle1="1" edges="!0 1600|2600 1600|2600 1700|0 1700|0 1600"/><Edge fillStyle1="1" edges="!0 1800|2600 1800|2600 1900|0 1900|0 1800"/></edges></DOMShape>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Inside" color="#4FFF4F" layerType="folder" open="true"/>
|
||||
<DOMLayer name="Window" color="#4FFFFF" layerType="mask" parentLayerIndex="2" locked="true">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMRectangleObject x="150" y="20" objectWidth="80" objectHeight="80" topLeftRadius="20">
|
||||
<fill><SolidColor color="#00FF00"/></fill>
|
||||
</DOMRectangleObject>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Sky" color="#FF4FFF" parentLayerIndex="3" locked="true">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMShape>
|
||||
<fills>
|
||||
<FillStyle index="1">
|
||||
<RadialGradient>
|
||||
<matrix><Matrix a="0.07" d="0.07" tx="190" ty="60"/></matrix>
|
||||
<GradientEntry color="#FFE8D6" ratio="0"/>
|
||||
<GradientEntry color="#6B705C" ratio="1"/>
|
||||
</RadialGradient>
|
||||
</FillStyle>
|
||||
</fills>
|
||||
<edges><Edge fillStyle1="1" edges="!2800 0|4800 0|4800 2400|2800 2400|2800 0"/></edges>
|
||||
</DOMShape>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Loose" color="#808080" parentLayerIndex="2">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMShape>
|
||||
<fills><FillStyle index="1"><SolidColor color="#CB997E"/></FillStyle></fills>
|
||||
<edges><Edge fillStyle1="1" edges="!5400 400|6200 1800|4600 1800|5400 400"/></edges>
|
||||
</DOMShape>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Ground" color="#4F4FFF">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMSymbolInstance libraryItemName="Peephole" symbolType="graphic" loop="loop">
|
||||
<matrix><Matrix a="1.2" d="1.2" tx="80" ty="145"/></matrix>
|
||||
</DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Peephole" symbolType="graphic" loop="loop">
|
||||
<matrix><Matrix a="0.8" b="0.4" c="-0.4" d="0.8" tx="240" ty="145"/></matrix>
|
||||
</DOMSymbolInstance>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
</timelines>
|
||||
</DOMDocument>
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- A graphic with its own mask: a diamond showing part of a row of bars. Self-authored. -->
|
||||
<DOMSymbolItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" name="Peephole" itemID="00000000-0000-0000-0000-000000000401" symbolType="graphic">
|
||||
<timeline>
|
||||
<DOMTimeline name="Peephole">
|
||||
<layers>
|
||||
<DOMLayer name="Diamond" color="#4F80FF" layerType="mask" locked="true">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMShape>
|
||||
<fills><FillStyle index="1"><SolidColor color="#000000"/></FillStyle></fills>
|
||||
<edges><Edge fillStyle1="1" edges="!0 -500|500 0|0 500|-500 0|0 -500"/></edges>
|
||||
</DOMShape>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Bars" color="#FF4F4F" parentLayerIndex="0" locked="true">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMShape><fills><FillStyle index="1"><SolidColor color="#E76F51"/></FillStyle></fills><edges><Edge fillStyle1="1" edges="!-800 -600|800 -600|800 -500|-800 -500|-800 -600"/><Edge fillStyle1="1" edges="!-800 -400|800 -400|800 -300|-800 -300|-800 -400"/><Edge fillStyle1="1" edges="!-800 -200|800 -200|800 -100|-800 -100|-800 -200"/><Edge fillStyle1="1" edges="!-800 0|800 0|800 100|-800 100|-800 0"/><Edge fillStyle1="1" edges="!-800 200|800 200|800 300|-800 300|-800 200"/><Edge fillStyle1="1" edges="!-800 400|800 400|800 500|-800 500|-800 400"/></edges></DOMShape>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
</timeline>
|
||||
</DOMSymbolItem>
|
||||
|
After Width: | Height: | Size: 6.7 KiB |
@@ -0,0 +1 @@
|
||||
PROXY-CS5
|
||||
@@ -0,0 +1,70 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- AniCraft XFL corpus: rectangle and oval primitives and groups (with their own matrices,
|
||||
nested), and a hidden layer that must not draw. Self-authored. -->
|
||||
<DOMDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" width="320" height="180" frameRate="24" backgroundColor="#FFFFFF">
|
||||
<timelines>
|
||||
<DOMTimeline name="Scene 1">
|
||||
<layers>
|
||||
<DOMLayer name="Hidden" color="#9933CC" visible="false">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMRectangleObject x="0" y="0" objectWidth="320" objectHeight="180">
|
||||
<fill><SolidColor color="#FF00FF"/></fill>
|
||||
</DOMRectangleObject>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Group" color="#4FFF4F">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMGroup>
|
||||
<matrix><Matrix tx="180" ty="20"/></matrix>
|
||||
<members>
|
||||
<DOMOvalObject x="0" y="0" objectWidth="60" objectHeight="40">
|
||||
<fill><SolidColor color="#E07A5F"/></fill>
|
||||
<stroke><SolidStroke weight="3"><fill><SolidColor color="#3D405B"/></fill></SolidStroke></stroke>
|
||||
</DOMOvalObject>
|
||||
<DOMGroup>
|
||||
<matrix><Matrix a="0.5" d="0.5" tx="70" ty="0"/></matrix>
|
||||
<members>
|
||||
<DOMShape>
|
||||
<fills><FillStyle index="1"><SolidColor color="#81B29A"/></FillStyle></fills>
|
||||
<edges><Edge fillStyle1="1" edges="!0 0|1600 0|1600 1600|0 1600|0 0"/></edges>
|
||||
</DOMShape>
|
||||
</members>
|
||||
</DOMGroup>
|
||||
</members>
|
||||
</DOMGroup>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Primitives" color="#FF4F4F">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMRectangleObject x="20" y="20" objectWidth="120" objectHeight="60" topLeftRadius="12">
|
||||
<fill><SolidColor color="#F2CC8F"/></fill>
|
||||
<stroke><SolidStroke weight="4"><fill><SolidColor color="#3D405B"/></fill></SolidStroke></stroke>
|
||||
</DOMRectangleObject>
|
||||
<DOMRectangleObject x="20" y="100" objectWidth="80" objectHeight="60">
|
||||
<matrix><Matrix a="0.866" b="0.5" c="-0.5" d="0.866" tx="40" ty="-20"/></matrix>
|
||||
<fill><SolidColor color="#3D405B" alpha="0.5"/></fill>
|
||||
</DOMRectangleObject>
|
||||
<DOMOvalObject x="180" y="100" objectWidth="120" objectHeight="60">
|
||||
<stroke><SolidStroke weight="6"><fill><SolidColor color="#E07A5F"/></fill></SolidStroke></stroke>
|
||||
</DOMOvalObject>
|
||||
<!-- Nothing to draw: no fill and no stroke, and a zero-sized one. -->
|
||||
<DOMOvalObject x="10" y="10" objectWidth="20" objectHeight="20"/>
|
||||
<DOMRectangleObject x="10" y="10" objectWidth="0" objectHeight="20"><fill><SolidColor color="#000000"/></fill></DOMRectangleObject>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
</timelines>
|
||||
</DOMDocument>
|
||||
|
After Width: | Height: | Size: 5.0 KiB |
@@ -0,0 +1 @@
|
||||
PROXY-CS5
|
||||
@@ -0,0 +1,88 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- AniCraft XFL corpus: scenes, labels and scripts. Three scenes (the last unnamed and
|
||||
empty); frame labels, a frame comment and an anchor on a labels layer; frame scripts on an
|
||||
actions layer (reported: ActionScript isn't run yet); a sun rising across scene 1.
|
||||
Self-authored. -->
|
||||
<DOMDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" width="320" height="180" frameRate="12" backgroundColor="#14213D">
|
||||
<timelines>
|
||||
<DOMTimeline name="Opening">
|
||||
<layers>
|
||||
<DOMLayer name="Actions" color="#4F80FF">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="5" keyMode="9728"><elements/></DOMFrame>
|
||||
<DOMFrame index="5" keyMode="9728">
|
||||
<Actionscript>
|
||||
<script><![CDATA[stop();
|
||||
// The sun is up; wait for a click.]]></script>
|
||||
</Actionscript>
|
||||
<elements/>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Labels" color="#FF4F4F">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="3" name="intro" labelType="name" keyMode="9728"><elements/></DOMFrame>
|
||||
<DOMFrame index="3" duration="2" name="note to self" labelType="comment" keyMode="9728"><elements/></DOMFrame>
|
||||
<DOMFrame index="5" name="sunrise" labelType="anchor" keyMode="9728"><elements/></DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Sun" color="#4FFF4F">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="5" tweenType="motion" motionTweenSnap="true" keyMode="22017">
|
||||
<elements>
|
||||
<DOMGroup>
|
||||
<members>
|
||||
<DOMOvalObject x="140" y="150" objectWidth="40" objectHeight="40"><fill><SolidColor color="#FCA311"/></fill></DOMOvalObject>
|
||||
</members>
|
||||
</DOMGroup>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
<DOMFrame index="5" keyMode="9728">
|
||||
<elements>
|
||||
<DOMGroup>
|
||||
<members>
|
||||
<DOMOvalObject x="140" y="40" objectWidth="40" objectHeight="40"><fill><SolidColor color="#FCA311"/></fill></DOMOvalObject>
|
||||
</members>
|
||||
</DOMGroup>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Hills" color="#808080">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="6" keyMode="9728">
|
||||
<elements>
|
||||
<DOMShape>
|
||||
<fills><FillStyle index="1"><SolidColor color="#2B4162"/></FillStyle></fills>
|
||||
<edges><Edge fillStyle1="1" edges="!0 2800[1600 2000 3200 2800[4800 2400 6400 2800|6400 3600|0 3600|0 2800"/></edges>
|
||||
</DOMShape>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
<DOMTimeline name="Credits">
|
||||
<layers>
|
||||
<DOMLayer name="Scripts" color="#4F80FF">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="3" name="credits" keyMode="9728"><elements/></DOMFrame>
|
||||
<DOMFrame index="3" keyMode="9728">
|
||||
<Actionscript><script><![CDATA[gotoAndPlay("Opening", "intro");]]></script></Actionscript>
|
||||
<elements/>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Cards" color="#FF4F4F">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="2" keyMode="9728"><elements><DOMShape><fills><FillStyle index="1"><SolidColor color="#E5E5E5"/></FillStyle></fills><edges><Edge fillStyle1="1" edges="!1200 1200|5200 1200|5200 2400|1200 2400|1200 1200"/></edges></DOMShape></elements></DOMFrame>
|
||||
<DOMFrame index="2" duration="2" keyMode="9728"><elements><DOMShape><fills><FillStyle index="1"><SolidColor color="#FCA311"/></FillStyle></fills><edges><Edge fillStyle1="1" edges="!1200 1200|5200 1200|5200 2400|1200 2400|1200 1200"/></edges></DOMShape></elements></DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
<DOMTimeline name="">
|
||||
<layers/>
|
||||
</DOMTimeline>
|
||||
</timelines>
|
||||
</DOMDocument>
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1005 B |
@@ -0,0 +1 @@
|
||||
PROXY-CS5
|
||||
@@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- AniCraft XFL corpus: shapes. Self-authored from the public description of the format.
|
||||
Edges in twips: `!` move, `|` and `/` lines, `[` and `]` quadratic curves, `S` selection
|
||||
marks, `#` hex fixed point. A fill style on both sides of an edge, a hole, alpha, strokes
|
||||
with every cap and join, a stroke continuing across edges and one with a gap. -->
|
||||
<DOMDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" width="320" height="180" frameRate="24" backgroundColor="#F4F1EA" currentTimeline="1" xflVersion="2.97">
|
||||
<timelines>
|
||||
<DOMTimeline name="Scene 1">
|
||||
<layers>
|
||||
<DOMLayer name="Strokes" color="#4F80FF" current="true" isSelected="true">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMShape>
|
||||
<strokes>
|
||||
<StrokeStyle index="1">
|
||||
<SolidStroke scaleMode="normal" weight="8" caps="none" joints="miter" miterLimit="4">
|
||||
<fill><SolidColor color="#333355"/></fill>
|
||||
</SolidStroke>
|
||||
</StrokeStyle>
|
||||
<StrokeStyle index="2">
|
||||
<SolidStroke scaleMode="normal" weight="8" caps="square" joints="bevel">
|
||||
<fill><SolidColor color="#7A3355"/></fill>
|
||||
</SolidStroke>
|
||||
</StrokeStyle>
|
||||
<StrokeStyle index="3">
|
||||
<SolidStroke scaleMode="normal" weight="8">
|
||||
<fill><SolidColor color="#33557A"/></fill>
|
||||
</SolidStroke>
|
||||
</StrokeStyle>
|
||||
<StrokeStyle index="4">
|
||||
<SolidStroke scaleMode="normal" weight="1">
|
||||
<fill><SolidColor color="#000000" alpha="0.6"/></fill>
|
||||
</SolidStroke>
|
||||
</StrokeStyle>
|
||||
</strokes>
|
||||
<edges>
|
||||
<!-- A zigzag split over two edges; the second starts where the first ends. -->
|
||||
<Edge strokeStyle="1" edges="!400 3200|1100 2200"/>
|
||||
<Edge strokeStyle="1" edges="!1100 2200|1800 3200"/>
|
||||
<Edge strokeStyle="2" edges="!2400 3200/3100 2200/3800 3200"/>
|
||||
<Edge strokeStyle="3" edges="!4400 3200]5100 1600 5800 3200"/>
|
||||
<!-- One edge, two runs: the second move leaves a gap. -->
|
||||
<Edge strokeStyle="4" edges="!400 3460|1800 3460!2400 3460|3800 3460"/>
|
||||
</edges>
|
||||
</DOMShape>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Fills" color="#FF4F4F">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMShape>
|
||||
<fills>
|
||||
<FillStyle index="1"><SolidColor color="#D9452B"/></FillStyle>
|
||||
<FillStyle index="2"><SolidColor color="#2B6CD9"/></FillStyle>
|
||||
<FillStyle index="3"><SolidColor color="#3FA34D" alpha="0.75"/></FillStyle>
|
||||
<FillStyle index="4"><SolidColor color="#F29E1F"/></FillStyle>
|
||||
</fills>
|
||||
<strokes>
|
||||
<StrokeStyle index="1">
|
||||
<SolidStroke scaleMode="normal" weight="2">
|
||||
<fill><SolidColor color="#1A1A1A"/></fill>
|
||||
</SolidStroke>
|
||||
</StrokeStyle>
|
||||
</strokes>
|
||||
<edges>
|
||||
<!-- Two rectangles side by side, (20, 20)-(70, 80) red and (70, 20)-(120, 80)
|
||||
blue, each outer edge with its fill on the side it encloses. -->
|
||||
<Edge fillStyle1="1" strokeStyle="1" edges="!400 400|1400 400"/>
|
||||
<Edge fillStyle1="2" strokeStyle="1" edges="!1400 400/2400 400"/>
|
||||
<Edge fillStyle1="2" strokeStyle="1" edges="!2400 400|2400 1600"/>
|
||||
<Edge fillStyle0="2" strokeStyle="1" edges="!1400 1600|2400 1600"/>
|
||||
<Edge fillStyle0="1" strokeStyle="1" edges="!400 1600|1400 1600"/>
|
||||
<Edge fillStyle0="1" strokeStyle="1" edges="!400 400|400 1600"/>
|
||||
<!-- The shared edge: blue on its left, red on its right. -->
|
||||
<Edge fillStyle0="2" fillStyle1="1" edges="!1400 400|1400 1600"/>
|
||||
<!-- A square hole in the blue one: blue outside (on the left), nothing inside. -->
|
||||
<Edge fillStyle0="2" strokeStyle="1" edges="!1700 800|2100 800|2100 1200|1700 1200|1700 800"/>
|
||||
<!-- A round blob of quadratic curves, both selectors, with selection marks. -->
|
||||
<Edge fillStyle1="3" edges="!4000 1000S2[4000 1600 3400 1600]2800 1600 2800 1000S6[2800 400 3400 400]4000 400 4000 1000"/>
|
||||
<!-- A triangle in hex fixed point: #1518.80 is 5400.5 twips. -->
|
||||
<Edge fillStyle1="4" strokeStyle="1" edges="!#1518.80 #190|#1770 #640|#12C0 #640|#1518.80 #190"/>
|
||||
</edges>
|
||||
</DOMShape>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
</timelines>
|
||||
</DOMDocument>
|
||||
|
After Width: | Height: | Size: 7.2 KiB |
@@ -0,0 +1 @@
|
||||
PROXY-CS5
|
||||
@@ -0,0 +1,92 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- AniCraft XFL corpus: symbols. Graphic instances in every loop mode with first frames, a
|
||||
graphic nesting graphics, a movie clip playing on its own timeline, a button showing its Up
|
||||
frame, and the colour effects (alpha, tint, brightness up and down, advanced). The library
|
||||
is in folders, and one Include names a file that isn't there. Self-authored. -->
|
||||
<DOMDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" width="320" height="180" frameRate="24" backgroundColor="#F1FAEE">
|
||||
<folders>
|
||||
<DOMFolderItem name="Movie" itemID="00000000-0000-0000-0000-000000000201"/>
|
||||
<DOMFolderItem name="Parts" itemID="00000000-0000-0000-0000-000000000202"/>
|
||||
<DOMFolderItem name="Ui" itemID="00000000-0000-0000-0000-000000000203"/>
|
||||
</folders>
|
||||
<symbols>
|
||||
<Include href="Movie/Spinner.xml" itemIcon="1" loadImmediate="false"/>
|
||||
<Include href="Parts/Badge.xml" itemIcon="1" loadImmediate="false"/>
|
||||
<Include href="Parts/Blink.xml" loadImmediate="false"/>
|
||||
<Include href="Parts/Dot.xml" loadImmediate="false"/>
|
||||
<Include href="Parts/Lost.xml" loadImmediate="false"/>
|
||||
<Include href="Ui/Play Button.xml" itemIcon="0" loadImmediate="false"/>
|
||||
</symbols>
|
||||
<timelines>
|
||||
<DOMTimeline name="Scene 1">
|
||||
<layers>
|
||||
<DOMLayer name="Effects" color="#9933CC">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="6" keyMode="9728">
|
||||
<elements>
|
||||
<DOMSymbolInstance libraryItemName="Parts/Dot" symbolType="graphic" loop="loop">
|
||||
<matrix><Matrix a="2" d="2" tx="170" ty="130"/></matrix>
|
||||
<color><Color alphaMultiplier="0.4"/></color>
|
||||
</DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Parts/Dot" symbolType="graphic" loop="loop">
|
||||
<matrix><Matrix a="2" d="2" tx="200" ty="130"/></matrix>
|
||||
<color><Color tintMultiplier="0.7" tintColor="#0000FF"/></color>
|
||||
</DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Parts/Dot" symbolType="graphic" loop="loop">
|
||||
<matrix><Matrix a="2" d="2" tx="230" ty="130"/></matrix>
|
||||
<color><Color brightness="0.6"/></color>
|
||||
</DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Parts/Dot" symbolType="graphic" loop="loop">
|
||||
<matrix><Matrix a="2" d="2" tx="260" ty="130"/></matrix>
|
||||
<color><Color brightness="-0.5"/></color>
|
||||
</DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Parts/Dot" symbolType="graphic" loop="loop">
|
||||
<matrix><Matrix a="2" d="2" tx="290" ty="130"/></matrix>
|
||||
<color><Color redMultiplier="0.2" greenOffset="120" alphaMultiplier="0.8"/></color>
|
||||
</DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Parts/Missing" symbolType="graphic" loop="loop"/>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Clips" color="#FF4F4F">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="6" keyMode="9728">
|
||||
<elements>
|
||||
<DOMSymbolInstance libraryItemName="Movie/Spinner" name="spinner">
|
||||
<matrix><Matrix tx="40" ty="130"/></matrix>
|
||||
</DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Ui/Play Button" symbolType="button">
|
||||
<matrix><Matrix a="1.2" d="1.2" tx="110" ty="130"/></matrix>
|
||||
</DOMSymbolInstance>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Loops" color="#4F80FF" current="true" isSelected="true">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="6" keyMode="9728">
|
||||
<elements>
|
||||
<DOMSymbolInstance libraryItemName="Parts/Blink" symbolType="graphic" loop="loop">
|
||||
<matrix><Matrix tx="30" ty="40"/></matrix>
|
||||
</DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Parts/Blink" symbolType="graphic" loop="play once" firstFrame="1">
|
||||
<matrix><Matrix tx="80" ty="40"/></matrix>
|
||||
</DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Parts/Blink" symbolType="graphic" loop="single frame" firstFrame="2">
|
||||
<matrix><Matrix tx="130" ty="40"/></matrix>
|
||||
</DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Parts/Blink" symbolType="graphic" loop="play once reverse" firstFrame="3">
|
||||
<matrix><Matrix tx="180" ty="40"/></matrix>
|
||||
</DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Parts/Badge" symbolType="graphic" loop="loop">
|
||||
<matrix><Matrix a="1.5" d="1.5" tx="260" ty="45"/></matrix>
|
||||
</DOMSymbolInstance>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
</timelines>
|
||||
</DOMDocument>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- A movie clip (no symbolType: movie clip is the format's default) whose bar turns 0, 60 and
|
||||
120 degrees on its three frames. It plays on its own timeline. Self-authored. -->
|
||||
<DOMSymbolItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" name="Movie/Spinner" itemID="00000000-0000-0000-0000-000000000104">
|
||||
<timeline>
|
||||
<DOMTimeline name="Spinner">
|
||||
<layers>
|
||||
<DOMLayer name="Bar" color="#4F80FF">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728"><elements><DOMShape><matrix><Matrix a="1" b="0" c="0" d="1"/></matrix><fills><FillStyle index="1"><SolidColor color="#2A9D8F"/></FillStyle></fills><edges><Edge fillStyle1="1" edges="!-400 -80|400 -80|400 80|-400 80|-400 -80"/></edges></DOMShape></elements></DOMFrame>
|
||||
<DOMFrame index="1" keyMode="9728"><elements><DOMShape><matrix><Matrix a="0.5" b="0.866" c="-0.866" d="0.5"/></matrix><fills><FillStyle index="1"><SolidColor color="#2A9D8F"/></FillStyle></fills><edges><Edge fillStyle1="1" edges="!-400 -80|400 -80|400 80|-400 80|-400 -80"/></edges></DOMShape></elements></DOMFrame>
|
||||
<DOMFrame index="2" keyMode="9728"><elements><DOMShape><matrix><Matrix a="-0.5" b="0.866" c="-0.866" d="-0.5"/></matrix><fills><FillStyle index="1"><SolidColor color="#2A9D8F"/></FillStyle></fills><edges><Edge fillStyle1="1" edges="!-400 -80|400 -80|400 80|-400 80|-400 -80"/></edges></DOMShape></elements></DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
</timeline>
|
||||
</DOMSymbolItem>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- A graphic nesting other symbols: a ring, two dots (one tinted) and the Blink graphic held
|
||||
on its last frame. Two levels of nesting below the stage. Self-authored. -->
|
||||
<DOMSymbolItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" name="Parts/Badge" itemID="00000000-0000-0000-0000-000000000103" symbolType="graphic">
|
||||
<timeline>
|
||||
<DOMTimeline name="Badge">
|
||||
<layers>
|
||||
<DOMLayer name="Dots" color="#FF4F4F">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="6" keyMode="9728">
|
||||
<elements>
|
||||
<DOMSymbolInstance libraryItemName="Parts/Dot" symbolType="graphic" loop="loop">
|
||||
<matrix><Matrix tx="-12" ty="0"/></matrix>
|
||||
</DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Parts/Dot" symbolType="graphic" loop="loop">
|
||||
<matrix><Matrix tx="12" ty="0"/></matrix>
|
||||
<color><Color tintMultiplier="1" tintColor="#F4A261"/></color>
|
||||
</DOMSymbolInstance>
|
||||
<DOMSymbolInstance libraryItemName="Parts/Blink" symbolType="graphic" loop="single frame" firstFrame="3">
|
||||
<matrix><Matrix a="0.4" d="0.4" tx="0" ty="-14"/></matrix>
|
||||
</DOMSymbolInstance>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Ring" color="#4F80FF">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="6" keyMode="9728">
|
||||
<elements>
|
||||
<DOMOvalObject x="-24" y="-24" objectWidth="48" objectHeight="48">
|
||||
<stroke><SolidStroke weight="3"><fill><SolidColor color="#264653"/></fill></SolidStroke></stroke>
|
||||
</DOMOvalObject>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
</timeline>
|
||||
</DOMSymbolItem>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- A graphic with one colour per frame: red, green, blue, yellow. Self-authored. -->
|
||||
<DOMSymbolItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" name="Parts/Blink" itemID="00000000-0000-0000-0000-000000000101" symbolType="graphic">
|
||||
<timeline>
|
||||
<DOMTimeline name="Blink">
|
||||
<layers>
|
||||
<DOMLayer name="Layer 1" color="#4F80FF" current="true" isSelected="true">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728"><elements><DOMShape><fills><FillStyle index="1"><SolidColor color="#E63946"/></FillStyle></fills><edges><Edge fillStyle1="1" edges="!-300 -300|300 -300|300 300|-300 300|-300 -300"/></edges></DOMShape></elements></DOMFrame>
|
||||
<DOMFrame index="1" keyMode="9728"><elements><DOMShape><fills><FillStyle index="1"><SolidColor color="#2A9D8F"/></FillStyle></fills><edges><Edge fillStyle1="1" edges="!-300 -300|300 -300|300 300|-300 300|-300 -300"/></edges></DOMShape></elements></DOMFrame>
|
||||
<DOMFrame index="2" keyMode="9728"><elements><DOMShape><fills><FillStyle index="1"><SolidColor color="#457B9D"/></FillStyle></fills><edges><Edge fillStyle1="1" edges="!-300 -300|300 -300|300 300|-300 300|-300 -300"/></edges></DOMShape></elements></DOMFrame>
|
||||
<DOMFrame index="3" keyMode="9728"><elements><DOMShape><fills><FillStyle index="1"><SolidColor color="#E9C46A"/></FillStyle></fills><edges><Edge fillStyle1="1" edges="!-300 -300|300 -300|300 300|-300 300|-300 -300"/></edges></DOMShape></elements></DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
</timeline>
|
||||
</DOMSymbolItem>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- A dark dot, 16 px across, centred on its registration point. Self-authored. -->
|
||||
<DOMSymbolItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" name="Parts/Dot" itemID="00000000-0000-0000-0000-000000000102" symbolType="graphic">
|
||||
<timeline>
|
||||
<DOMTimeline name="Dot">
|
||||
<layers>
|
||||
<DOMLayer name="Layer 1" color="#4F80FF">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMOvalObject x="-8" y="-8" objectWidth="16" objectHeight="16">
|
||||
<fill><SolidColor color="#6D597A"/></fill>
|
||||
</DOMOvalObject>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
</timeline>
|
||||
</DOMSymbolItem>
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- A button: Up, Over, Down and Hit frames, and a label layer drawn on every state. While
|
||||
editing (and in a render) it shows Up. Self-authored. -->
|
||||
<DOMSymbolItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" name="Ui/Play Button" itemID="00000000-0000-0000-0000-000000000105" symbolType="button">
|
||||
<timeline>
|
||||
<DOMTimeline name="Play Button">
|
||||
<layers>
|
||||
<DOMLayer name="Arrow" color="#FF4F4F">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="4" keyMode="9728">
|
||||
<elements>
|
||||
<DOMShape>
|
||||
<fills><FillStyle index="1"><SolidColor color="#FFFFFF"/></FillStyle></fills>
|
||||
<edges><Edge fillStyle1="1" edges="!-120 -160|200 0|-120 160|-120 -160"/></edges>
|
||||
</DOMShape>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="States" color="#4F80FF">
|
||||
<frames>
|
||||
<DOMFrame index="0" name="Up" keyMode="9728"><elements><DOMRectangleObject x="-30" y="-14" objectWidth="60" objectHeight="28" topLeftRadius="8"><fill><SolidColor color="#2A9D8F"/></fill></DOMRectangleObject></elements></DOMFrame>
|
||||
<DOMFrame index="1" keyMode="9728"><elements><DOMRectangleObject x="-30" y="-14" objectWidth="60" objectHeight="28" topLeftRadius="8"><fill><SolidColor color="#E9C46A"/></fill></DOMRectangleObject></elements></DOMFrame>
|
||||
<DOMFrame index="2" keyMode="9728"><elements><DOMRectangleObject x="-30" y="-14" objectWidth="60" objectHeight="28" topLeftRadius="8"><fill><SolidColor color="#E76F51"/></fill></DOMRectangleObject></elements></DOMFrame>
|
||||
<DOMFrame index="3" keyMode="9728"><elements><DOMRectangleObject x="-30" y="-14" objectWidth="60" objectHeight="28" topLeftRadius="8"><fill><SolidColor color="#000000"/></fill></DOMRectangleObject></elements></DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
</timeline>
|
||||
</DOMSymbolItem>
|
||||
|
After Width: | Height: | Size: 6.5 KiB |
|
After Width: | Height: | Size: 6.8 KiB |
@@ -0,0 +1 @@
|
||||
PROXY-CS5
|
||||
@@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- AniCraft XFL corpus: text. A static field with runs in two styles over two lines, a
|
||||
fixed-width static field that wraps, a dynamic field with an instance name and a centred
|
||||
run, and an input field. Text is laid out with the computer's fonts, so the golden renders
|
||||
import it with none (only the card behind it draws, and the text is reported); the
|
||||
structural test checks the blocks with the fonts the computer has. Self-authored. -->
|
||||
<DOMDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" width="320" height="180" frameRate="24" backgroundColor="#FFFFFF">
|
||||
<timelines>
|
||||
<DOMTimeline name="Scene 1">
|
||||
<layers>
|
||||
<DOMLayer name="Text" color="#4F80FF">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMStaticText fontRenderingMode="standard" autoExpand="true" isSelectable="false" width="180" height="60">
|
||||
<matrix><Matrix tx="20" ty="16"/></matrix>
|
||||
<textRuns>
|
||||
<DOMTextRun>
|
||||
<characters>Corpus
</characters>
|
||||
<textAttrs><DOMTextAttrs aliasText="false" size="28" bitmapSize="560" face="ArialMT" bold="true" fillColor="#264653"/></textAttrs>
|
||||
</DOMTextRun>
|
||||
<DOMTextRun>
|
||||
<characters>self-authored, line two</characters>
|
||||
<textAttrs><DOMTextAttrs aliasText="false" size="12" bitmapSize="240" face="ArialMT" fillColor="#E76F51" letterSpacing="1"/></textAttrs>
|
||||
</DOMTextRun>
|
||||
</textRuns>
|
||||
</DOMStaticText>
|
||||
<DOMStaticText fontRenderingMode="standard" width="100" height="70" isSelectable="false">
|
||||
<matrix><Matrix tx="210" ty="16"/></matrix>
|
||||
<textRuns>
|
||||
<DOMTextRun>
|
||||
<characters>A fixed-width field wraps its words onto lines.</characters>
|
||||
<textAttrs><DOMTextAttrs aliasText="false" size="11" bitmapSize="220" face="ArialMT" fillColor="#2A9D8F" lineSpacing="2"/></textAttrs>
|
||||
</DOMTextRun>
|
||||
</textRuns>
|
||||
</DOMStaticText>
|
||||
<DOMDynamicText name="score" fontRenderingMode="standard" width="120" height="30" lineType="single line">
|
||||
<matrix><Matrix tx="20" ty="110"/></matrix>
|
||||
<textRuns>
|
||||
<DOMTextRun>
|
||||
<characters>Score 0042</characters>
|
||||
<textAttrs><DOMTextAttrs aliasText="false" alignment="center" size="18" bitmapSize="360" face="CourierNewPSMT" fillColor="#8338EC"/></textAttrs>
|
||||
</DOMTextRun>
|
||||
</textRuns>
|
||||
</DOMDynamicText>
|
||||
<DOMInputText name="answer" fontRenderingMode="standard" width="120" height="24" border="true">
|
||||
<matrix><Matrix tx="180" ty="120"/></matrix>
|
||||
<textRuns>
|
||||
<DOMTextRun>
|
||||
<characters>type here</characters>
|
||||
<textAttrs><DOMTextAttrs aliasText="false" size="14" bitmapSize="280" face="ArialMT" fillColor="#000000"/></textAttrs>
|
||||
</DOMTextRun>
|
||||
</textRuns>
|
||||
</DOMInputText>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Card" color="#FF4F4F">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMRectangleObject x="10" y="10" objectWidth="300" objectHeight="80" topLeftRadius="10">
|
||||
<fill><SolidColor color="#E9EDC9"/></fill>
|
||||
</DOMRectangleObject>
|
||||
<DOMRectangleObject x="10" y="100" objectWidth="300" objectHeight="60" topLeftRadius="10">
|
||||
<fill><SolidColor color="#CCD5AE"/></fill>
|
||||
</DOMRectangleObject>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
</timelines>
|
||||
</DOMDocument>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
@@ -0,0 +1 @@
|
||||
PROXY-CS5
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- AniCraft XFL corpus: tweens. Classic tweens (eased in, a custom ease curve, a turn with
|
||||
extra clockwise spins asked for), a shape tween eased out with a shape hint, and a motion
|
||||
tween (kept as keyframes, reported). Self-authored. -->
|
||||
<DOMDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" width="320" height="180" frameRate="24" backgroundColor="#FFFFFF">
|
||||
<symbols>
|
||||
<Include href="Ball.xml" loadImmediate="false"/>
|
||||
<Include href="Box.xml" loadImmediate="false"/>
|
||||
</symbols>
|
||||
<timelines>
|
||||
<DOMTimeline name="Scene 1">
|
||||
<layers>
|
||||
<DOMLayer name="Ease in" color="#4F80FF">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="12" tweenType="motion" motionTweenSnap="true" keyMode="22017" acceleration="-100">
|
||||
<elements>
|
||||
<DOMSymbolInstance libraryItemName="Ball" symbolType="graphic" loop="loop">
|
||||
<matrix><Matrix tx="20" ty="25"/></matrix>
|
||||
</DOMSymbolInstance>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
<DOMFrame index="12" keyMode="9728">
|
||||
<elements>
|
||||
<DOMSymbolInstance libraryItemName="Ball" symbolType="graphic" loop="loop">
|
||||
<matrix><Matrix tx="300" ty="25"/></matrix>
|
||||
</DOMSymbolInstance>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Custom ease" color="#FF4F4F">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="12" tweenType="motion" motionTweenSnap="true" keyMode="22017" hasCustomEase="true" useSingleEaseCurve="true">
|
||||
<tweens>
|
||||
<CustomEase target="all">
|
||||
<Point/>
|
||||
<Point x="0.7" y="0"/>
|
||||
<Point x="0.3" y="1"/>
|
||||
<Point x="1" y="1"/>
|
||||
</CustomEase>
|
||||
</tweens>
|
||||
<elements>
|
||||
<DOMSymbolInstance libraryItemName="Ball" symbolType="graphic" loop="loop">
|
||||
<matrix><Matrix tx="20" ty="60"/></matrix>
|
||||
</DOMSymbolInstance>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
<DOMFrame index="12" keyMode="9728">
|
||||
<elements>
|
||||
<DOMSymbolInstance libraryItemName="Ball" symbolType="graphic" loop="loop">
|
||||
<matrix><Matrix tx="300" ty="60"/></matrix>
|
||||
<color><Color tintMultiplier="1" tintColor="#E76F51"/></color>
|
||||
</DOMSymbolInstance>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Turn" color="#4FFF4F">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="12" tweenType="motion" motionTweenSnap="true" motionTweenRotate="clockwise" motionTweenRotateTimes="1" keyMode="22017">
|
||||
<elements>
|
||||
<DOMSymbolInstance libraryItemName="Box" symbolType="graphic" loop="loop">
|
||||
<matrix><Matrix tx="40" ty="95"/></matrix>
|
||||
</DOMSymbolInstance>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
<DOMFrame index="12" keyMode="9728">
|
||||
<elements>
|
||||
<DOMSymbolInstance libraryItemName="Box" symbolType="graphic" loop="loop">
|
||||
<matrix><Matrix a="0" b="1.5" c="-1.5" d="0" tx="280" ty="95"/></matrix>
|
||||
<color><Color alphaMultiplier="0.3"/></color>
|
||||
</DOMSymbolInstance>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Morph" color="#FF800A">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="12" tweenType="shape" keyMode="17922" acceleration="50">
|
||||
<shapeHints>
|
||||
<ShapeHint index="0" x="20" y="120"/>
|
||||
</shapeHints>
|
||||
<elements>
|
||||
<DOMShape>
|
||||
<fills><FillStyle index="1"><SolidColor color="#8338EC"/></FillStyle></fills>
|
||||
<edges><Edge fillStyle1="1" edges="!400 2400|1200 2400|1200 3200|400 3200|400 2400"/></edges>
|
||||
</DOMShape>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
<DOMFrame index="12" keyMode="9728">
|
||||
<shapeHints>
|
||||
<ShapeHint index="0" x="270" y="115"/>
|
||||
</shapeHints>
|
||||
<elements>
|
||||
<DOMShape>
|
||||
<fills><FillStyle index="1"><SolidColor color="#FF006E"/></FillStyle></fills>
|
||||
<edges><Edge fillStyle1="1" edges="!5400 2300[6000 2300 6000 2900[6000 3500 5400 3500[4800 3500 4800 2900[4800 2300 5400 2300"/></edges>
|
||||
</DOMShape>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
<DOMLayer name="Motion tween" color="#808080" animationType="motion object">
|
||||
<frames>
|
||||
<DOMFrame index="0" duration="13" tweenType="motion object" motionTweenRotate="none" keyMode="8195">
|
||||
<elements>
|
||||
<DOMSymbolInstance libraryItemName="Box" symbolType="graphic" loop="loop">
|
||||
<matrix><Matrix a="0.5" d="0.5" tx="300" ty="160"/></matrix>
|
||||
</DOMSymbolInstance>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
</timelines>
|
||||
</DOMDocument>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Self-authored corpus symbol. -->
|
||||
<DOMSymbolItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" name="Ball" itemID="00000000-0000-0000-0000-000000000301" symbolType="graphic">
|
||||
<timeline>
|
||||
<DOMTimeline name="Ball">
|
||||
<layers>
|
||||
<DOMLayer name="Layer 1" color="#4F80FF">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMOvalObject x="-12" y="-12" objectWidth="24" objectHeight="24"><fill><SolidColor color="#F4A261"/></fill><stroke><SolidStroke weight="2"><fill><SolidColor color="#264653"/></fill></SolidStroke></stroke></DOMOvalObject>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
</timeline>
|
||||
</DOMSymbolItem>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Self-authored corpus symbol. -->
|
||||
<DOMSymbolItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://ns.adobe.com/xfl/2008/" name="Box" itemID="00000000-0000-0000-0000-000000000302" symbolType="graphic">
|
||||
<timeline>
|
||||
<DOMTimeline name="Box">
|
||||
<layers>
|
||||
<DOMLayer name="Layer 1" color="#4F80FF">
|
||||
<frames>
|
||||
<DOMFrame index="0" keyMode="9728">
|
||||
<elements>
|
||||
<DOMRectangleObject x="-12" y="-12" objectWidth="24" objectHeight="24"><fill><SolidColor color="#2A9D8F"/></fill></DOMRectangleObject><DOMRectangleObject x="4" y="-12" objectWidth="8" objectHeight="8"><fill><SolidColor color="#264653"/></fill></DOMRectangleObject>
|
||||
</elements>
|
||||
</DOMFrame>
|
||||
</frames>
|
||||
</DOMLayer>
|
||||
</layers>
|
||||
</DOMTimeline>
|
||||
</timeline>
|
||||
</DOMSymbolItem>
|
||||
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
@@ -0,0 +1 @@
|
||||
PROXY-CS5
|
||||
@@ -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.
|
||||
@@ -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<Paint>`, 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.
|
||||
@@ -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/<name>/`, each a real
|
||||
XFL folder: `DOMDocument.xml`, `LIBRARY/` (symbols and images), and `<name>.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).
|
||||
@@ -11,12 +11,12 @@ 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 `<g opacity>`. **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 poLine truncated
|
||||
| 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 PLine truncated
|
||||
| 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 PLine truncated
|
||||
| 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 `<settings>/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. |
|
||||
| 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. **Web editor, first slice** (ADR 0036, `docs/web.md`): the same program built for `wasm32-unknown-unknown` runs in a browser (WebGL2), built by `scripts/build-web.sh`/`.ps1` with the wasm-bindgen CLI into `web/` (8973 KB, 3278 KB gzipped). Open and import with the browser's file picker; save and export as downloads (the engine reads and writes through `engine::vfs`, memory in the browser). Autosave and preferences in browser storage, with Web Locks so only closed or crashed tabs' work is offered. Leaving with unsaved work asks first. Every crate builds for wasm32 in CI, and the engine's tests run inside WebAssembly in Node. Not yet: a browser-verified run, sound (Web Audio), the GPU stage on WebGPU, video export, plug-in installs, PNG sequence as one zip, IndexedDB for large autosaves, threads, hosting. **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,10 +33,10 @@ 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. |
|
||||
| **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~~ ✅ first slice (ADR 0036: browser file picker and downloads, autosave in browser storage, CPU stage, CI wasm build and tests in Node; next: Web Audio, WebGPU stage, verified in browsers); 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), ~~web build~~ ✅ first slice (ADR 0036); 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
|
||||
@@ -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
|
||||
|
||||
@@ -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"] {
|
||||
|
||||
@@ -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<f32>)>,
|
||||
pub pen_pressure: Option<f32>,
|
||||
/// 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,
|
||||
@@ -447,6 +459,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(),
|
||||
@@ -799,6 +812,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.
|
||||
@@ -1090,6 +1132,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");
|
||||
|
||||
@@ -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<f32>) -> Drag {
|
||||
Drag::Brush
|
||||
}
|
||||
|
||||
/// The stroke's samples as command points (with pressure when a pen gave any).
|
||||
pub fn points(samples: &[(Vec2, Option<f32>)]) -> Vec<serde_json::Value> {
|
||||
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<f32>, 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<serde_json::Value> = 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<Po
|
||||
if app.tool != Tool::Brush {
|
||||
return;
|
||||
}
|
||||
let o = app.brush;
|
||||
if app.drag == Drag::Brush {
|
||||
// Opaque, so overlapping pieces don't darken each other.
|
||||
let color = to_color32(anicraft_engine::doc::Rgba { a: 1.0, ..app.s.style.fill });
|
||||
draw_sweep(painter, xf, &app.brush, &app.brush_samples, color);
|
||||
}
|
||||
if let Some(h) = hover {
|
||||
// The tip's size and shape at the pointer, as Animate shows it.
|
||||
draw_tip(painter, xf, &app.brush, xf.to_stage(h));
|
||||
}
|
||||
}
|
||||
|
||||
/// The tip swept along `samples` (shared with the Eraser, ADR 0034), filled with `color`.
|
||||
pub fn draw_sweep(painter: &egui::Painter, xf: Xf, o: &BrushOptions, samples: &[(Vec2, Option<f32>)], color: egui::Color32) {
|
||||
if samples.is_empty() {
|
||||
return;
|
||||
}
|
||||
let unit = o.unit_outline();
|
||||
let screen = |at: Vec2, pressure: Option<f32>| -> Vec<Pos2> {
|
||||
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<f32>)> = 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<f32>)> = 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<Pos2> = 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::*;
|
||||
|
||||
@@ -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<Pos2>) {
|
||||
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 };
|
||||
}
|
||||
@@ -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")),
|
||||
|
||||
@@ -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"));
|
||||
|
||||
@@ -23,6 +23,7 @@ mod actions_panel;
|
||||
mod app;
|
||||
mod autosave;
|
||||
mod brushtool;
|
||||
mod erasertool;
|
||||
mod camera_tool;
|
||||
mod dialogs;
|
||||
mod gpu_stage;
|
||||
@@ -157,7 +158,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 <percent>] [--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 <percent>] [--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\
|
||||
|
||||
@@ -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();
|
||||
@@ -79,7 +86,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));
|
||||
@@ -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<anicraft_engine:
|
||||
}
|
||||
|
||||
fn tool_props(app: &mut App, ui: &mut egui::Ui) {
|
||||
if app.tool == Tool::Eraser {
|
||||
eraser_props(app, ui);
|
||||
return;
|
||||
}
|
||||
if app.tool == Tool::Text {
|
||||
// What new text gets (the last style used, as in Animate).
|
||||
let mut st = app.s.text_style.clone();
|
||||
@@ -1238,7 +1249,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 +1257,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 +1287,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.
|
||||
@@ -1306,6 +1328,45 @@ fn tool_props(app: &mut App, ui: &mut egui::Ui) {
|
||||
}
|
||||
}
|
||||
|
||||
/// The Eraser's options (ADR 0034): the Faucet, size, shape and erase mode, as in Animate.
|
||||
fn eraser_props(app: &mut App, ui: &mut egui::Ui) {
|
||||
use crate::brushtool::{SIZE_MAX, SIZE_MIN};
|
||||
use anicraft_engine::cmds_erase::EraseMode;
|
||||
use anicraft_engine::geom::brush::TipShape;
|
||||
let keys = [app.keymap.primary("view.brush_smaller"), app.keymap.primary("view.brush_larger")].into_iter().flatten().map(crate::platform::shortcut_label).collect::<Vec<_>>().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};
|
||||
|
||||
@@ -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<u64> = 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)
|
||||
@@ -1178,7 +1193,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 {
|
||||
|
||||