mirror of
https://github.com/storytold/AniCraft.git
synced 2026-11-21 01:52:49 +01:00
chore: merge main into m6/html-filters
This commit is contained in:
commit
0d528dc91e
27 files changed
+719
-69
No files matched your search
+1
-1
@@ -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` (22 files: align, distribute, layer, mask and masked layer, width tool, camera, brush, paint brush, eraser, eyedropper, muted sound, magnet, bone, bind, edit multiple frames) | Align panel, layer-type, Width tool, Camera, Brush, Paint Brush, Eraser, Eyedropper, Bone and Bind tool icons, the timeline's mute toggle, Snap to Objects, Edit Multiple Frames | AniCraft contributors | Original work, drawn on Lucide's 24-unit grid and stroke style (the muted sound keeps the speaker of Lucide's `volume-2`, ISC, crossed out) | MIT OR Apache-2.0 |
|
||||
| `assets/icons/anicraft-*.svg` (26 files: align, distribute, layer, mask and masked layer, width tool, camera, brush, paint brush, eraser, eyedropper, muted sound, magnet, bone, bind, edit multiple frames, insert frame, keyframe and blank keyframe, clip to the stage) | Align panel, layer-type, Width tool, Camera, Brush, Paint Brush, Eraser, Eyedropper, Bone and Bind tool icons, the timeline's mute toggle, Snap to Objects, Edit Multiple Frames, the timeline's Insert Frame / Keyframe / Blank Keyframe buttons, Clip Content Outside the Stage | AniCraft contributors | Original work, drawn on Lucide's 24-unit grid and stroke style (the muted sound keeps the speaker of Lucide's `volume-2`, ISC, crossed out) | 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 |
|
||||
| `crates/svg/fixtures/soft-masks-text-paths.svg` | SVG import test drawing (an alpha and a luminance mask, text on a path) | 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) |
|
||||
|
||||
@@ -11,6 +11,24 @@
|
||||
against AniCraft's renderer pixel by pixel (35 filter set-ups at three view scales, within
|
||||
1/1000) and checked in a browser. At 1080p the demo's filtered symbols cost 3.4 ms a frame while
|
||||
they change; one covering the whole frame 50 to 150 ms. The export report no longer lists them.
|
||||
* **Timeline, bones, menus and stage fixes from user reports** (M1).
|
||||
* **Fixed**: F5 with no frames selected only extended the active layer. It now extends every
|
||||
layer that has frames at or after the playhead, as in Animate, and leaves the layers that end
|
||||
before it alone (#242).
|
||||
* **Fixed**: after F5, F6 or F7 you had to select the next frame by hand. F5 now moves onto the
|
||||
frame it adds, and F6 or F7 on a keyframe makes the new keyframe on the next frame and moves
|
||||
there, so draw, F6, draw keeps going (#254). F7 on a keyframe no longer clears its drawing.
|
||||
* **Fixed**: the timeline's Frame, Keyframe and Blank buttons took a lot of room. They are icons
|
||||
now (a frame, a filled dot and a hollow dot, each with a plus), named in their tooltips (#240).
|
||||
* **Fixed**: bone chains looked broken and jumped while posing. A bone started anywhere on an
|
||||
instance now starts at the end of the bone before it, so the chain stays joined, and dragging
|
||||
a bone along its length moves it from where you grabbed it instead of snapping its end to the
|
||||
pointer (#239).
|
||||
* **Fixed**: on macOS there were no menus (no File, no Save). The title bar covered the menu
|
||||
row; it is see-through now, as designed (#247).
|
||||
* **Fixed**: you couldn't draw outside the stage; anything past its edge was hidden. The
|
||||
pasteboard now shows your artwork, as in Animate, and **Clip content outside the stage**
|
||||
(beside the zoom menu, and in the View menu) hides it again when you want (#245, #251).
|
||||
* **Soft masks and text on a path** (ADR 0070, M4).
|
||||
* **Soft masks**: Layer Properties › **Mask type** on a mask layer: *Shape* (as in Animate),
|
||||
*Alpha* (the mask's opacity reveals: a gradient to transparent fades the artwork out) or
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<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">
|
||||
<rect x="6" y="6" width="12" height="12" rx="1" />
|
||||
<path d="M6 2v2" />
|
||||
<path d="M2 6h2" />
|
||||
<path d="M18 2v2" />
|
||||
<path d="M20 6h2" />
|
||||
<path d="M6 20v2" />
|
||||
<path d="M2 18h2" />
|
||||
<path d="M18 20v2" />
|
||||
<path d="M20 18h2" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 426 B |
@@ -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">
|
||||
<circle cx="9" cy="15" r="6" />
|
||||
<path d="M19 3v6" />
|
||||
<path d="M16 6h6" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 269 B |
@@ -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">
|
||||
<rect x="3" y="8" width="11" height="13" rx="2" />
|
||||
<path d="M19 3v6" />
|
||||
<path d="M16 6h6" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 288 B |
@@ -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">
|
||||
<circle cx="9" cy="15" r="6" fill="currentColor" />
|
||||
<path d="M19 3v6" />
|
||||
<path d="M16 6h6" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 289 B |
@@ -409,6 +409,15 @@ pub fn bones_at(arm: &Armature, elements: &[Arc<Element>], pose: &Pose) -> Vec<B
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Layer point `p` in the space of the instance (or joint node) bone `id` moves, with the
|
||||
/// armature posed by `pose`: the `local` for [`solve`] that makes the grabbed point follow a drag
|
||||
/// from where it is, so grabbing a bone along its length never snaps its end to the pointer.
|
||||
pub fn grab_point(arm: &Armature, elements: &[Arc<Element>], pose: &Pose, id: BoneId, p: Vec2) -> Option<Vec2> {
|
||||
let child = arm.bone(id)?.child;
|
||||
let q = place(arm, elements, pose).get(&child)?.inverse()?.apply(p);
|
||||
(q.x.is_finite() && q.y.is_finite()).then_some(q)
|
||||
}
|
||||
|
||||
/// What a solve came to.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Solved {
|
||||
|
||||
@@ -24,7 +24,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
c(
|
||||
"bone.add",
|
||||
"Add Bone",
|
||||
"{from (instance id: the bone starts on it), to (instance id: the bone moves it), head?: [x, y] (the joint, stage px; default the end of the bone into `from`, else its registration point), tail?: [x, y] (default `to`'s registration point), name?} → {bone, layer}. Both instances go to an armature layer (made for the first bone)",
|
||||
"{from (instance id: the bone starts on it), to (instance id: the bone moves it), head?: [x, y] (the joint on a root instance, stage px, default its registration point; from an instance that hangs from a bone the joint is always that bone's end, so chains stay joined), tail?: [x, y] (default `to`'s registration point), name?} → {bone, layer}. Both instances go to an armature layer (made for the first bone)",
|
||||
true,
|
||||
add as crate::RunFn,
|
||||
),
|
||||
@@ -193,10 +193,12 @@ fn add(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let (wf, wt) = (f.el.transform, t.el.transform);
|
||||
let singular = || EngineError::State("an instance scaled to nothing can't hold a bone".into());
|
||||
let (inv_f, inv_t) = (wf.inverse().ok_or_else(singular)?, wt.inverse().ok_or_else(singular)?);
|
||||
// The joint: given, else the end of the bone into `from` (a chain joins end to start), else
|
||||
// its registration point.
|
||||
// The joint. An instance that already hangs from a bone has one joint, that bone's end: every
|
||||
// bone from it starts there, wherever on the instance the drag began, so the chain stays
|
||||
// joined end to start and turns about the joints it shows, as in Animate (#239). A root's
|
||||
// bones start where given (a torso's shoulders and hips), else at its registration point.
|
||||
let into_from = fa.as_ref().and_then(|a| a.bone_into(from)).map(|b| wf.apply(b.tail));
|
||||
let head = head.or(into_from).unwrap_or(wf.translation());
|
||||
let head = into_from.or(head).unwrap_or(wf.translation());
|
||||
let tail = tail.unwrap_or(wt.translation());
|
||||
let rest = inv_f.mul(&wt);
|
||||
if !rest.is_finite() || rest.inverse().is_none() {
|
||||
|
||||
@@ -9,10 +9,10 @@ use std::sync::Arc;
|
||||
pub fn specs() -> Vec<CommandSpec> {
|
||||
let c = |id, label, menu, shortcut, params, mutates, run| CommandSpec { id, label, menu, shortcut, params, mutates, run };
|
||||
vec![
|
||||
c("timeline.insert_frame", "Frame", "Insert/Timeline", Some("F5"), "{layer? | layers?: [..], frame?, count?}", true, insert_frame as crate::RunFn),
|
||||
c("timeline.insert_frame", "Frame", "Insert/Timeline", Some("F5"), "{layer? | layers?: [..] | all_layers?: true (every layer with frames at or after the frame, as F5 with no frame selection; the active layer when none has), frame?, count?, advance?: true (the playhead moves onto the last frame inserted, as the key does in the editor)}", true, insert_frame as crate::RunFn),
|
||||
c("timeline.remove_frame", "Remove Frame", "Insert/Timeline", Some("Shift+F5"), "{layer? | layers?: [..], frame?, count?}", true, remove_frame),
|
||||
c("timeline.insert_keyframe", "Keyframe", "Insert/Timeline", Some("F6"), "{layer? | layers?: [..], frame?}", true, insert_keyframe),
|
||||
c("timeline.insert_blank_keyframe", "Blank Keyframe", "Insert/Timeline", Some("F7"), "{layer? | layers?: [..], frame?}", true, insert_blank_keyframe),
|
||||
c("timeline.insert_keyframe", "Keyframe", "Insert/Timeline", Some("F6"), "{layer? | layers?: [..], frame?, advance?: true (on a keyframe the new key goes on the next frame, and the playhead moves onto it, as the key does in the editor)}", true, insert_keyframe),
|
||||
c("timeline.insert_blank_keyframe", "Blank Keyframe", "Insert/Timeline", Some("F7"), "{layer? | layers?: [..], frame?, advance?: true (on a keyframe the blank key goes on the next frame instead of clearing it, and the playhead moves onto it)}", true, insert_blank_keyframe),
|
||||
c("timeline.clear_keyframe", "Clear Keyframe", "Insert/Timeline", Some("Shift+F6"), "{layer? | layers?: [..], frame?, count?}", true, clear_keyframe),
|
||||
c("timeline.move_keyframes", "Move Keyframes", "", None, "{layer? | layers?: [..], from, to?, by, layer_by? (rows down; negative = up)}", true, move_keyframes),
|
||||
c("timeline.create_motion_tween", "Create Motion Tween", "Insert", None, "{layer?, frame?} (several objects on the key become one graphic symbol; a one-frame span grows to a second)", true, crate::cmds_motion::create),
|
||||
@@ -232,19 +232,54 @@ pub(crate) fn shift_after(layer: &mut Layer, from: u32, delta: i64) {
|
||||
}
|
||||
}
|
||||
|
||||
/// F5 over a range: `count` frames on each target layer.
|
||||
/// F5 over a range: `count` frames on each target layer. With `all_layers` (F5 with no frame
|
||||
/// selection) every layer that has frames at or after `frame` grows, so the layers stay in step;
|
||||
/// layers that end before it are left alone. With `advance` the playhead moves onto the last
|
||||
/// frame inserted, as holding F5 walks along the timeline.
|
||||
fn insert_frame(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let (_, frame) = target(s, p)?;
|
||||
let count = count_param(p)?;
|
||||
let all = opt_bool(p, "all_layers")?.unwrap_or(false);
|
||||
let ids = if all { layers_at_or_after(s, frame) } else { target_layers(s, p)? };
|
||||
let mut frames = 0;
|
||||
for id in target_layers(s, p)? {
|
||||
for &id in &ids {
|
||||
let layer = s.layer_mut(Some(id))?;
|
||||
for _ in 0..count {
|
||||
insert_frame_at(layer, frame)?;
|
||||
if all && layer.keyframe_index_at(frame).is_none() && layer.end_frame() > frame {
|
||||
// A gap (or the frames before the first key) under the playhead: insert an
|
||||
// empty frame there, so what follows moves along with the other layers.
|
||||
insert_empty_frame_at(layer, frame)?;
|
||||
} else {
|
||||
insert_frame_at(layer, frame)?;
|
||||
}
|
||||
}
|
||||
frames = frames.max(layer.end_frame());
|
||||
}
|
||||
Ok(json!({"frames": frames}))
|
||||
let mut out = json!({"frames": frames, "layers": ids.iter().map(|l| l.0).collect::<Vec<_>>()});
|
||||
if opt_bool(p, "advance")?.unwrap_or(false) {
|
||||
s.set_frame(frame.saturating_add(count).min(frames.saturating_sub(1)));
|
||||
out["playhead"] = json!(s.frame);
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// The layers F5 with no frame selection extends: every layer of the timeline with frames at or
|
||||
/// after `frame` (folders have none). When no layer reaches that far, the active layer, so F5
|
||||
/// past the end still lengthens what you are working on.
|
||||
fn layers_at_or_after(s: &Session, frame: u32) -> Vec<LayerId> {
|
||||
let tl = s.timeline();
|
||||
let ids: Vec<LayerId> = tl.layers.iter().filter(|l| l.kind != LayerKind::Folder && l.end_frame() > frame).map(|l| l.id).collect();
|
||||
if ids.is_empty() { vec![s.layer] } else { ids }
|
||||
}
|
||||
|
||||
/// One empty frame at `frame`: everything from there on moves one frame later.
|
||||
fn insert_empty_frame_at(layer: &mut Layer, frame: u32) -> Result<()> {
|
||||
if layer.end_frame() >= MAX_FRAME {
|
||||
return Err(EngineError::State("the timeline is at its maximum length".into()));
|
||||
}
|
||||
shift_after(layer, frame, 1);
|
||||
layer.normalize();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn insert_frame_at(layer: &mut Layer, frame: u32) -> Result<()> {
|
||||
@@ -393,7 +428,7 @@ pub(crate) fn insert_keyframe_at(layer: &mut Layer, frame: u32, copy: bool) -> R
|
||||
}
|
||||
|
||||
fn insert_keyframe(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let (_, frame) = target(s, p)?;
|
||||
let frame = key_frame(s, p)?;
|
||||
for id in target_layers(s, p)? {
|
||||
let layer = s.layer_mut(Some(id))?;
|
||||
// Inside a motion tween F6 keys every property there; the span stays whole.
|
||||
@@ -401,15 +436,38 @@ fn insert_keyframe(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
insert_keyframe_at(layer, frame, true)?;
|
||||
}
|
||||
}
|
||||
Ok(json!({"keyframe": frame}))
|
||||
advanced(s, p, frame)
|
||||
}
|
||||
|
||||
fn insert_blank_keyframe(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let (_, frame) = target(s, p)?;
|
||||
let frame = key_frame(s, p)?;
|
||||
for id in target_layers(s, p)? {
|
||||
insert_keyframe_at(s.layer_mut(Some(id))?, frame, false)?;
|
||||
}
|
||||
Ok(json!({"keyframe": frame}))
|
||||
advanced(s, p, frame)
|
||||
}
|
||||
|
||||
/// Where F6 / F7 put the key. With `advance`, a frame that is already a keyframe on every target
|
||||
/// layer means "the next one": pressing F6 again after drawing makes the next drawing's key.
|
||||
fn key_frame(s: &Session, p: &Value) -> Result<u32> {
|
||||
let (_, frame) = target(s, p)?;
|
||||
if !opt_bool(p, "advance")?.unwrap_or(false) {
|
||||
return Ok(frame);
|
||||
}
|
||||
let ids = target_layers(s, p)?;
|
||||
let tl = s.timeline();
|
||||
let on_keys = !ids.is_empty() && ids.iter().all(|id| tl.layer(*id).is_some_and(|l| l.keyframe_starting_at(frame).is_some()));
|
||||
if on_keys && frame < MAX_FRAME { Ok(frame + 1) } else { Ok(frame) }
|
||||
}
|
||||
|
||||
/// The result of F6 / F7; with `advance` the playhead moves onto the new key.
|
||||
fn advanced(s: &mut Session, p: &Value, frame: u32) -> Result<Value> {
|
||||
let mut out = json!({"keyframe": frame});
|
||||
if opt_bool(p, "advance")?.unwrap_or(false) {
|
||||
s.set_frame(frame);
|
||||
out["playhead"] = json!(frame);
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// Shift+F6 over a range: clears every keyframe starting in `frame..frame + count` on each
|
||||
|
||||
@@ -1047,4 +1047,8 @@ mod template_tests;
|
||||
#[cfg(test)]
|
||||
mod timeline_drop_tests;
|
||||
#[cfg(test)]
|
||||
mod timeline_key_tests;
|
||||
#[cfg(test)]
|
||||
mod tests_bone_chain;
|
||||
#[cfg(test)]
|
||||
mod path_text_tests;
|
||||
@@ -0,0 +1,97 @@
|
||||
//! A bone chain stays one chain (user report #239): bones join end to start wherever the Bone
|
||||
//! tool's drag began on an instance, lengths hold, the joints stay joined through many IK drags,
|
||||
//! a small pointer move is a small turn, and grabbing a bone along its length doesn't snap its
|
||||
//! end to the pointer.
|
||||
|
||||
use super::*;
|
||||
use crate::tests_bone::{ARM, HAND, ROOT, three_bars};
|
||||
use anicraft_doc::armature;
|
||||
use anicraft_geom::Vec2;
|
||||
use serde_json::json;
|
||||
|
||||
fn run(s: &mut Session, id: &str, p: Value) -> Value {
|
||||
s.execute(id, &p).unwrap_or_else(|e| panic!("{id} {p}: {e}"))
|
||||
}
|
||||
|
||||
fn bones(s: &mut Session) -> Vec<Value> {
|
||||
run(s, "bone.info", json!({}))["armatures"][0]["bones"].as_array().cloned().unwrap_or_default()
|
||||
}
|
||||
|
||||
fn pt(v: &Value) -> Vec2 {
|
||||
Vec2::new(v[0].as_f64().unwrap_or(f64::NAN) as f32, v[1].as_f64().unwrap_or(f64::NAN) as f32)
|
||||
}
|
||||
|
||||
/// The reporter's steps: a bone from the first bar to the second, then one from the second bar
|
||||
/// to the third, started on the bar a little way from the first bone's end (as a quick drag does).
|
||||
fn drawn_by_hand() -> (Session, u64, u64) {
|
||||
let mut s = three_bars();
|
||||
let b1 = run(&mut s, "bone.add", json!({"from": ROOT, "to": ARM, "head": [150, 100], "tail": [250, 100]}))["bone"].as_u64().unwrap();
|
||||
let b2 = run(&mut s, "bone.add", json!({"from": ARM, "to": HAND, "head": [262, 103], "tail": [350, 100]}))["bone"].as_u64().unwrap();
|
||||
(s, b1, b2)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_bone_from_an_instance_on_a_chain_starts_at_its_joint() {
|
||||
let (mut s, _, _) = drawn_by_hand();
|
||||
let bs = bones(&mut s);
|
||||
assert!(pt(&bs[1]["head"]).distance(pt(&bs[0]["tail"])) < 1e-3, "the second bone starts where the first ends: {} vs {}", bs[1]["head"], bs[0]["tail"]);
|
||||
// A root's bones still start where they were drawn (a torso's shoulders and hips).
|
||||
let mut s = three_bars();
|
||||
run(&mut s, "bone.add", json!({"from": ROOT, "to": ARM, "head": [150, 100]}));
|
||||
run(&mut s, "bone.add", json!({"from": ROOT, "to": HAND, "head": [180, 100]}));
|
||||
let bs = bones(&mut s);
|
||||
assert!(pt(&bs[0]["head"]).distance(Vec2::new(150.0, 100.0)) < 1e-3);
|
||||
assert!(pt(&bs[1]["head"]).distance(Vec2::new(180.0, 100.0)) < 1e-3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn repeated_ik_drags_keep_the_chain_joined_and_its_lengths() {
|
||||
let (mut s, _, b2) = drawn_by_hand();
|
||||
let lengths = |bs: &[Value]| bs.iter().map(|b| pt(&b["head"]).distance(pt(&b["tail"]))).collect::<Vec<f32>>();
|
||||
let first = lengths(&bones(&mut s));
|
||||
let mut prev: Option<Vec<f64>> = None;
|
||||
// Round and round, in and out of reach, several times over (400 small pointer moves).
|
||||
for i in 0..400 {
|
||||
let t = i as f32 / 400.0 * std::f32::consts::TAU * 3.0;
|
||||
let r = 40.0 + 170.0 * (t * 0.5).sin().abs();
|
||||
let (x, y) = (150.0 + r * t.cos(), 100.0 + r * t.sin());
|
||||
run(&mut s, "bone.solve", json!({"bone": b2, "x": x, "y": y}));
|
||||
let bs = bones(&mut s);
|
||||
assert!(pt(&bs[0]["tail"]).distance(pt(&bs[1]["head"])) < 1e-3, "the elbow came apart at step {i}");
|
||||
for (a, b) in lengths(&bs).iter().zip(&first) {
|
||||
assert!((a - b).abs() < 1e-2, "a bone changed length at step {i}: {a} vs {b}");
|
||||
}
|
||||
let angles: Vec<f64> = bs.iter().map(|b| b["angle"].as_f64().unwrap_or(0.0)).collect();
|
||||
if let Some(p) = &prev {
|
||||
let turn = angles.iter().zip(p).map(|(a, b)| (a - b).abs()).fold(0.0, f64::max);
|
||||
// About 4 px of pointer travel per step at 40–210 px from the shoulder.
|
||||
assert!(turn < 30.0, "a small move turned a joint {turn:.1}° at step {i}");
|
||||
}
|
||||
prev = Some(angles);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn grabbing_a_bone_along_its_length_moves_from_where_it_was_grabbed() {
|
||||
let (mut s, b1, _) = drawn_by_hand();
|
||||
let (l, arm) = {
|
||||
let l = s.timeline().layers.iter().find(|l| l.armature.is_some()).cloned().unwrap();
|
||||
let arm = l.armature.clone().unwrap();
|
||||
(l, arm)
|
||||
};
|
||||
let (_, els) = anicraft_doc::evaluate_layer_elements(&l, 0).unwrap();
|
||||
let pose = armature::pose_at(&l, 0).unwrap_or_default();
|
||||
// Pressed a quarter of the way along the first bone, near the shoulder.
|
||||
let press = Vec2::new(175.0, 100.0);
|
||||
let local = armature::grab_point(&arm, &els, &pose, anicraft_doc::BoneId(b1), press).unwrap();
|
||||
let v = run(&mut s, "bone.solve", json!({"bone": b1, "x": press.x, "y": press.y, "local": [local.x, local.y]}));
|
||||
assert!(v["error"].as_f64().unwrap() < 0.05, "{v}");
|
||||
let bs = bones(&mut s);
|
||||
assert!(bs[0]["angle"].as_f64().unwrap().abs() < 1e-3, "pressing alone turns nothing");
|
||||
// A small drag down turns the bone a little about the shoulder: the grabbed point follows.
|
||||
run(&mut s, "bone.solve", json!({"bone": b1, "x": 175.0, "y": 105.0, "local": [local.x, local.y]}));
|
||||
let a = bones(&mut s)[0]["angle"].as_f64().unwrap();
|
||||
assert!((a - 5.0f64.atan2(25.0).to_degrees()).abs() < 0.5, "{a}°");
|
||||
// The bone's end, by contrast, would have been pulled 75 px onto the pointer.
|
||||
assert!(armature::grab_point(&arm, &els, &pose, anicraft_doc::BoneId(999), press).is_none());
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
//! F5, F6 and F7 as the keys work in the editor (user reports #242 and #254).
|
||||
|
||||
use super::*;
|
||||
use anicraft_doc::{Keyframe, LayerId};
|
||||
use serde_json::json;
|
||||
use std::sync::Arc;
|
||||
|
||||
fn run(s: &mut Session, id: &str, p: Value) -> Value {
|
||||
match s.execute(id, &p) {
|
||||
Ok(v) => v,
|
||||
Err(e) => panic!("{id} {p}: {e}"),
|
||||
}
|
||||
}
|
||||
|
||||
fn spans(s: &Session, layer: LayerId) -> Vec<(u32, u32)> {
|
||||
s.timeline().layer(layer).unwrap().keyframes.iter().map(|k| (k.start, k.duration)).collect()
|
||||
}
|
||||
|
||||
/// A layer whose keyframes are exactly `keys` (start, duration).
|
||||
fn layer_with(s: &mut Session, keys: &[(u32, u32)]) -> LayerId {
|
||||
let id = LayerId(run(s, "layer.new", json!({}))["layer"].as_u64().unwrap());
|
||||
let l = s.layer_mut(Some(id)).unwrap();
|
||||
l.keyframes = keys.iter().map(|&(a, d)| Arc::new(Keyframe::new(a, d))).collect();
|
||||
id
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn f5_with_no_frame_selection_extends_every_layer_that_reaches_the_playhead() {
|
||||
// The report's example: playhead at frame 5 (index 4).
|
||||
let mut s = Session::default();
|
||||
let l1 = layer_with(&mut s, &[(0, 8)]);
|
||||
let l2 = layer_with(&mut s, &[(0, 4)]);
|
||||
let l3 = layer_with(&mut s, &[(0, 6)]);
|
||||
let l4 = layer_with(&mut s, &[(0, 2), (2, 7)]);
|
||||
// Content only after the playhead, and a gap under it: both move along.
|
||||
let later = layer_with(&mut s, &[(6, 3)]);
|
||||
let gap = layer_with(&mut s, &[(0, 2), (7, 2)]);
|
||||
let first = s.timeline().layers.iter().find(|l| ![l1, l2, l3, l4, later, gap].contains(&l.id)).map(|l| l.id).unwrap();
|
||||
s.layer_mut(Some(first)).unwrap().keyframes = vec![Arc::new(Keyframe::new(0, 1))];
|
||||
s.layer = l2;
|
||||
s.set_frame(4);
|
||||
let v = run(&mut s, "timeline.insert_frame", json!({"all_layers": true}));
|
||||
assert_eq!(spans(&s, l1), vec![(0, 9)], "frames 1–8: extended");
|
||||
assert_eq!(spans(&s, l2), vec![(0, 4)], "frames 1–4 end before the playhead: unchanged, even when active");
|
||||
assert_eq!(spans(&s, l3), vec![(0, 7)], "frames 1–6: extended");
|
||||
assert_eq!(spans(&s, l4), vec![(0, 2), (2, 8)], "frames 1–9: extended");
|
||||
assert_eq!(spans(&s, later), vec![(7, 3)], "a key after the playhead moves one frame later");
|
||||
assert_eq!(spans(&s, gap), vec![(0, 2), (8, 2)], "a gap under the playhead grows by one");
|
||||
assert_eq!(spans(&s, first), vec![(0, 1)]);
|
||||
assert_eq!(v["layers"].as_array().unwrap().len(), 5);
|
||||
assert_eq!(s.frame, 4, "without advance the playhead stays");
|
||||
// One undo step takes it back on every layer.
|
||||
run(&mut s, "edit.undo", json!({}));
|
||||
assert_eq!(spans(&s, l1), vec![(0, 8)]);
|
||||
assert_eq!(spans(&s, l4), vec![(0, 2), (2, 7)]);
|
||||
assert_eq!(spans(&s, gap), vec![(0, 2), (7, 2)]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn f5_past_every_layer_lengthens_the_active_one() {
|
||||
let mut s = Session::default();
|
||||
let a = layer_with(&mut s, &[(0, 3)]);
|
||||
let b = layer_with(&mut s, &[(0, 5)]);
|
||||
s.layer = a;
|
||||
s.set_frame(9);
|
||||
run(&mut s, "timeline.insert_frame", json!({"all_layers": true, "advance": true}));
|
||||
assert_eq!(spans(&s, a), vec![(0, 10)], "extended up to the playhead");
|
||||
assert_eq!(spans(&s, b), vec![(0, 5)]);
|
||||
assert_eq!(s.frame, 9, "the frame made is the playhead's own");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn f5_advance_moves_the_playhead_onto_the_new_frame() {
|
||||
let mut s = Session::default();
|
||||
let a = layer_with(&mut s, &[(0, 1)]);
|
||||
s.layer = a;
|
||||
for want in 1..4 {
|
||||
let v = run(&mut s, "timeline.insert_frame", json!({"layer": a.0, "advance": true}));
|
||||
assert_eq!(s.frame, want);
|
||||
assert_eq!(v["playhead"], json!(want));
|
||||
}
|
||||
assert_eq!(spans(&s, a), vec![(0, 4)], "holding F5 walks along, one frame each");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn f6_on_a_keyframe_keys_the_next_frame_and_follows() {
|
||||
let mut s = Session::default();
|
||||
let a = layer_with(&mut s, &[(0, 1)]);
|
||||
s.layer = a;
|
||||
run(&mut s, "draw.rect", json!({"x": 0, "y": 0, "w": 10, "h": 10}));
|
||||
for want in 1..4 {
|
||||
run(&mut s, "timeline.insert_keyframe", json!({"advance": true}));
|
||||
assert_eq!(s.frame, want, "F6 on a keyframe makes the next one and goes there");
|
||||
}
|
||||
assert_eq!(spans(&s, a), vec![(0, 1), (1, 1), (2, 1), (3, 1)]);
|
||||
assert_eq!(s.timeline().layer(a).unwrap().keyframes[3].elements.len(), 1, "a copy of the drawing");
|
||||
// Inside a span (not on its key) F6 keys the playhead's own frame.
|
||||
run(&mut s, "timeline.insert_frame", json!({"layer": a.0, "frame": 3, "count": 3}));
|
||||
s.set_frame(5);
|
||||
run(&mut s, "timeline.insert_keyframe", json!({"advance": true}));
|
||||
assert_eq!(s.frame, 5);
|
||||
assert_eq!(spans(&s, a), vec![(0, 1), (1, 1), (2, 1), (3, 2), (5, 2)]);
|
||||
// Without advance (scripts), the old behaviour: nothing new on a keyframe.
|
||||
run(&mut s, "timeline.insert_keyframe", json!({}));
|
||||
assert_eq!(s.frame, 5);
|
||||
assert_eq!(spans(&s, a).len(), 5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn f7_on_a_keyframe_makes_a_blank_one_next_instead_of_clearing() {
|
||||
let mut s = Session::default();
|
||||
let a = layer_with(&mut s, &[(0, 1)]);
|
||||
s.layer = a;
|
||||
run(&mut s, "draw.rect", json!({"x": 0, "y": 0, "w": 10, "h": 10}));
|
||||
run(&mut s, "timeline.insert_blank_keyframe", json!({"advance": true}));
|
||||
assert_eq!(s.frame, 1);
|
||||
let l = s.timeline().layer(a).unwrap();
|
||||
assert_eq!(l.keyframes[0].elements.len(), 1, "the drawing is kept");
|
||||
assert!(l.keyframes[1].elements.is_empty(), "a blank key on the next frame");
|
||||
// Across two layers it advances only when both are on a keyframe.
|
||||
let b = layer_with(&mut s, &[(0, 4)]);
|
||||
run(&mut s, "timeline.insert_blank_keyframe", json!({"layers": [a.0, b.0], "frame": 1, "advance": true}));
|
||||
assert_eq!(s.frame, 1);
|
||||
assert_eq!(spans(&s, b), vec![(0, 1), (1, 3)]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn advance_at_the_last_frame_stays_in_range() {
|
||||
let mut s = Session::default();
|
||||
let a = layer_with(&mut s, &[(MAX_FRAME - 1, 2)]);
|
||||
s.layer = a;
|
||||
s.set_frame(MAX_FRAME);
|
||||
assert!(s.execute("timeline.insert_frame", &json!({"advance": true})).is_err());
|
||||
s.layer_mut(Some(a)).unwrap().keyframes = vec![Arc::new(Keyframe::new(MAX_FRAME, 1))];
|
||||
let _ = s.execute("timeline.insert_keyframe", &json!({"advance": true}));
|
||||
assert!(s.frame <= MAX_FRAME);
|
||||
}
|
||||
@@ -32,7 +32,7 @@ The policy is one shell with platform decisions isolated in one module, rather t
|
||||
|---|---|---|---|
|
||||
| Shortcuts | `Ctrl` in the registry = **⌘**; labels use Apple order and glyphs (⇧⌘S), or "Shift+Cmd+S" when the font lacks them (checked at runtime) | Ctrl labels | Ctrl labels |
|
||||
| Application menu | **AniCraft** menu: About, Settings… (⌘,), Quit (⌘Q) | File › Exit (Ctrl+Q), Edit › Preferences… (Ctrl+U, as in Animate) | as Windows |
|
||||
| Window chrome | Unified title bar: full-size content view, title hidden, menu row inset for the traffic lights | Native frame | Native frame (X11 or Wayland chosen by winit; app id `anicraft` for window rules and docks) |
|
||||
| Window chrome | Unified title bar: full-size content view, transparent title bar (an opaque one covers the menu row: #247), title hidden, menu row inset for the traffic lights | Native frame | Native frame (X11 or Wayland chosen by winit; app id `anicraft` for window rules and docks) |
|
||||
| File dialogs | Native panels (rfd) | Common dialogs (rfd) | **XDG desktop portal** (rfd). A Preferences switch falls back to a built-in path field on desktops without a portal |
|
||||
| GPU backend | wgpu → Metal | wgpu → DX12/Vulkan | wgpu → Vulkan; **automatic retry with OpenGL** (glow) if wgpu cannot start (VMs, old GPUs, missing drivers); `--renderer gl` / `ANICRAFT_RENDERER` to force |
|
||||
| Settings folder | ~/Library/Application Support/AniCraft | %APPDATA%\AniCraft | $XDG_CONFIG_HOME/anicraft |
|
||||
|
||||
@@ -57,8 +57,12 @@ list, and every edit is a command.
|
||||
6. **Commands** (`bone.*`, a document namespace plug-ins may call): `bone.add {from, to,
|
||||
head?, tail?}` moves both instances to a new armature layer above them (one pose spanning
|
||||
from their keyframe to the end of the timeline, a classic tween on it) or adds the new one
|
||||
to an existing armature (in every pose, at angle 0); a new bone's joint defaults to the end
|
||||
of the bone into `from`, so chains join end to start. `bone.remove` takes a bone and those
|
||||
to an existing armature (in every pose, at angle 0). An instance that hangs from a bone has
|
||||
one joint, that bone's end: every bone from it starts there, wherever on the instance the
|
||||
drag began, so chains always join end to start (a root's bones start where they are drawn,
|
||||
by default at its registration point). Until #239 a given `head` won anywhere on the
|
||||
instance, so a drag started a few pixels off the end left the chain looking broken and
|
||||
turning about joints it didn't show. `bone.remove` takes a bone and those
|
||||
below it out of every pose; the instances they moved go to a normal layer of their own, as
|
||||
they look at the playhead; with the last bone the whole armature does and its layer goes.
|
||||
It asks first when the armature has more than one pose (undoable tier, ADR 0004).
|
||||
@@ -74,8 +78,10 @@ list, and every edit is a command.
|
||||
draw over the artwork as wedges, widest by the round joint and narrowing to a smaller round
|
||||
end, in the armature layer's colour (green by default), the picked bone in the selection
|
||||
colour; they fade with other tools and on locked layers. The **Selection tool** drags a
|
||||
bone, or an instance a bone moves (the grabbed point follows the pointer), to pose by IK,
|
||||
and the root instance to move the armature; each drag is one undo step. Properties shows a
|
||||
bone, or an instance a bone moves, to pose by IK: the grabbed point follows the pointer
|
||||
(a bone's end when the press is on it; along a bone, the point pressed, so the bone never
|
||||
jumps to put its end under the pointer, #239). The root instance, or the joint a root's bone
|
||||
starts at, moves the armature; each drag is one undo step. Properties shows a
|
||||
**Bone** section: the joint angle at the playhead, Constrain rotation with min and max, Pin,
|
||||
and Remove Bone; Delete removes the picked bone. The timeline shows the armature layer with
|
||||
a bone icon.
|
||||
|
||||
@@ -155,8 +155,12 @@ called inverse kinematics.
|
||||
2. Pick the **Bone** tool (**M**).
|
||||
3. Drag from one instance (for example, the upper arm) to the next (the forearm). A bone joins
|
||||
them, and both move to a new **armature** layer, shown with a bone icon in the timeline.
|
||||
4. To continue the chain, drag from the end of the last bone to the next instance (the hand).
|
||||
5. To branch, drag from any instance of the armature to another one.
|
||||
4. To continue the chain, drag from the last instance (the forearm) to the next one (the
|
||||
hand). The new bone always starts at the end of the bone before it, wherever on the
|
||||
instance you began, so the chain stays joined.
|
||||
5. To branch, drag from any instance of the armature to another one. Branches from the first
|
||||
instance (the root, such as a torso) start where you begin the drag; branches from any other
|
||||
instance start at its joint.
|
||||
|
||||
Bones show on the stage as wedges, from a round joint to their end, in the armature layer's
|
||||
colour. Click a bone to select it.
|
||||
@@ -165,9 +169,10 @@ colour. Click a bone to select it.
|
||||
|
||||
With the **Selection** tool (**V**):
|
||||
|
||||
* drag a bone or an instance, and the bones above it turn so it follows the pointer. If the point
|
||||
is out of reach, the chain stretches straight towards it;
|
||||
* drag the root instance to move the whole armature.
|
||||
* drag a bone or an instance, and the bones above it turn so the point you grabbed follows the
|
||||
pointer (drag a bone's end to pull the end). If the point is out of reach, the chain stretches
|
||||
straight towards it;
|
||||
* drag the root instance, or the joint its first bone starts at, to move the whole armature.
|
||||
|
||||
Each drag is one undo step.
|
||||
|
||||
|
||||
@@ -96,13 +96,13 @@ This page is generated from the command registry, so it always matches the versi
|
||||
## Insert
|
||||
|
||||
- **Frame** `timeline.insert_frame` · Insert › Timeline · **F5** · changes the document
|
||||
Parameters: `{layer? | layers?: [..], frame?, count?}`
|
||||
Parameters: `{layer? | layers?: [..] | all_layers?: true (every layer with frames at or after the frame, as F5 with no frame selection; the active layer when none has), frame?, count?, advance?: true (the playhead moves onto the last frame inserted, as the key does in the editor)}`
|
||||
- **Remove Frame** `timeline.remove_frame` · Insert › Timeline · **Shift+F5** (macOS **⇧F5**) · changes the document
|
||||
Parameters: `{layer? | layers?: [..], frame?, count?}`
|
||||
- **Keyframe** `timeline.insert_keyframe` · Insert › Timeline · **F6** · changes the document
|
||||
Parameters: `{layer? | layers?: [..], frame?}`
|
||||
Parameters: `{layer? | layers?: [..], frame?, advance?: true (on a keyframe the new key goes on the next frame, and the playhead moves onto it, as the key does in the editor)}`
|
||||
- **Blank Keyframe** `timeline.insert_blank_keyframe` · Insert › Timeline · **F7** · changes the document
|
||||
Parameters: `{layer? | layers?: [..], frame?}`
|
||||
Parameters: `{layer? | layers?: [..], frame?, advance?: true (on a keyframe the blank key goes on the next frame instead of clearing it, and the playhead moves onto it)}`
|
||||
- **Clear Keyframe** `timeline.clear_keyframe` · Insert › Timeline · **Shift+F6** (macOS **⇧F6**) · changes the document
|
||||
Parameters: `{layer? | layers?: [..], frame?, count?}`
|
||||
- **Create Motion Tween** `timeline.create_motion_tween` · changes the document
|
||||
@@ -292,7 +292,7 @@ These commands have no menu item: the panels, the stage and the timeline use the
|
||||
- **Layer Depth** `layer.set_depth` · changes the document
|
||||
Parameters: `{depth (px behind the stage, −500…10000; deeper layers move less when the camera pans), layer?}`
|
||||
- **Add Bone** `bone.add` · changes the document
|
||||
Parameters: ``{from (instance id: the bone starts on it), to (instance id: the bone moves it), head?: [x, y] (the joint, stage px; default the end of the bone into `from`, else its registration point), tail?: [x, y] (default `to`'s registration point), name?} → {bone, layer}. Both instances go to an armature layer (made for the first bone)``
|
||||
Parameters: ``{from (instance id: the bone starts on it), to (instance id: the bone moves it), head?: [x, y] (the joint on a root instance, stage px, default its registration point; from an instance that hangs from a bone the joint is always that bone's end, so chains stay joined), tail?: [x, y] (default `to`'s registration point), name?} → {bone, layer}. Both instances go to an armature layer (made for the first bone)``
|
||||
- **Add Bone in Shape** `bone.add_in_shape` · changes the document
|
||||
Parameters: `{shape? (shape id: the first bone, or another bone from the shape), parent? (bone id: continue the chain from its end), head?: [x, y] (the joint, stage px; default the parent bone's end), tail: [x, y] (stage px), name?} → {bone, layer, created, points}. The first bone moves the shape to an armature layer of its own, as an object (merge drawing leaves it alone); the shape's points are bound to the nearest bones`
|
||||
- **Bind Points** `bone.bind` · changes the document
|
||||
|
||||
+17
-3
@@ -19,7 +19,8 @@ The timeline sits under the stage. From left to right, its header holds:
|
||||
* the onion skin buttons and their options menu;
|
||||
* the camera button;
|
||||
* the current frame number, the frame rate and the time at the playhead;
|
||||
* the **Frame**, **Keyframe** and **Blank** buttons, and a tween menu.
|
||||
* the **Insert frame**, **Insert keyframe** and **Insert blank keyframe** buttons (a frame, a
|
||||
filled dot and a hollow dot, each with a plus), and a tween menu.
|
||||
|
||||
Under the header, the layer list is on the left and the frame grid on the right, with the frame
|
||||
ruler along the top. The bar at the bottom has buttons for new layers and folders, deleting and
|
||||
@@ -110,8 +111,21 @@ with nothing on it, so the layer is empty from there on.
|
||||
| Insert a blank keyframe | **F7** | **Insert › Timeline › Blank Keyframe** |
|
||||
| Turn a keyframe back into a plain frame | **Shift+F6** | **Insert › Timeline › Clear Keyframe** |
|
||||
|
||||
The **Frame**, **Keyframe** and **Blank** buttons in the timeline header do the same, and so
|
||||
does the right-click menu on the frames.
|
||||
The **Insert frame**, **Insert keyframe** and **Insert blank keyframe** buttons in the timeline
|
||||
header do the same, and so does the right-click menu on the frames.
|
||||
|
||||
As in Animate, the keys keep you moving along the timeline:
|
||||
|
||||
* **F5** moves the playhead onto the frame it adds, so holding it down walks along the timeline.
|
||||
* **F6** or **F7** on a frame that is already a keyframe adds the new keyframe on the *next*
|
||||
frame and moves there, so you can draw, press **F6**, draw again, and so on. On any other
|
||||
frame they key the frame you're on.
|
||||
* With no frames selected (for example after scrubbing the playhead), **F5** adds a frame on
|
||||
every layer that has frames at or after the playhead, so the layers stay in step. Layers that
|
||||
end before the playhead are left alone. When no layer reaches the playhead, it lengthens the
|
||||
layer you're on up to it.
|
||||
* With a frame selected, the keys act on that frame's layer, and the selection moves with the
|
||||
playhead.
|
||||
|
||||
An empty frame shows a hint in **Properties › Frame**: press **F7** to start drawing there.
|
||||
|
||||
|
||||
+11
-1
@@ -16,7 +16,7 @@ AniCraft has a single window with fixed, docked panels:
|
||||
| Area | Where | What it's for |
|
||||
|---|---|---|
|
||||
| Menu bar | top | Every command, grouped as in Animate: File, Edit, View, Insert, Modify, Commands, Control, Window, Help. On macOS there's also the AniCraft menu, with About, Settings… and Quit. |
|
||||
| Edit bar | above the stage | The scene menu, the path to the symbol you're editing, the active layer, the stage size, an **Onion skin** switch and the zoom menu. |
|
||||
| Edit bar | above the stage | The scene menu, the path to the symbol you're editing, the active layer, the stage size, an **Onion skin** switch, the **Clip content outside the stage** button and the zoom menu. |
|
||||
| Tools | left | The drawing and editing tools, the **Snap to Objects** magnet, and the current fill and stroke colours. |
|
||||
| Stage | middle | Your artwork. The stage rectangle is what the movie shows. You can draw on the grey area around it too. |
|
||||
| Timeline and Motion Editor | bottom | Layers, frames and playback. The **Motion Editor** tab beside it shows a motion tween's property curves. |
|
||||
@@ -92,6 +92,16 @@ lets you change them (see [Preferences, shortcuts and accessibility](preferences
|
||||
| See the stage at actual size | **View › 100%** (**Ctrl+1**) |
|
||||
| Jump to a set zoom | the zoom menu at the right of the edit bar: Fit in window, 25 % to 800 % |
|
||||
|
||||
### The pasteboard
|
||||
|
||||
The grey area around the stage is the **pasteboard**. You can draw, paste and park artwork
|
||||
there, as in Animate: notes for yourself, spare drawings, or a background wider than the stage
|
||||
that a tween slides across. Only what is on the stage shows in Test Movie and in exports.
|
||||
|
||||
To hide everything outside the stage while you work, click **Clip content outside the stage**
|
||||
(the frame with crop marks, left of the zoom menu), or choose **View › Clip Content Outside the
|
||||
Stage**. The artwork is still there; click again to see it.
|
||||
|
||||
### Rulers, grids and guides
|
||||
|
||||
AniCraft doesn't have rulers, a grid or draggable guides yet. Until then:
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ milestone ends with a green tree: build, tests, clippy, a `--screenshot` check a
|
||||
|---|---|
|
||||
| Architecture | M0 skeleton in place: geom → doc → render → engine → cli → shell, layering enforced by `cargo test` (`src/architecture_tests.rs`: lower layers only, no UI crates below the shell, and the AGENTS.md map must match). |
|
||||
| Rendering | CPU oracle with analytic AA, non-zero/even-odd, solid + linear/radial gradients, round-join strokes. **Mask clipping**: the display list carries nested clips; a clip is the anti-aliased union of its mask fills (strokes and opacity ignored), intersected with any enclosing clip, computed once per render band; an empty mask hides everything under it. **Soft masks** (ADR 0070): a mask layer's mask type is Shape (coverage), Alpha (its artwork's opacity as drawn: gradients, faded shapes, strokes, bitmaps) or Luminance (brightness × opacity, SVG's coefficients), in the CPU oracle (analytic tests), the GPU stage (parity: mean 0.00006, worst 1 step of 255), SVG export (`<mask>` with `mask-type`), Lottie (alpha and luma track mattes) and the HTML canvas; Layer Properties › Mask type. **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). **Fourth slice** (ADR 0048): **tile binning on the GPU** for heavy frames without masks or groups (count, prefix sum, scatter and tile-list passes, no atomics, no readback; the CPU binning stays the reference and does the rest; one tile format for both: an integer backdrop per tile and steps on the tiles' left edges): on Vulkan, 10k shapes at 4K in one texture 21.7 → 4.7 ms, 50k shapes 122 → 22.5 ms, the 50k-shape 4K stage 75 → 37 ms (Direct3D 12 keeps CPU binning: slower therLine truncated
|
||||
| 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), **timeline polish** (ADR 0061): a per-layer **onion skin toggle** column (Alt-click solos; left-out layers aren't onion-skinned; Edit Multiple Frames unaffected), the colour square toggles **View as Outlines** in the layer colour **on the stage only** (exports, Test Movie and the player draw the artwork as it is), the **colour chip** opens the layer colour (swatches, hex, More…), **onion frames of the parent timeline** dimmed around a symbol edited in place, **Layer Height** 100/200/300 %, **Layer Properties** (double-click the layer icon; name, show/lock, type, outline colour, outlines, onion, height; one undo step), **Frame View** (Tiny/Small/Normal/Medium/Large, Short rows) with the frame zoom in the timeline's bottom bar (the header fits at the default window size, tested); headless `layer.set_onion/set_color/set_height/set_properties/properties`; XFL `heightMultiplier`. Not yet: folder onion toggles, onion of deeper parent timelines, multi-layer Layer Properties and layer transparency, frame thumbnails (Preview). 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, looping playback. **Onion skin and Edit Multiple Frames** (ADR 0047): onion markers on the frame ruler (drag the start and end brackets; Always Show Markers, Anchor Markers, Onion 2 / Onion 5 / Onion All, also on a right-click on the ruler), frames before and after the playhead tinted in their own colours (theme blue and green, changeable in the onion menu, Reset) and fading with distance, Outlines, Keyframes Only, locked layers left out as in Animate, each layer's onion frames under its own artwork and over the layers below; options saved in the preferences; the stage's frame cache keys every look apart. **Edit Multiple Frames** shows every keyframe within the markers at full strength and selects (click, Shift-click, marquee, Select All) and moves (drag, arrow keys) artwork across them, one undo step, motion tween paths moving with their objects. Headless: `frames.artwork`, `frames.edit_multiple`. **Edit Multiple Frames, complete** (ADR 0051): Cut, Copy, Paste (current frame), Paste in Place (back keyframe by keyframe, or a one-frame copy onto every keyframe between the markers), Clear, Align (Ctrl+Alt+1…6, To Stage), Rotate 90° and Flip, and **Free Transform** of the selection on every keyframe about one shared pivot (one box, one undo step per drag); raw shapes moved, transformed or pasted merge again on their own keyframe; **onion skin and Edit Multiple Frames inside a symbol edited in place**, on its own timeline and markers. Headless: `frames.transform`, `frames.align`, `frames.delete`, `frames.copy`, `frames.cut`, `frames.paste`, `frames.merge`, `merge` on `frames.edit_multiple`. Not yet: per-layer onion toggles, Duplicate/DistrLine truncated
|
||||
| Timeline | **Frame selection**: click, Shift-click or drag across frames and layers; F5/Shift+F5, F6/F7 and Shift+F6 (keys, icon buttons and right-click menu) act on the whole selection; with no frame selection F5 extends every layer with frames at or after the playhead, and F5/F6/F7 move the playhead on as in Animate (F6/F7 on a keyframe key the next frame; `all_layers`/`advance` headless); 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), **timeline polish** (ADR 0061): a per-layer **onion skin toggle** column (Alt-click solos; left-out layers aren't onion-skinned; Edit Multiple Frames unaffected), the colour square toggles **View as Outlines** in the layer colour **on the stage only** (exports, Test Movie and the player draw the artwork as it is), the **colour chip** opens the layer colour (swatches, hex, More…), **onion frames of the parent timeline** dimmed around a symbol edited in place, **Layer Height** 100/200/300 %, **Layer Properties** (double-click the layer icon; name, show/lock, type, outline colour, outlines, onion, height; one undo step), **Frame View** (Tiny/Small/Normal/Medium/Large, Short rows) with the frame zoom in the timeline's bottom bar (the header fits at the default window size, tested); headless `layer.set_onion/set_color/set_height/set_properties/properties`; XFL `heightMultiplier`. Not yet: folder onion toggles, onion of deeper parent timelines, multi-layer Layer Properties and layer transparency, frame thumbnails (Preview). 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, looping playback. **Onion skin and Edit Multiple Frames** (ADR 0047): onion markers on the frame ruler (drag the start and end brackets; Always Show Markers, Anchor Markers, Onion 2 / Onion 5 / Onion All, also on a right-click on the ruler), frames before and after the playhead tinted in their own colours (theme blue and green, changeable in the onion menu, Reset) and fading with distance, Outlines, Keyframes Only, locked layers left out as in Animate, each layer's onion frames under its own artwork and over the layers below; options saved in the preferences; the stage's frame cache keys every look apart. **Edit Multiple Frames** shows every keyframe within the markers at full strength and selects (click, Shift-click, marquee, Select All) and moves (drag, arrow keys) artwork across them, one undo step, motion tween paths moving with their objects. Headless: `frames.artwork`, `frames.edit_multiple`. **Edit Multiple Frames, complete** (ADR 0051): Cut, Copy, Paste (current frame), Paste in Place (back keyframe by keyframe, or a one-frame copy onto every keyframe between the markers), Clear, Align (Ctrl+Alt+1…6, To Stage), Rotate 90° and Flip, and **Free Transform** of the selection on every keyframe about one shared pivot (one box, one undo step per drag); raw shapes moved, transformed or pasted merge again on their own keyframe; **onion skin and Edit Multiple Frames inside a symbol edited in place**, on its own timeline and markLine truncated
|
||||
| Drawing | Selection (click, shift-add, marquee, drag-move, arrow nudge; **across layers**, ADR 0044: a selection holds artwork on several visible, unlocked layers, the timeline marks them, Properties shows mixed values), **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. **Stroke styles** (ADR 0046): Properties › Style (Solid, Dashed with dash and gap, Dotted with spacing), Cap (None, Round, Square), Join (Miter, Round, Bevel) and Miter limit, also in the drawing tools' options for new strokes; drawn exactly by the oracle (butt and square caps, miters bevelled past the limit, dashes by arc length restarting per subpath, round dots, dashes keeping a width profile's widths; sub-pixel patterns solid and faded) and so by the GPU stage; the Ink Bottle carries the style and the Eyedropper picks it; merge drawing keeps it on cut pieces; shape tweens blend miter limits and dash lengths; SVG, HTML canvas and Lottie export write it. Headless: `stroke.set_style`, and `cap`, `join`, `miter`, `style`, `dash`, `dash_offset`, `dot_spacing` on `element.set_stroke`, the drawing commands and `paint.ink`. Not yet: Animate's ragged, stipple and hatched styles, multi-dash patterns in Properties (kept and editable by command), stroke scale modes and hairlines. **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 Line 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. **A window of its own on the desktop** (ADR 0062): sized to the stage at 100 % (smaller to fit the screen), titled with the document, back where it was last (not on Wayland, where the desktop places windows), with the keyboard when it opens; Esc or Ctrl+W (⌘W) closes it, Ctrl+Enter restarts it in place, and the editor's Ctrl/Alt shortcuts work from it; floating inside the editor in the web build, where the system can't open windows (it says so), or by choice in Preferences › Test Movie. Not yet: full screen, zoom in the movie window, remembering its size. 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; **filters and Subtract/Invert in the page** (ADR 0072: `filters.js`, a port of the renderer's filters run over the group's pixels on a layer that reaches past the canvas by the filters' reach, Subtract and Invert composited per pixel, results kept while the group is unchanged; equal to the oracle's pixels within 9.3e-4 in Boa; 3.4 ms a frame for the demo's filters at 1080p while they change); Web Audio for Event/Start/Stop/Stream sounds; bitmap tints, 9-slice scaling and plug-in frame scripts reported. Not yet: 9-slice in the page, keeping a moving filtered group's pixels, filters off the main thread. **Kept frame scripts** (ADR 0013 tier 1): scripts written in another language (an Animate document's ActionScript) kept verbatim on keyframes with their language, symbol linkage classes and the document class; the Actions panel's **Script** view (monospace editor with line numbers, language, live and undoable), the same "a" marker, Class rows in Properties; `script.set/clear/list/set_class`; **ActionScript timeline subset runs** (ADR 0013 tier 2): a hand-written, bounded lexer and parser (`anicraft_actions::as3`) lower stop/play/go to/next and previous frame and scene on instance-name paths, mouse listeners (click, down, up, roll over and out; named or inline functions, `currentTarget`), `trace` and property settings to the action IR, compiled once per script; anything else is reported with line and column and the script doesn't run (never half-run), `navigateToURL` and the like are ignored and noted; the player keeps listeners per instance, Test Movie's Output says which scripts run and which don't and why, the Script view lists problems in place, the XFL report and `script.list/check` say what runs, and the HTML page runs the same steps (`player.js` checked against the Rust player). **ActionScript small logic** (ADR 0052): scripts compile to a small typed script IR evaluated by the player with fuel (100,000 per script or listener call, 1,000,000 per step; an endless loop or a run-time error stops its script with an Output line and the movie plays on): typed variables (Number, int, uint, Boolean, String, untyped) kept per timeline instance across its frame scripts, expressions as ECMA-262 has them, `if`/`else`, `for`/`while`/`do`, functions with parameters, results and recursion, called from any frame of the same timeline (a timeline-level link step; names that aren't there keep the script from running, said in place), property reads of instances and timelines (`x`, `y`, `alpha`, `visible`, `rotation`, `scaleX/Y`, `currentFrame`, `tLine truncated
|
||||
@@ -26,7 +26,7 @@ milestone ends with a green tree: build, tests, clippy, a `--screenshot` check a
|
||||
| Documentation | **User guide, first slice** (ADR 0069, `docs/guide/`): eighteen chapters for artists (getting started to troubleshooting, and Coming from Animate), a command reference and a shortcut reference (Windows/Linux and macOS) generated from the registry and checked for freshness by tests, every link, anchor and picture checked, eight screenshots from `scripts/guide-shots.sh`. Help › User Guide opens the book bundled in the app, offline, in the browser; the web build serves it beside the editor; `anicraft-cli guide --out <folder>` writes it. Not yet: translated guides, search, a PDF edition, context help from panels, macOS and Linux screenshots. |
|
||||
| Languages | **First slice** (ADR 0040, `docs/localisation.md`): every shell string goes through `tr!`/`trn!` (keyed by its English; placeholders; CLDR plurals for whole numbers), menus translate the registry's labels when drawn (ids, CLI, MCP and the file format stay English), screen-reader names too. Catalogs are craft-i18n's TSV, read by our own parser and embedded from `CRAFT_I18N_DIR` (fallback app → shared → base language → English). Preferences › Appearance › Language (system language by default) and `--lang`. A **pseudo-locale** (`--lang pseudo`: accented, a third longer, bracketed) tests layout; checked by a source guideline test and a pseudo-locale accessibility audit; `scripts/i18n-extract.sh` writes the translators' template and per-locale coverage. Not yet: a real language (craft-i18n has no `anicraft.tsv` yet), engine messages and confirmation bodies (`@msg`), default document names, right to left (needs bidi and shaping in egui upstream), CJK and Georgian (need a font), shaped scripts. |
|
||||
| Accessibility | **First pass** (ADR 0022, `docs/accessibility.md`): AccessKit (via eframe) gives every control a name and role, checked by a headless test that walks the tree in 23 interface states (custom-painted tools, layer rows and toggles, icon buttons, Library rows, every Properties field, the Motion Editor, every dialog; the stage is a named canvas; the status bar a polite live region). **Ctrl+F6 / Ctrl+Shift+F6** move focus between Stage, Timeline, Properties, Library and Tools (rebindable); focused controls keep Enter/Space/arrows while other shortcuts still work; pointer-only surfaces are not Tab stops. **High contrast** palette (Preferences › Theme) from the same roles, text ≥ 7:1, controls and focus ≥ 3:1; both palettes checked by the contrast test (the graphite one now meets AA everywhere). **Interface scale** 75–200 % holds up (stage refits, tools and timeline header scroll, status truncates). **Second pass** (ADR 0064): while the stage has focus its elements are a list box under the canvas (name from the instance name and outline or kind, layer, place and size, bounds, selected; 2,000 at most plus a summary); **Tab, arrows, Enter/Space and Shift+Space select on the stage** through `element.select` (new `toggle`); the active layer's keyframe spans are a list (frames, tween, label, sound, actions; activating one moves the playhead); on the focused timeline the arrows move the playhead and layer, announced through the status bar; **the menu bar from the keyboard** on Windows and Linux (Alt tap or F10, arrows, submenus, Esc, Alt+letter with underlined access keys); **Follow system** (the default theme) switches to high contrast with Windows' contrast themes, macOS' Increase Contrast, the portal/GNOME contrast setting and `prefers-contrast` in browsers. Not yet: names beyond the outline heuristic, per-item menu letters, a light palette, a keyboard route to the menu row on macOS (⌘K covers it), manual passes with Narrator, VoiceOver and Orca. |
|
||||
| Stage rendering & build | **Tiled stage** (ADR 0007): 512 px cached tiles, batched per frame with one scene evaluation per frame, look-ahead ring and playback prefetch, scaled older tiles instead of blank areas, pixel-aligned (no seams). **Space-biased build**: debug build 6.9 GB → 1.04 GB, fresh build 44 s, edit rebuild 4–6 s (`docs/development.md`). |
|
||||
| Stage rendering & build | **Tiled stage** (ADR 0007): 512 px cached tiles, over the stage and the visible pasteboard (artwork off the stage shows, on transparent tiles that never cross the stage edge; View › Clip Content Outside the Stage and its edit-bar button hide it, view state), batched per frame with one scene evaluation per frame, look-ahead ring and playback prefetch, scaled older tiles instead of blank areas, pixel-aligned (no seams). **Space-biased build**: debug build 6.9 GB → 1.04 GB, fresh build 44 s, edit rebuild 4–6 s (`docs/development.md`). |
|
||||
| Scale & performance | Pulled forward from M2: persistent document with snapshot undo (memory-budgeted history, save-point dirty tracking, History panel), background render worker with frame cache and playback look-ahead, band-parallel renderer with culling, compact streaming file format v2, `anicraft-cli bench`. Measured numbers are in `docs/performance.md`. Memory, sharing, file-size and culling budgets are a test on every PR; timing budgets are `anicraft-cli bench --check yes` (all met; the 1080p render is 15.3–15.8 ms against 16.7 ms). |
|
||||
|
||||
## Milestones
|
||||
|
||||
+22
-1
@@ -181,6 +181,9 @@ pub struct StageView {
|
||||
/// The canvas size and zoom of the last fit: while the view is still as fitted, it fits
|
||||
/// again when the canvas changes size (window resized, panels or interface scale changed).
|
||||
pub fitted: Option<(egui::Vec2, f32)>,
|
||||
/// View › Clip Content Outside the Stage (#251): hide artwork on the pasteboard (it is still
|
||||
/// there, and still exported only where it is on the stage). Off: it shows, as in Animate.
|
||||
pub clip_to_stage: bool,
|
||||
}
|
||||
|
||||
/// In-progress pointer gesture on the stage.
|
||||
@@ -560,7 +563,7 @@ impl App {
|
||||
updates: Default::default(),
|
||||
s: session,
|
||||
tool: Tool::Select,
|
||||
view: StageView { zoom: 1.0, pan: egui::Vec2::ZERO, fit: true, fitted: None },
|
||||
view: StageView { zoom: 1.0, pan: egui::Vec2::ZERO, fit: true, fitted: None, clip_to_stage: false },
|
||||
stage_cache: stage::Cache::default(),
|
||||
drag: Drag::None,
|
||||
hint_menu: None,
|
||||
@@ -1065,6 +1068,17 @@ impl App {
|
||||
self.view.zoom = 3.0;
|
||||
self.view.pan = egui::vec2(1200.0, 300.0);
|
||||
}
|
||||
Some("pasteboard") | Some("clipped") => {
|
||||
// Artwork half off the stage (#245); `clipped`: Clip Content Outside the Stage on
|
||||
// (#251). Zoomed out so the pasteboard shows around the stage.
|
||||
let w = self.s.doc.stage.width as f32;
|
||||
self.run("draw.ellipse", json!({"x": -160.0, "y": 40.0, "w": 260.0, "h": 200.0}));
|
||||
self.run("draw.rect", json!({"x": w - 80.0, "y": 260.0, "w": 240.0, "h": 120.0}));
|
||||
self.view.fit = false;
|
||||
self.view.zoom = 0.55;
|
||||
self.view.pan = egui::Vec2::ZERO;
|
||||
self.view.clip_to_stage = which == Some("clipped");
|
||||
}
|
||||
Some("prefs") => {
|
||||
self.show_prefs = true;
|
||||
self.scan_system_fonts();
|
||||
@@ -2263,6 +2277,13 @@ impl App {
|
||||
self.prompt = Some(Prompt { title, cmd: id, key, text });
|
||||
return;
|
||||
}
|
||||
// F5, F6 and F7 work as in Animate: at the playhead with no frame selection, F5 extends
|
||||
// every layer that reaches it; on one frame the playhead moves on to what was made.
|
||||
if let Some(p) = timeline::insert_key_params(self, id) {
|
||||
self.request(id, p);
|
||||
timeline::follow_playhead(self);
|
||||
return;
|
||||
}
|
||||
// Frame commands act on the frame selection (F5 over 3 frames on 2 layers inserts 3
|
||||
// frames on each).
|
||||
if timeline::RANGE_COMMANDS.contains(&id)
|
||||
|
||||
+19
-3
@@ -6,8 +6,9 @@
|
||||
//! instance to another adds a bone; a drag inside a shape draws a bone inside it (the shape
|
||||
//! bends with it: a shape armature); a drag starting on a bone's end continues the chain from
|
||||
//! it, and a click picks a bone. With the **Selection tool** a drag on a bone, or on an
|
||||
//! instance a bone moves, poses the armature by inverse kinematics; a drag on the root instance
|
||||
//! (or a shape armature's shape) moves the whole armature. Each drag is one undo step, and the
|
||||
//! instance a bone moves, poses the armature by inverse kinematics (the point grabbed follows the
|
||||
//! pointer); a drag on the root instance, the root's joints (or a shape armature's shape) moves
|
||||
//! the whole armature. Each drag is one undo step, and the
|
||||
//! pose keys the frame.
|
||||
|
||||
use crate::app::{App, Drag, Tool};
|
||||
@@ -216,7 +217,22 @@ pub fn select_drag_start(app: &mut App, xf: Xf, press: Pos2) -> Option<Drag> {
|
||||
let sp = xf.to_stage(press);
|
||||
let tl = app.s.timeline();
|
||||
let (layer, bone, local) = match hit(app, xf, press) {
|
||||
Some((layer, id, _)) => (layer, Some(id), None),
|
||||
Some((layer, id, Part::End)) => (layer, Some(id), None),
|
||||
// Along a bone: the point grabbed follows the pointer (pulling the bone's end there would
|
||||
// make the chain jump, #239); on the joint a root's bone starts at, the armature moves.
|
||||
Some((layer, id, Part::Body)) => {
|
||||
let l = tl.layer(layer)?;
|
||||
let arm = l.armature.as_deref()?;
|
||||
let (_, els) = evaluate_layer_elements(l, app.s.frame)?;
|
||||
let pose = armature::pose_at(l, app.s.frame).unwrap_or_default();
|
||||
let from_root = arm.bone(id).is_some_and(|b| arm.bone_into(b.parent).is_none());
|
||||
let at_head = armature::bones_at(arm, &els, &pose).iter().find(|b| b.id == id).is_some_and(|b| xf.to_screen(b.head).distance(press) <= GRAB_END);
|
||||
if from_root && at_head {
|
||||
(layer, None, None)
|
||||
} else {
|
||||
(layer, Some(id), armature::grab_point(arm, &els, &pose, id, sp))
|
||||
}
|
||||
}
|
||||
None => {
|
||||
let (layer, el) = item_at(app, sp, 3.0 / xf.zoom.max(1e-3), None, rig_target).filter(|(l, _)| tl.layer(*l).is_some_and(|l| l.kind == LayerKind::Armature))?;
|
||||
let l = tl.layer(layer)?;
|
||||
|
||||
+23
-2
@@ -71,11 +71,19 @@ pub enum Icon {
|
||||
Bind,
|
||||
EditMultiple,
|
||||
Layer,
|
||||
InsertFrame,
|
||||
InsertKeyframe,
|
||||
InsertBlankKeyframe,
|
||||
ClipStage,
|
||||
}
|
||||
|
||||
impl Icon {
|
||||
#[cfg(test)]
|
||||
pub const ALL: [Icon; 57] = [
|
||||
pub const ALL: [Icon; 61] = [
|
||||
Icon::ClipStage,
|
||||
Icon::InsertFrame,
|
||||
Icon::InsertKeyframe,
|
||||
Icon::InsertBlankKeyframe,
|
||||
Icon::Bind,
|
||||
Icon::Layer,
|
||||
Icon::EditMultiple,
|
||||
@@ -138,7 +146,7 @@ impl Icon {
|
||||
/// Drawn filled as well as outlined: the Selection arrow is solid, the Subselection arrow
|
||||
/// hollow, the way animators tell the two apart at a glance.
|
||||
fn solid(self) -> bool {
|
||||
matches!(self, Icon::Select)
|
||||
matches!(self, Icon::Select | Icon::InsertKeyframe)
|
||||
}
|
||||
|
||||
/// Lucide icon file and whether it is drawn mirrored.
|
||||
@@ -219,6 +227,15 @@ impl Icon {
|
||||
Icon::FolderOpen => ("folder-open", false),
|
||||
// A layer: a row with a keyframe and its span (AniCraft original, on Lucide's grid).
|
||||
Icon::Layer => ("anicraft-layer", false),
|
||||
// Insert Frame / Keyframe / Blank Keyframe: the timeline's own marks (a frame cell, a
|
||||
// filled keyframe dot, a hollow blank-keyframe dot), each with a plus (AniCraft
|
||||
// originals, on Lucide's grid).
|
||||
Icon::InsertFrame => ("anicraft-insert-frame", false),
|
||||
Icon::InsertKeyframe => ("anicraft-insert-keyframe", false),
|
||||
Icon::InsertBlankKeyframe => ("anicraft-insert-blank-keyframe", false),
|
||||
// The stage with crop marks at its corners (AniCraft original, on Lucide's grid):
|
||||
// Clip Content Outside the Stage.
|
||||
Icon::ClipStage => ("anicraft-clip-stage", false),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -273,6 +290,10 @@ static FILES: &[(&str, &str)] = &[
|
||||
("anicraft-eyedropper", include_str!("../assets/icons/anicraft-eyedropper.svg")),
|
||||
("anicraft-masked", include_str!("../assets/icons/anicraft-masked.svg")),
|
||||
("anicraft-layer", include_str!("../assets/icons/anicraft-layer.svg")),
|
||||
("anicraft-insert-frame", include_str!("../assets/icons/anicraft-insert-frame.svg")),
|
||||
("anicraft-insert-keyframe", include_str!("../assets/icons/anicraft-insert-keyframe.svg")),
|
||||
("anicraft-insert-blank-keyframe", include_str!("../assets/icons/anicraft-insert-blank-keyframe.svg")),
|
||||
("anicraft-clip-stage", include_str!("../assets/icons/anicraft-clip-stage.svg")),
|
||||
("anicraft-camera", include_str!("../assets/icons/anicraft-camera.svg")),
|
||||
("anicraft-bone", include_str!("../assets/icons/anicraft-bone.svg")),
|
||||
("anicraft-bind", include_str!("../assets/icons/anicraft-bind.svg")),
|
||||
|
||||
@@ -604,6 +604,9 @@ pub(crate) fn menu_contents(app: &mut App, ui: &mut egui::Ui, top: &str, cmds: &
|
||||
crate::onion::toggle_edit_multiple(app);
|
||||
}
|
||||
ui.menu_button(tr!("Onion Skin Options"), |ui| crate::onion::menu(app, ui));
|
||||
if ui_item(ui, tr!("Clip Content Outside the Stage"), "", Some(app.view.clip_to_stage)) {
|
||||
app.view.clip_to_stage = !app.view.clip_to_stage;
|
||||
}
|
||||
if ui_item(ui, tr!("Preview Through Camera"), "", Some(app.camera_preview)) {
|
||||
app.toggle_camera_preview();
|
||||
}
|
||||
|
||||
@@ -189,6 +189,11 @@ pub fn edit_bar(app: &mut App, ui: &mut egui::Ui) {
|
||||
})
|
||||
.response
|
||||
.set_name(tr!("Zoom"));
|
||||
// Beside the zoom, as in Animate (#251): a toggle, on = the pasteboard is hidden.
|
||||
let clip = app.view.clip_to_stage;
|
||||
if crate::timeline::icon_button(ui, tr!("Clip content outside the stage"), Some(clip), Icon::ClipStage).clicked() {
|
||||
app.view.clip_to_stage = !clip;
|
||||
}
|
||||
if ui.selectable_label(app.onion.ghosts, tr!("Onion skin")).clicked() {
|
||||
crate::onion::toggle_ghosts(app);
|
||||
}
|
||||
|
||||
+25
-3
@@ -331,9 +331,16 @@ pub const APP_ID: &str = "ai.storyteller.anicraft";
|
||||
pub fn viewport(b: egui::ViewportBuilder) -> egui::ViewportBuilder {
|
||||
// The Wayland app_id / X11 class: docks match it to the installed desktop entry
|
||||
// (packaging/linux/ai.storyteller.anicraft.desktop) for the icon and the launcher.
|
||||
let b = b.with_app_id(APP_ID).with_icon(app_icon());
|
||||
match OS {
|
||||
Os::Mac => b.with_fullsize_content_view(true).with_title_shown(false),
|
||||
chrome(OS, b.with_app_id(APP_ID).with_icon(app_icon()))
|
||||
}
|
||||
|
||||
/// The window chrome for `os`. On macOS the content runs under the title bar, so the bar must be
|
||||
/// transparent too: an opaque one covers the menu row (File, Edit, …) and swallows its clicks,
|
||||
/// which left Mac users with no menus at all (#247).
|
||||
#[cfg_attr(target_arch = "wasm32", allow(dead_code))]
|
||||
fn chrome(os: Os, b: egui::ViewportBuilder) -> egui::ViewportBuilder {
|
||||
match os {
|
||||
Os::Mac => b.with_fullsize_content_view(true).with_titlebar_shown(false).with_title_shown(false).with_titlebar_buttons_shown(true),
|
||||
_ => b,
|
||||
}
|
||||
}
|
||||
@@ -638,6 +645,21 @@ pub fn set_unsaved(unsaved: bool) {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn the_mac_menu_row_is_never_under_an_opaque_title_bar() {
|
||||
// #247: content under the title bar (full-size content view) with the bar still drawn
|
||||
// hid File, Edit and the rest on macOS. Whenever content goes under it, it is see-through.
|
||||
for os in [Os::Mac, Os::Windows, Os::Linux] {
|
||||
let b = chrome(os, egui::ViewportBuilder::default());
|
||||
if b.fullsize_content_view == Some(true) {
|
||||
assert_eq!(b.titlebar_shown, Some(false), "{os:?}: the title bar would cover the menus");
|
||||
assert_ne!(b.titlebar_buttons_shown, Some(false), "{os:?}: keep the traffic lights");
|
||||
}
|
||||
}
|
||||
assert_eq!(chrome(Os::Mac, egui::ViewportBuilder::default()).fullsize_content_view, Some(true));
|
||||
assert_eq!(chrome(Os::Windows, egui::ViewportBuilder::default()).fullsize_content_view, None, "native frame");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_desktop_runs_every_command() {
|
||||
assert!(anicraft_engine::commands().iter().all(|c| unavailable(c.id).is_none()));
|
||||
|
||||
+113
-17
@@ -138,26 +138,58 @@ struct TileSpec {
|
||||
view: View,
|
||||
}
|
||||
|
||||
/// Tiles covering stage-device-pixel rect `[x0, x1) × [y0, y1)`, nearest to `centre` first.
|
||||
fn tiles_for(z: f32, stage_px: (u32, u32), px: [f32; 4], margin: u32, bg: anicraft_engine::doc::Rgba) -> Vec<TileSpec> {
|
||||
/// Most tiles along one side: a screen's worth and the look-ahead ring, many times over.
|
||||
const MAX_TILES_PER_AXIS: usize = 64;
|
||||
|
||||
/// The tile spans `(offset, length)` in device pixels along one axis of a stage `len` long that
|
||||
/// overlap `[lo, hi)`. The stage is cut into `TILE`s from its edge; with `pasteboard`, so is the
|
||||
/// space before and after it (from the stage's edges outwards), so no tile straddles the edge.
|
||||
fn spans(len: u32, lo: f32, hi: f32, pasteboard: bool) -> Vec<(i64, u32)> {
|
||||
let t = i64::from(TILE);
|
||||
let len = i64::from(len);
|
||||
let (lo, hi) = (lo.floor().clamp(-1e9, 1e9) as i64, hi.ceil().clamp(-1e9, 1e9) as i64);
|
||||
let mut out = Vec::new();
|
||||
if pasteboard && lo < 0 {
|
||||
// Before the stage: [-(k+1)T, -kT), nearest the stage first.
|
||||
let first = (-hi).max(0) / t;
|
||||
let last = (-lo - 1) / t;
|
||||
let first = first.max(last - MAX_TILES_PER_AXIS as i64 + 1);
|
||||
out.extend((first..=last).rev().map(|k| (-(k + 1) * t, TILE)));
|
||||
}
|
||||
if hi > 0 && lo < len {
|
||||
let first = lo.max(0) / t;
|
||||
let last = (hi.min(len) - 1) / t;
|
||||
out.extend((first..=last).take(MAX_TILES_PER_AXIS).map(|k| (k * t, (t.min(len - k * t)) as u32)));
|
||||
}
|
||||
if pasteboard && hi > len {
|
||||
// After it: [len + kT, len + (k+1)T).
|
||||
let first = (lo - len).max(0) / t;
|
||||
let last = (hi - len - 1) / t;
|
||||
out.extend((first..=last).take(MAX_TILES_PER_AXIS).map(|k| (len + k * t, TILE)));
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Tiles covering stage-device-pixel rect `[x0, x1) × [y0, y1)` (and `margin` tiles around it),
|
||||
/// nearest to its centre first. The stage's tiles are filled with `bg`; with `pasteboard` the
|
||||
/// view beyond the stage gets tiles too, transparent over the pasteboard (#245), so artwork
|
||||
/// there shows while the stage keeps its exact colour and blending.
|
||||
fn tiles_for(z: f32, stage_px: (u32, u32), px: [f32; 4], margin: u32, bg: anicraft_engine::doc::Rgba, pasteboard: bool) -> Vec<TileSpec> {
|
||||
let (sw, sh) = stage_px;
|
||||
if sw == 0 || sh == 0 {
|
||||
return Vec::new();
|
||||
}
|
||||
let t = TILE as f32;
|
||||
let last = (sw.div_ceil(TILE) - 1, sh.div_ceil(TILE) - 1);
|
||||
let tx0 = ((px[0] / t).floor().max(0.0) as u32).saturating_sub(margin);
|
||||
let ty0 = ((px[1] / t).floor().max(0.0) as u32).saturating_sub(margin);
|
||||
let tx1 = (((px[2] - 1.0).max(0.0) / t).floor() as u32 + margin).min(last.0);
|
||||
let ty1 = (((px[3] - 1.0).max(0.0) / t).floor() as u32 + margin).min(last.1);
|
||||
let m = (margin * TILE) as f32;
|
||||
let xs = spans(sw, px[0] - m, px[2] + m, pasteboard);
|
||||
let ys = spans(sh, px[1] - m, px[3] + m, pasteboard);
|
||||
let (cx, cy) = ((px[0] + px[2]) / 2.0, (px[1] + px[3]) / 2.0);
|
||||
let mut out = Vec::new();
|
||||
for ty in ty0..=ty1 {
|
||||
for tx in tx0..=tx1 {
|
||||
let (ox, oy) = (tx * TILE, ty * TILE);
|
||||
let (w, h) = (TILE.min(sw - ox), TILE.min(sh - oy));
|
||||
let view = View { transform: Affine::translate(-(ox as f32), -(oy as f32)).mul(&Affine::scale(z, z)), width: w, height: h, background: Some(bg) };
|
||||
let rect = [ox as f32 / z, oy as f32 / z, (ox + w) as f32 / z, (oy + h) as f32 / z];
|
||||
for &(oy, h) in &ys {
|
||||
for &(ox, w) in &xs {
|
||||
let inside = ox >= 0 && oy >= 0 && ox < i64::from(sw) && oy < i64::from(sh);
|
||||
let (fx, fy) = (ox as f32, oy as f32);
|
||||
let view = View { transform: Affine::translate(-fx, -fy).mul(&Affine::scale(z, z)), width: w, height: h, background: inside.then_some(bg) };
|
||||
let rect = [fx / z, fy / z, (fx + w as f32) / z, (fy + h as f32) / z];
|
||||
out.push(TileSpec { rect, view });
|
||||
}
|
||||
}
|
||||
@@ -814,7 +846,10 @@ pub fn show(app: &mut App, ui: &mut egui::Ui) {
|
||||
painter.rect_filled(stage_rect.translate(vec2(3.0, 4.0)), 0.0, T.stage_shadow);
|
||||
// Stage colour first, so a picture still rendering never shows as a hole.
|
||||
painter.rect_filled(stage_rect, 0.0, crate::theme::to_color32(app.s.doc.stage.background));
|
||||
let vis = stage_rect.intersect(canvas);
|
||||
// What gets rendered: the stage, and the pasteboard around it unless View › Clip Content
|
||||
// Outside the Stage is on (#251). Previewing through the camera shows what the movie shows.
|
||||
let pasteboard = !app.view.clip_to_stage && !preview;
|
||||
let vis = if pasteboard { canvas } else { stage_rect.intersect(canvas) };
|
||||
if vis.width() >= 1.0 && vis.height() >= 1.0 {
|
||||
if app.stage_cache.service.is_none() {
|
||||
let ctx = ui.ctx().clone();
|
||||
@@ -831,7 +866,7 @@ pub fn show(app: &mut App, ui: &mut egui::Ui) {
|
||||
let bg = app.s.doc.stage.background;
|
||||
let stage_px = ((size.x * z).ceil().max(1.0) as u32, (size.y * z).ceil().max(1.0) as u32);
|
||||
let px = [(vis.min.x - st_origin.x) * ppp, (vis.min.y - st_origin.y) * ppp, (vis.max.x - st_origin.x) * ppp, (vis.max.y - st_origin.y) * ppp];
|
||||
let visible = tiles_for(z, stage_px, px, 0, bg);
|
||||
let visible = tiles_for(z, stage_px, px, 0, bg, pasteboard);
|
||||
let pic = app.s.stage_picture();
|
||||
let editing = edit_view.is_some();
|
||||
// Onion skin is off while a symbol is open in place (`stage_skin`, ADR 0045).
|
||||
@@ -910,7 +945,7 @@ pub fn show(app: &mut App, ui: &mut egui::Ui) {
|
||||
ahead.extend(jobs.iter().map(|(t, _)| make_job_for(raster, state, &app.s.doc, start + f, t.view, None).through_camera(preview)));
|
||||
}
|
||||
} else {
|
||||
ahead.extend(tiles_for(z, stage_px, px, 1, bg).into_iter().filter(|t| !jobs.iter().any(|(v, _)| v.rect == t.rect)).map(|t| make_job_for(raster, state, &pic.doc, pic.frame, t.view, onion).through_camera(preview)));
|
||||
ahead.extend(tiles_for(z, stage_px, px, 1, bg, pasteboard).into_iter().filter(|t| !jobs.iter().any(|(v, _)| v.rect == t.rect)).map(|t| make_job_for(raster, state, &pic.doc, pic.frame, t.view, onion).through_camera(preview)));
|
||||
}
|
||||
svc.prefetch(ahead);
|
||||
}
|
||||
@@ -1640,3 +1675,64 @@ mod xf_tests {
|
||||
assert_eq!(xf_zone(r, pos2(500.0, 500.0)), None);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod pasteboard_tests {
|
||||
use super::*;
|
||||
use anicraft_engine::doc::Rgba;
|
||||
|
||||
const BG: Rgba = Rgba { r: 1.0, g: 1.0, b: 1.0, a: 1.0 };
|
||||
|
||||
/// Every device pixel of `px` is in exactly one tile.
|
||||
fn covered_once(tiles: &[TileSpec], z: f32, px: [f32; 4]) {
|
||||
for y in (px[1] as i32..px[3] as i32).step_by(97) {
|
||||
for x in (px[0] as i32..px[2] as i32).step_by(89) {
|
||||
let (sx, sy) = ((x as f32 + 0.5) / z, (y as f32 + 0.5) / z);
|
||||
let n = tiles.iter().filter(|t| sx >= t.rect[0] && sx < t.rect[2] && sy >= t.rect[1] && sy < t.rect[3]).count();
|
||||
assert_eq!(n, 1, "pixel ({x}, {y}) is in {n} tiles");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_pasteboard_gets_transparent_tiles_that_never_cross_the_stage_edge() {
|
||||
// A 1280 × 720 stage at 100 %, seen with 700 px of pasteboard on each side (#245).
|
||||
let (z, stage) = (1.0, (1280, 720));
|
||||
let view = [-700.0, -300.0, 1980.0, 1020.0];
|
||||
let tiles = tiles_for(z, stage, view, 0, BG, true);
|
||||
covered_once(&tiles, z, view);
|
||||
for t in &tiles {
|
||||
let inside = t.rect[0] >= 0.0 && t.rect[1] >= 0.0 && t.rect[2] <= 1280.0 && t.rect[3] <= 720.0;
|
||||
let outside = t.rect[2] <= 0.0 || t.rect[0] >= 1280.0 || t.rect[3] <= 0.0 || t.rect[1] >= 720.0;
|
||||
assert!(inside ^ outside, "a tile straddles the stage edge: {:?}", t.rect);
|
||||
// The stage keeps its colour (and blends against it); the pasteboard is see-through.
|
||||
assert_eq!(t.view.background.is_some(), inside, "{:?}", t.rect);
|
||||
assert!(t.view.width <= TILE && t.view.height <= TILE);
|
||||
}
|
||||
// The stage's own tiles are the same with or without the pasteboard.
|
||||
let clipped = tiles_for(z, stage, view, 0, BG, false);
|
||||
let rects = |ts: &[TileSpec], f: fn(&TileSpec) -> bool| {
|
||||
let mut v: Vec<[i32; 4]> = ts.iter().filter(|t| f(t)).map(|t| t.rect.map(|c| c as i32)).collect();
|
||||
v.sort_unstable();
|
||||
v
|
||||
};
|
||||
assert_eq!(rects(&tiles, |t| t.view.background.is_some()), rects(&clipped, |_| true));
|
||||
// Clipped (#251), nothing is drawn off the stage.
|
||||
assert!(clipped.iter().all(|t| t.rect[0] >= 0.0 && t.rect[1] >= 0.0 && t.rect[2] <= 1280.0 && t.rect[3] <= 720.0));
|
||||
covered_once(&clipped, z, [0.0, 0.0, 1280.0, 720.0]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pasteboard_tiles_work_far_away_zoomed_and_stay_bounded() {
|
||||
// Zoomed in, looking only at the pasteboard, left of and below the stage.
|
||||
let tiles = tiles_for(4.0, (2000, 1000), [-5000.0, 1500.0, -3000.0, 2600.0], 1, BG, true);
|
||||
assert!(!tiles.is_empty());
|
||||
assert!(tiles.iter().all(|t| t.view.background.is_none()));
|
||||
covered_once(&tiles, 4.0, [-5000.0, 1500.0, -3000.0, 2600.0]);
|
||||
// A wild view (zoomed far out on a huge canvas) still makes a bounded number of tiles.
|
||||
let n = tiles_for(1.0, (100, 100), [-1e12, -1e12, 1e12, 1e12], 1, BG, true).len();
|
||||
assert!(n <= (2 * MAX_TILES_PER_AXIS + 1).pow(2), "{n} tiles");
|
||||
// Clipped and looking away from the stage: nothing to draw.
|
||||
assert!(tiles_for(1.0, (100, 100), [-900.0, -900.0, -10.0, -10.0], 0, BG, false).is_empty());
|
||||
}
|
||||
}
|
||||
+87
-7
@@ -171,6 +171,36 @@ pub fn range_params(app: &App) -> Option<serde_json::Value> {
|
||||
Some(json!({"layers": ids, "frame": f0, "count": f1 - f0 + 1}))
|
||||
}
|
||||
|
||||
/// Params for F5, F6 and F7 when they act at one frame, as in Animate: with no frame selection
|
||||
/// F5 extends every layer that reaches the playhead (#242), and the playhead moves on to the frame
|
||||
/// or key just made, so pressing the key again keeps going (#254). `None`: not one of them, or a
|
||||
/// selection of more than one frame (that is a range edit, see [`range_params`]).
|
||||
pub fn insert_key_params(app: &App, id: &str) -> Option<serde_json::Value> {
|
||||
if !matches!(id, "timeline.insert_frame" | "timeline.insert_keyframe" | "timeline.insert_blank_keyframe") {
|
||||
return None;
|
||||
}
|
||||
match range_params(app) {
|
||||
Some(mut p) if p["count"] == json!(1) => {
|
||||
p["advance"] = json!(true);
|
||||
Some(p)
|
||||
}
|
||||
Some(_) => None,
|
||||
None if id == "timeline.insert_frame" => Some(json!({"all_layers": true, "advance": true})),
|
||||
None => Some(json!({"advance": true})),
|
||||
}
|
||||
}
|
||||
|
||||
/// A one-frame selection moves with the playhead after F5 / F6 / F7 (as in Animate), instead of
|
||||
/// being dropped for being left behind.
|
||||
pub fn follow_playhead(app: &mut App) {
|
||||
if let Some(sel) = app.frame_sel.as_mut()
|
||||
&& sel.anchor.1 == sel.head.1
|
||||
{
|
||||
sel.anchor.1 = app.s.frame;
|
||||
sel.head.1 = app.s.frame;
|
||||
}
|
||||
}
|
||||
|
||||
/// Frame commands that act on the frame selection.
|
||||
pub const RANGE_COMMANDS: [&str; 7] = ["timeline.insert_frame", "timeline.remove_frame", "timeline.insert_keyframe", "timeline.insert_blank_keyframe", "timeline.clear_keyframe", "timeline.copy_frames", "timeline.cut_frames"];
|
||||
|
||||
@@ -1465,15 +1495,22 @@ fn header(app: &mut App, ui: &mut egui::Ui, dock: Rect) {
|
||||
ui.label(text(Type::Data, fps_label(fps)).color(T.text_dim)).on_hover_text(tr!("Frame rate"));
|
||||
ui.label(text(Type::Data, format!("{:>6.2} s", f as f32 / fps.max(1.0))).color(T.text_dim)).on_hover_text(tr!("Time at the playhead"));
|
||||
ui.separator();
|
||||
// Through `invoke`, so the buttons act on the frame selection like the keys do.
|
||||
let cmd = |app: &mut App, ui: &mut egui::Ui, label: &str, tip: &str, id: &'static str| {
|
||||
if ui.button(label).named(tip).on_hover_text(tip).clicked() {
|
||||
// Through `invoke`, so the buttons act on the frame selection like the keys do. Icons (the
|
||||
// timeline's own marks, each with a plus) keep the header narrow; the name and the key
|
||||
// stay in the tooltip and the accessible name (#240).
|
||||
for (id, name, icon) in [
|
||||
("timeline.insert_frame", tr!("Insert frame"), Icon::InsertFrame),
|
||||
("timeline.insert_keyframe", tr!("Insert keyframe"), Icon::InsertKeyframe),
|
||||
("timeline.insert_blank_keyframe", tr!("Insert blank keyframe"), Icon::InsertBlankKeyframe),
|
||||
] {
|
||||
let tip = match app.keymap.primary(id).map(crate::platform::shortcut_label) {
|
||||
Some(k) => format!("{name} ({k})"),
|
||||
None => name.to_string(),
|
||||
};
|
||||
if icon_button(ui, &tip, None, icon).clicked() {
|
||||
app.invoke(id);
|
||||
}
|
||||
};
|
||||
cmd(app, ui, tr!("Frame"), tr!("Insert frame (F5)"), "timeline.insert_frame");
|
||||
cmd(app, ui, tr!("Keyframe"), tr!("Insert keyframe (F6)"), "timeline.insert_keyframe");
|
||||
cmd(app, ui, tr!("Blank"), tr!("Insert blank keyframe (F7)"), "timeline.insert_blank_keyframe");
|
||||
}
|
||||
let here = app.s.active_layer().and_then(|l| l.keyframe_at(app.s.frame));
|
||||
let in_tween = here.and_then(|k| k.tween);
|
||||
let in_motion = here.is_some_and(|k| k.motion.is_some());
|
||||
@@ -1644,6 +1681,49 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
fn spans(app: &App, l: LayerId) -> Vec<(u32, u32)> {
|
||||
app.s.timeline().layer(l).map(|l| l.keyframes.iter().map(|k| (k.start, k.duration)).collect()).unwrap_or_default()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn f5_f6_f7_from_the_editor_extend_at_the_playhead_and_move_on() {
|
||||
let ctx = egui::Context::default();
|
||||
let mut app = App::with_context(&ctx, anicraft_engine::Session::default(), Some(std::path::PathBuf::from("unused.png")));
|
||||
let a = app.s.layer;
|
||||
app.run("timeline.insert_frame", json!({"layer": a.0, "frame": 0, "count": 7}));
|
||||
let b = LayerId(app.run("layer.new", json!({})).and_then(|v| v["layer"].as_u64()).unwrap_or(0));
|
||||
app.run("timeline.remove_frame", json!({"layer": b.0, "frame": 0, "count": 4}));
|
||||
assert_eq!((spans(&app, a), spans(&app, b)), (vec![(0, 8)], vec![(0, 4)]));
|
||||
// No frame selection, playhead at frame 5: F5 extends layer 1 only, and moves on.
|
||||
app.frame_sel = None;
|
||||
app.s.set_frame(4);
|
||||
app.invoke("timeline.insert_frame");
|
||||
assert_eq!((spans(&app, a), spans(&app, b)), (vec![(0, 9)], vec![(0, 4)]));
|
||||
assert_eq!(app.s.frame, 5);
|
||||
// A clicked cell: F5 there is for that layer, and the cell follows the playhead.
|
||||
app.frame_sel = Some(FrameSel::cell(b, 3));
|
||||
app.s.set_frame(3);
|
||||
app.invoke("timeline.insert_frame");
|
||||
assert_eq!(spans(&app, b), vec![(0, 5)]);
|
||||
assert_eq!(app.s.frame, 4);
|
||||
assert_eq!(app.frame_sel.map(|s| s.frames()), Some((4, 4)));
|
||||
// F6 on a keyframe: the next frame gets the key, the playhead and the cell go there.
|
||||
app.frame_sel = Some(FrameSel::cell(b, 0));
|
||||
app.s.set_frame(0);
|
||||
app.invoke("timeline.insert_keyframe");
|
||||
assert_eq!(spans(&app, b), vec![(0, 1), (1, 4)]);
|
||||
assert_eq!((app.s.frame, app.frame_sel.map(|s| s.frames())), (1, Some((1, 1))));
|
||||
app.invoke("timeline.insert_blank_keyframe");
|
||||
assert_eq!(spans(&app, b), vec![(0, 1), (1, 1), (2, 3)]);
|
||||
assert_eq!(app.s.frame, 2);
|
||||
// A selection of several frames stays a range edit and doesn't move the playhead.
|
||||
app.frame_sel = Some(FrameSel { anchor: (a, 1), head: (a, 2) });
|
||||
app.s.set_frame(1);
|
||||
app.invoke("timeline.insert_frame");
|
||||
assert_eq!(spans(&app, a), vec![(0, 11)]);
|
||||
assert_eq!(app.s.frame, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_selection_spans_rows_and_frames_in_either_direction() {
|
||||
let ls = layers(4);
|
||||
|
||||
Reference in new issue
Block a user