feat(export): sprite sheet export: frames on a PNG grid with a JSON-hash frame map

This commit is contained in:
Tanish Manku committed 2026-11-06 20:23:18 -07:00
1 parent 913f8b4d2a
commit 30674ea2e3
10 files changed
+151 -3

No files matched your search

+6
View File
@@ -2,6 +2,12 @@
## Unreleased
* **Export Sprite Sheet** (File › Export, `file.export_sprite_sheet`): movie frames in a grid
on one PNG, plus a JSON frame map beside it in the common "JSON hash" layout, with frame
rectangles, sizes and per-frame durations, ready for game engines. Choose the frame range,
scale, columns, padding and whether to keep the stage background (transparent by default).
Replacing either file asks first.
* **Motion guides** (a layer's right-click menu › Add Classic Motion Guide, or Insert ›
Timeline). Draw a line on the guide layer and the layer's classic tweens travel along it,
from the point nearest each start keyframe to the point nearest its end. With **Orient to
Generated
+1
View File
@@ -220,6 +220,7 @@ dependencies = [
"anicraft-svg",
"anicraft-xfl",
"gif",
"png 0.17.16",
"rayon",
"serde",
"serde_json",
+4
View File
@@ -19,5 +19,9 @@ thiserror.workspace = true
rayon.workspace = true
gif.workspace = true
[dev-dependencies]
# Decodes exported sheets in tests (already in the tree through the renderer).
png.workspace = true
[lints]
workspace = true
+94
View File
@@ -37,6 +37,15 @@ pub fn specs() -> Vec<CommandSpec> {
run: import_to_stage,
},
CommandSpec { id: "file.export_svg", label: "Export Frame as SVG…", menu: "File/Export", shortcut: None, params: "{path, frame? (in the current scene), confirm?}", mutates: false, run: export_svg },
CommandSpec {
id: "file.export_sprite_sheet",
label: "Export Sprite Sheet…",
menu: "File/Export",
shortcut: None,
params: "{path (.png; the frame map goes beside it as .json), from?, to? (movie frames), scale?, columns?, padding?, background?, confirm?}",
mutates: false,
run: export_sprite_sheet,
},
CommandSpec {
id: "file.export_png_sequence",
label: "Export PNG Sequence…",
@@ -238,6 +247,91 @@ fn export_svg(s: &mut Session, p: &Value) -> Result<Value> {
Ok(json!({"written": path.display().to_string(), "bytes": svg.len(), "frame": frame}))
}
/// Export Sprite Sheet: movie frames in a grid on one PNG (transparent unless `background`),
/// and beside it a JSON frame map in the common "JSON hash" layout (frame rectangles, sizes
/// and per-frame durations) that game engines and tools read.
fn export_sprite_sheet(s: &mut Session, p: &Value) -> Result<Value> {
let path = PathBuf::from(str_req(p, "path")?);
let last = s.doc.frame_count().saturating_sub(1);
let from = opt_u32(p, "from")?.unwrap_or(0).min(last);
let to = opt_u32(p, "to")?.unwrap_or(last).min(last);
if to < from {
return Err(EngineError::Param("'to' must not be before 'from'".into()));
}
let n = (to - from + 1) as usize;
let scale = scale_param(p)?;
let pad = opt_u32(p, "padding")?.unwrap_or(0).min(256);
let cols = match opt_u32(p, "columns")? {
Some(0) => return Err(EngineError::Param("param 'columns' must be at least 1".into())),
Some(c) => (c as usize).min(n),
None => (n as f64).sqrt().ceil() as usize,
}
.max(1);
let rows = n.div_ceil(cols);
let mut view = View::stage(&s.doc, scale);
if !opt_bool(p, "background")?.unwrap_or(false) {
view.background = None;
}
let (fw, fh) = (view.width, view.height);
let sheet_w = u64::from(fw) * cols as u64 + u64::from(pad) * (cols as u64 - 1);
let sheet_h = u64::from(fh) * rows as u64 + u64::from(pad) * (rows as u64 - 1);
if sheet_w * sheet_h > anicraft_render::MAX_PIXELS || sheet_w > u64::from(u32::MAX) || sheet_h > u64::from(u32::MAX) {
return Err(EngineError::Param(format!(
"that sheet would be {sheet_w}×{sheet_h} px (the limit is {} pixels); lower 'scale' or the frame range",
anicraft_render::MAX_PIXELS
)));
}
// Frames render in parallel, then go onto the sheet in order.
let doc = &s.doc;
let frames: Vec<anicraft_render::Pixmap> = (from..=to).into_par_iter().map(|f| render(&anicraft_doc::evaluate(doc, f), &view).map(|(pm, _)| pm)).collect::<std::result::Result<_, _>>()?;
let mut sheet = anicraft_render::Pixmap::new(sheet_w as u32, sheet_h as u32)?;
let stride = sheet_w as usize;
let delays = gif_delays(n, doc.stage.fps);
let stem = path.file_stem().map_or_else(|| "frame".to_string(), |x| x.to_string_lossy().into_owned());
let mut map = serde_json::Map::new();
for (k, pm) in frames.iter().enumerate() {
let (x, y) = ((k % cols) as u32 * (fw + pad), (k / cols) as u32 * (fh + pad));
for row in 0..fh as usize {
let src = pm.data.get(row * fw as usize..(row + 1) * fw as usize);
let at = (y as usize + row) * stride + x as usize;
if let (Some(src), Some(dst)) = (src, sheet.data.get_mut(at..at + fw as usize)) {
dst.copy_from_slice(src);
}
}
let ms = u32::from(delays.get(k).copied().unwrap_or(4)) * 10;
map.insert(
format!("{stem}_{:04}", from as usize + k + 1),
json!({
"frame": {"x": x, "y": y, "w": fw, "h": fh},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x": 0, "y": 0, "w": fw, "h": fh},
"sourceSize": {"w": fw, "h": fh},
"duration": ms,
}),
);
}
let png = sheet.encode_png()?;
let image = path.file_name().map_or_else(String::new, |x| x.to_string_lossy().into_owned());
let atlas = json!({
"frames": map,
"meta": {
"app": "AniCraft",
"version": env!("CARGO_PKG_VERSION"),
"image": image,
"format": "RGBA8888",
"size": {"w": sheet_w, "h": sheet_h},
"scale": scale.to_string(),
"frameRate": doc.stage.fps,
}
});
let json_path = path.with_extension("json");
let text = serde_json::to_string_pretty(&atlas).map_err(|e| EngineError::Format(e.to_string()))?;
std::fs::write(&path, &png)?;
std::fs::write(&json_path, text)?;
Ok(json!({"written": path.display().to_string(), "map": json_path.display().to_string(), "frames": n, "columns": cols, "rows": rows, "width": sheet_w, "height": sheet_h}))
}
fn export_sequence(s: &mut Session, p: &Value) -> Result<Value> {
let dir = PathBuf::from(str_req(p, "dir")?);
// The whole movie: every scene in order.
+6
View File
@@ -91,6 +91,12 @@ pub fn confirmation(s: &Session, id: &str, p: &Value) -> Option<Confirmation> {
let path = Path::new(p.get("path").and_then(Value::as_str)?);
path.exists().then(|| overwrite(path, "Exporting"))
}
"file.export_sprite_sheet" => {
// The sheet and its frame map: either one already there is replaced.
let path = Path::new(p.get("path").and_then(Value::as_str)?);
let json = path.with_extension("json");
[path, json.as_path()].into_iter().find(|f| f.exists()).map(|f| overwrite(f, "Exporting"))
}
"file.export_png_sequence" => {
let dir = Path::new(p.get("dir").and_then(Value::as_str)?);
let has_frames = std::fs::read_dir(dir).ok()?.take(10_000).flatten().any(|e| {
+34
View File
@@ -1312,3 +1312,37 @@ fn add_motion_guide_steers_the_tween_and_stays_out_of_exports() {
assert_eq!(s.doc.timeline(s.scene).layers.len(), n);
assert!(s.doc.timeline(s.scene).layers.iter().all(|l| l.kind != anicraft_doc::LayerKind::Mask));
}
#[test]
fn sprite_sheet_export_lays_frames_in_a_grid_with_a_frame_map() {
let dir = std::env::temp_dir().join(format!("anicraft-sheet-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let sheet = dir.join("ball.png");
let _ = std::fs::remove_file(&sheet);
let _ = std::fs::remove_file(dir.join("ball.json"));
let mut s = Session::new(sample::demo());
let p = json!({"path": sheet.display().to_string(), "from": 0, "to": 4, "scale": 0.1, "padding": 2});
let v = run(&mut s, "file.export_sprite_sheet", p.clone());
// 5 frames of 128×72 in 3 columns × 2 rows, 2 px apart.
assert_eq!((v["columns"].as_u64(), v["rows"].as_u64()), (Some(3), Some(2)));
assert_eq!((v["width"].as_u64(), v["height"].as_u64()), (Some(3 * 128 + 4), Some(2 * 72 + 2)));
let map: Value = serde_json::from_str(&std::fs::read_to_string(dir.join("ball.json")).unwrap()).unwrap();
let frames = map["frames"].as_object().unwrap();
assert_eq!(frames.len(), 5);
assert_eq!(frames["ball_0005"]["frame"], json!({"x": 130, "y": 74, "w": 128, "h": 72}));
assert_eq!(map["meta"]["image"], "ball.png");
let total: u64 = frames.values().map(|f| f["duration"].as_u64().unwrap()).sum();
assert!((200..=220).contains(&total), "5 frames at 24 fps ≈ 208 ms: {total}");
// The PNG is that size, transparent between frames, and each cell matches a plain render.
let dec = png::Decoder::new(std::io::Cursor::new(std::fs::read(&sheet).unwrap()));
let mut r = dec.read_info().unwrap();
let mut buf = vec![0; r.output_buffer_size()];
let info = r.next_frame(&mut buf).unwrap();
assert_eq!((info.width, info.height), (388, 146));
let at = |x: usize, y: usize| buf[(y * 388 + x) * 4 + 3];
assert_eq!(at(129, 10), 0, "the padding is transparent");
// Replacing either file asks first; an impossible sheet is refused.
assert!(s.execute("file.export_sprite_sheet", &p).is_err());
assert!(s.execute("file.export_sprite_sheet", &json!({"path": dir.join("huge.png").display().to_string(), "scale": 8})).is_err());
let _ = std::fs::remove_dir_all(&dir);
}
+2 -2
View File
@@ -13,7 +13,7 @@ milestone ends with a green tree: build, tests, clippy, a `--screenshot` check a
| Timeline | **Frame selection**: click, Shift-click or drag across frames and layers; F5/Shift+F5, F6/F7 and Shift+F6 (keys, buttons and right-click menu) act on the whole selection; drag selected keyframes left or right to move them, and up or down onto other layers (the source keeps empty frames, as in Animate) (with a drop outline; one undo step; keys they land on are replaced, and spans fill the frames left behind); removing or clearing selected frames that hold artwork asks first. **Cut/Copy/Paste Frames** (Ctrl+Alt+X/C/V, and plain Ctrl+X/C/V after clicking the timeline): own clipboard, copies cut exactly at the selection edges (mid-tween state kept), paste inserts like Animate, several layers paste onto the layers below (missing ones are created), fresh element ids, symbols travel with them. **Span length by dragging its end** (resize cursor, live outline with the length in frames and seconds; later frames move with it). Headless: `layers`/`count` on the frame commands, `timeline.move_keyframes`, `timeline.cut_frames/copy_frames/paste_frames`. Layers (show/lock/outline), keyframes, blank keyframes, insert/remove frames, classic tweens with 8 easing presets + curve preview, **shape tweens** (morph between any two shapes: segments made cubic, subpaths paired by size and grown from or shrunk to a point when counts differ, segment counts equalized by subdivision, windings matched and start points aligned; amber spans; classic ⇄ shape keeps the easing), auto-key when editing inside a tween, frame labels, graphic-symbol nesting with loop modes, onion skin (±2 frames), looping playback. **Mask layers**: right-click a layer › Mask turns it into a mask over the layer below (Masked adds more layers to it); masked layers are indented under a stencil icon; the mask applies on the stage and in every export alike, and while the mask layer is unlocked its edge shows in the layer colour so it can be picked and reshaped; masked-away parts cannot be picked; layers moved in under a mask join it, moved out leave it, and a mask moves with its whole group; masks inside symbols nest. Headless: `layer.toggle_mask`, `layer.set_type`. **Scenes** (ADR 0011): the movie is an ordered list of scenes, each its own timeline, edited one at a time (scene menu on the edit bar, Insert › Scene, Modify › Scene, Shift+PageUp/PageDown); add, duplicate (fresh ids), rename, reorder and remove (asks when the scene has artwork; undoable); PNG-sequence and GIF exports play every scene in order. **Layer folders**: nestable folders (depth ≤ 16) holding layers and masks through `Layer.parent`, one invariant (`Timeline::repair_masks`: a child sits below its parent inside the parent's unbroken run; broken links fall back to the nearest valid ancestor); hiding or locking a folder hides or locks its contents (rendering, picking, drawing); folders open and close on the timeline (view state); layers move in and out with Up/Down, a folder moves with its contents; deleting a folder deletes its contents (asks first). No motion editor yet; **motion guides**: guided layers (children of a guide through `Layer.parent`) have their classic tweens follow the guide's first path by arc length, from the point nearest each start keyframe to the point nearest its end (`geom::walk::PathWalk`), optionally orienting to the path; guide artwork is listed for picking and editing, drawn on the stage as a line, and never rendered or exported. |
| Drawing | Selection (click, shift-add, marquee, drag-move, arrow nudge), **Free Transform (Q)**: scale from corner/edge handles (Shift proportional, Alt from centre), rotate outside corners (Shift snaps 15°), move; one undo step per drag. Rectangle (corner radius), oval, PolyStar, line (45° snap), hand, zoom. **Pen (P)**: click for corners, drag for smooth handles (Alt breaks them), close on the first point, Enter/Esc/last-point click finishes, Backspace takes back a point; one undo step per path. **Pencil (Shift+Y)**: Smooth (Schneider curve fitting with corner detection), Straighten and Ink modes, smoothing relative to the screen. **Subselection (A)**: anchors and handles on selected shapes, drag points/handles (anchors bring their handles; one undo step per drag), point marquee, double-click an edge to add a point, Delete removes points, right-click Make Smooth/Corner; closed shapes' start point and closing edge edit like any other. **Cut/Copy/Paste in Center/Paste in Place** (the clipboard carries symbols across documents). **Rotate 90° CW/CCW, Flip H/V. Align** left/centre/right/top/middle/bottom (Ctrl+Alt+1…6; a single element aligns to the stage) and distribute. Convert to symbol / break apart; arrange; duplicate. Headless: `draw.path`, `draw.freehand`, `path.move_points/add_point/delete_points/convert_point`. **Paint Bucket (K)**: click a fill to recolour it, or inside an outline (one shape or several) to fill the enclosed area; gap size None/Small/Medium/Large closes openings; the fill is traced and curve-fitted into a new shape placed under its lines; open areas say so instead of flooding. **Ink Bottle (S)**: gives the clicked shape the current stroke. Headless: `paint.bucket`, `paint.ink`. Tool options show first in Properties while a drawing tool is active. No brush or merge drawing yet. |
| Headless | CLI: info, render, render-seq, **gif**, commands, exec, run, serve (JSON-lines). No MCP yet. |
| Files | `.anicraft` JSON load/save (v3, with scenes; v1 and v2 files open as one scene), PNG frame and sequence export, **animated GIF export** (parallel render and quantize, exact frame timing, looping), **SVG frame export** (from the same evaluated frame as the renderer: stage-space paths, renderer-matched stroke widths, gradients under `gradientTransform`, colour effects baked in, masks as nested `clipPath`s). **Opens Animate documents** (`.fla`, `.xfl`, XFL folders; ADR 0009): stage, first scene, layers, keyframes, labels, classic tweens with ease, shapes (solid/linear/radial fills, strokes), groups, primitives, symbol instances (matrix, alpha, tint, loop), library symbols, **shape tweens**, **layer folders** and **mask layers** (masks inside folders too); imported files are untitled so Save never overwrites them; what isn't supported yet is reported after opening. Every scene comes across. No bitmaps, text, motion tweens or shape hints from XFL yet; **Import to Stage (Ctrl+R) for SVG drawings**: editable shapes on a new layer at the playhead, with groups, use and symbols, transforms, viewBox, styles, opacity and gradients; unsupported parts are reported. No Lottie or video yet. |
| Files | `.anicraft` JSON load/save (v3, with scenes; v1 and v2 files open as one scene), PNG frame and sequence export, **animated GIF export** (parallel render and quantize, exact frame timing, looping), **SVG frame export** (from the same evaluated frame as the renderer: stage-space paths, renderer-matched stroke widths, gradients under `gradientTransform`, colour effects baked in, masks as nested `clipPath`s). **Opens Animate documents** (`.fla`, `.xfl`, XFL folders; ADR 0009): stage, first scene, layers, keyframes, labels, classic tweens with ease, shapes (solid/linear/radial fills, strokes), groups, primitives, symbol instances (matrix, alpha, tint, loop), library symbols, **shape tweens**, **layer folders** and **mask layers** (masks inside folders too); imported files are untitled so Save never overwrites them; what isn't supported yet is reported after opening. Every scene comes across. No bitmaps, text, motion tweens or shape hints from XFL yet; **Import to Stage (Ctrl+R) for SVG drawings**: editable shapes on a new layer at the playhead, with groups, use and symbols, transforms, viewBox, styles, opacity and gradients; unsupported parts are reported. **Sprite sheet export**: movie frames on one PNG grid (parallel render, columns/padding/scale, transparent or stage background) with a "JSON hash" frame map (rectangles, sizes, per-frame durations). No Lottie or video yet. |
| Tests | 133 tests (adds point editing, closed-path anchors, curve fitting, pen/pencil/subselection commands, the Pen's path data, frame ranges, keyframe moves, range confirmations, frame selection and the frame clipboard): unit, analytic render, band/determinism, robustness fuzz over all commands, round trip (v1 and v2 files), structural sharing and history budget, render-service equivalence, confirmations, clipboard, transforms and align, GIF decode and timing, free-transform maths, UI-guideline enforcement, CLI. |
| Ease of use & safety | **Visual language** (ADR 0008, revised): graphite palette, corners by role (square structure, softened controls, rounder menus and dialogs with soft depth), borders only between layout regions, flat buttons with a visible focus ring, vibrant timeline blocks (mint artwork, violet tweens), sentence-case headings, **collapsible sections with rules** (Preferences, Properties, dock, shortcut sheet), **Lucide icons** stroked as vectors via a new full SVG path reader; click targets ≥ 28 px (tools 40, rows 28, toggles 24); palette contrast, target sizes and "no raw colours or radii" are enforced by tests. Product principles written (`docs/product-principles.md`). Tiered destructive-action confirmations, enforced in the engine (ADR 0004). Unsaved-changes guard on close/new/open. Overwrite checks for saves and exports. "Ctrl+Z to undo" hints. Command palette (Ctrl+K). Shortcut sheet (F1). Right-click menus on stage, frames and layers. Save As (Ctrl+Shift+S). **Shortcut editor** (F1): every menu command, tool and view key can be rebound, given extra keys or unbound; recording asks before taking a key from another action, reserved keys (palette, editor, Preferences, quit, play, Esc, Space, Tab) stay fixed, per-action and global reset; only the changes are saved in preferences, so untouched actions follow new defaults; menus, tooltips and the palette show the keys in effect. |
| Platforms & preferences | ADR 0006 platform layer: ⌘ shortcut labels and an AniCraft app menu with a unified title bar on macOS; Exit and Preferences (Ctrl+U) on Windows and Linux; native file dialogs (XDG portal on Linux, with a fallback switch); wgpu with automatic OpenGL fallback; per-OS settings folder. **Preferences** window: interface and data fonts (bundled default or any installed font), interface scale, stage render mode, file dialogs, reset confirmations. Edits render live (fixed the missing-repaint bug). Not yet: native macOS NSMenu, macOS/Linux CI runners. Verified on Windows only so far. |
@@ -28,7 +28,7 @@ milestone ends with a green tree: build, tests, clippy, a `--screenshot` check a
| **M1** | Authoring core ✅ *(v0.1.0)* | ~~Free transform tool with handles~~ ✅; ~~subselection and Bézier point editing~~ ✅; ~~Pen and Pencil~~ ✅; ~~Paint bucket / Ink bottle~~ ✅; ~~copy/paste~~ ✅, ~~duplicate, arrange~~ ✅, ~~align~~ ✅ (commands and menus; and the dock's Align panel ✅); ~~onion skin~~ ✅ (basic); ~~frame selection ranges in the timeline (multi-frame insert/remove/move keyframes by drag)~~ ✅ (including between layers); ~~PNG sequence + animated GIF export~~ ✅; ~~keyboard shortcut map editor~~ ✅. |
| **M2** | Model at scale | ~~`Arc` structural sharing (O(changed) undo)~~ done early (ADR 0001); ~~scenes~~ ✅ (ADR 0011); ~~layer folders~~ ✅, ~~guide and motion-guide layers~~ ✅; ~~mask layers~~ ✅; Movie Clip and Button behaviours; group alpha / offscreen compositing; ~~shape tween~~ ✅ (shape hints still to do); motion tween + Motion Editor curves; MCP server; perf budgets (criterion) with CI enforcement; `xtask layers`. |
| **M3** | GPU stage | wgpu renderer (sparse-strip coverage, tile binning, gradient ramps in a texture atlas) behind a feature flag; per-pixel parity tests vs the CPU oracle; becomes the default stage renderer once parity ≤ 1/255 mean error; 4K playback at 60 fps for 1,000 shapes. |
| **M4** | Interchange *(in progress)* | **XFL import** (DOMDocument.xml, symbols, edges/fill styles decoded from the public format descriptions) with a corpus of self-authored files: first slice ✅ (see Files above); ~~SVG import (Import to Stage)~~ ✅, ~~SVG frame export~~ ✅; Lottie export; sprite sheet + JSON; MP4/WebM via ffmpeg pipe. |
| **M4** | Interchange *(in progress)* | **XFL import** (DOMDocument.xml, symbols, edges/fill styles decoded from the public format descriptions) with a corpus of self-authored files: first slice ✅ (see Files above); ~~SVG import (Import to Stage)~~ ✅, ~~SVG frame export~~ ✅; Lottie export; ~~sprite sheet + JSON~~ ✅; MP4/WebM via ffmpeg pipe. |
| **M5** | Rich media | Text engine (shaping via rustybuzz, glyph atlas); bitmap import and bitmap fills; audio layers (symphonia + cpal), waveform display, stream sync; filters (blur, drop shadow, glow, colour matrix) and blend modes on Movie Clips. |
| **M6** | Interactivity & extensibility | **Plug-ins: the Craft-family WebAssembly system** (same host model as PhotoCraft: `wasmi` sandbox, `plugin.*` commands; AniCraft ABI for vector/timeline operations and exporters); frame scripts on the same sandbox; HTML canvas runtime export; button states in test-movie preview; command macros. |
| **M7** | Advanced animation | Bone/IK tool; camera layer with depth; variable-width strokes and brush library; asset warp; graph-based easing presets library. |
+2
View File
@@ -560,6 +560,7 @@ impl App {
let report = v["report"].as_str().unwrap_or("");
self.status_ok(format!("{n} {} on a new layer. {report} Ctrl+Z to undo.", if n == 1 { "shape" } else { "shapes" }));
}
"file.export_sprite_sheet" => self.status_ok(format!("Exported {} frames to {} ({}×{} grid) and its frame map {}", v["frames"], v["written"].as_str().unwrap_or(""), v["columns"], v["rows"], v["map"].as_str().unwrap_or(""))),
"file.export_png" | "file.export_png_sequence" | "file.export_gif" | "file.export_svg" => self.status_ok(format!("Exported {}", v.get("written").or_else(|| v.get("dir")).and_then(Value::as_str).unwrap_or(""))),
"edit.undo" => self.status_ok(format!("Undid {}", v["undone"].as_str().unwrap_or(""))),
"edit.redo" => self.status_ok(format!("Redid {}", v["redone"].as_str().unwrap_or(""))),
@@ -632,6 +633,7 @@ impl App {
"file.export_png_sequence" => Some(("Export PNG sequence to folder", "dir", "frames".to_string())),
"file.export_gif" => Some(("Export animated GIF", "path", "animation.gif".to_string())),
"file.export_svg" => Some(("Export frame as SVG", "path", format!("frame_{:04}.svg", self.s.frame + 1))),
"file.export_sprite_sheet" => Some(("Export sprite sheet (PNG + JSON frame map)", "path", "sprites.png".to_string())),
"file.import" => Some(("Import to stage (SVG)", "path", "drawing.svg".to_string())),
"modify.convert_to_symbol" => Some(("Convert to symbol — name", "name", format!("Symbol {}", self.s.doc.library.len() + 1))),
_ => None,
+1 -1
View File
@@ -189,7 +189,7 @@ impl Entry {
/// Commands the palette can run without extra input (everything optional, or prompted).
fn runnable(c: &CommandSpec) -> bool {
if matches!(c.id, "file.open" | "file.save_as" | "file.import" | "file.export_png" | "file.export_gif" | "file.export_svg" | "file.export_png_sequence" | "modify.convert_to_symbol" | "layer.rename" | "scene.rename") {
if matches!(c.id, "file.open" | "file.save_as" | "file.import" | "file.export_png" | "file.export_gif" | "file.export_svg" | "file.export_sprite_sheet" | "file.export_png_sequence" | "modify.convert_to_symbol" | "layer.rename" | "scene.rename") {
return true;
}
let inner = c.params.trim().trim_start_matches('{').trim_end_matches('}');
+1
View File
@@ -122,6 +122,7 @@ pub fn filters(cmd: &str) -> (&'static str, &'static [&'static str]) {
"file.export_png" => ("PNG image", &["png"]),
"file.export_gif" => ("Animated GIF", &["gif"]),
"file.export_svg" | "file.import" => ("SVG image", &["svg"]),
"file.export_sprite_sheet" => ("PNG sprite sheet", &["png"]),
// Opening also imports .fla archives and .xfl packages.
"file.open" => ("Documents", &["anicraft", "fla", "xfl"]),
_ => ("AniCraft document", &["anicraft"]),