A drawing app built for agent/human collaboration
Rust
A first start: a welcome, first steps and samples
Indicode BVad0b4b92c1a6
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 13084b5..c5b6808 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -17,6 +17,7 @@ The first builds, and klad's licences.- `klad arcs` follows the part of a foot on the ground: a heel-to-toe roll is no longer reported as a slide.- "Report a problem" copies what an issue needs.- Bones: a layer or group gets a skeleton (`klad bone`, the bone tool J), weights from the bones or painted (`klad weights`), and poses that bend the drawing (`klad pose`, pose mode); in-betweens of two poses turn the bones. The bone tool lists the skeleton, picks a bone in every mode, and moves ends, joints and whole bones with their children (`klad bone --move` with `--by`).+- A first start: the start window welcomes, offers first steps (draw a shape, fill it, hand the drawing to an agent, ticked off as you go; Help > First steps opens them again) and six sample drawings that open as copies (`klad samples` lists and copies them).- Menus: a menu bar (the Mac's own, an in-window one on Windows and Linux) holds every command, with its keys, ticks for what is on and greyed items for what cannot run now; File has close (cmd W) and recent drawings.- Keys: layers, groups and shapes move, turn, scale and fade between frames with eases (`klad key`, the keys section of the inspector).- Godot: `--godot-rig` exports a Skeleton2D with Polygon2D parts and the poses as animations; `--godot-scene` a parallax scene with a Parallax2D per depth plane.diff --git a/README.md b/README.mdindex ca227b5..61a416a 100644--- a/README.md+++ b/README.md@@ -48,7 +48,7 @@ Early, and open for testing. What works today:- macOS and Windows: signed installers will be sold on itch.io and Steam, under the same licence as the source (see [Licence](#licence)). Until then, build klad from source as below.- Linux: build it from source, free.-Every build holds the `klad` command line tool, the editor, the fonts, the licences and the agent skill (`klad skill` prints it). In the editor, the document menu's "install the klad command" puts `klad` on your terminal's path for you and for agents (`klad install` does the same). The editor checks klad's releases once a day for a new version and says so; it installs nothing by itself (turn it off in the settings window).+Every build holds the `klad` command line tool, the editor, the fonts, the licences, the agent skill (`klad skill` prints it) and six sample drawings to look at and draw on (the start window shows them; `klad samples` lists them and copies one out). The first start offers first steps: draw a shape, fill it and hand the drawing to an agent. In the editor, the document menu's "install the klad command" puts `klad` on your terminal's path for you and for agents (`klad install` does the same). The editor checks klad's releases once a day for a new version and says so; it installs nothing by itself (turn it off in the settings window).### From source@@ -56,8 +56,8 @@ Building takes about ten minutes the first time.1. Install Rust with [rustup](https://rustup.rs) and [`just`](https://github.com/casey/just) (`brew install just`, or `cargo install just`). On Linux also `pkg-config`, `libfreetype-dev`, `libfontconfig1-dev`, `libxkbcommon-dev` and `libwayland-dev`.2. `git clone https://github.com/klad-app/klad && cd klad`, then `just compile` makes `klad` and `klad-editor` for the machine you are on, in `target/release/` (on Linux in `target/linux/release/`). What you build is for your own use or your company's (see [Licence](#licence)).-3. `target/release/klad open` starts the editor on its start window: make a drawing and start painting.-4. `just samples` builds the sample drawings in `samples/` (a lantern, a walking creature, a running courier, an underground ruin, an inn sign, a tree, a meadow, painted solids, a bowl of lemons and the same painted over with brushwork, a bouncing ball, ink examples); open one with `target/release/klad open samples/lantern/lantern.klad`.+3. `target/release/klad open` starts the editor on its start window: make a drawing and start painting, or take first steps (Help > First steps in the editor).+4. `just samples` builds the sample drawings in `samples/` (a lantern, a walking creature, a running courier, an underground ruin, an inn sign, a tree, a meadow, painted solids, a bowl of lemons and the same painted over with brushwork, a bouncing ball, ink examples); open one with `target/release/klad open samples/lantern/lantern.klad`. The six listed in `samples/shipped.json` show in the start window and go into every build (`packaging/samples.sh`).5. On a Mac, `just app` makes `klad.app` and a disk image in `dist/`; `just dist` packs this machine's build as an archive. Each machine builds for itself: a Mac builds the Mac version, Linux the Linux one.## Drawing with an agentdiff --git a/crates/app/src/commands.rs b/crates/app/src/commands.rsindex 1fa979f..4b6eb8b 100644--- a/crates/app/src/commands.rs+++ b/crates/app/src/commands.rs@@ -162,6 +162,7 @@ pub enum Cmd {ShowArcs,CloseDocument,Quit,+ FirstSteps,}#[derive(Clone, Copy, Debug, PartialEq, Eq)]@@ -476,7 +477,7 @@ use Repeat as R;use Trigger as T;impl Cmd {- pub const ALL: [Cmd; 158] = [+ pub const ALL: [Cmd; 159] = [Cmd::Brush,Cmd::Eraser,Cmd::Fill,@@ -620,6 +621,7 @@ impl Cmd {Cmd::NewDocument,Cmd::CloseDocument,Cmd::Quit,+ Cmd::FirstSteps,Cmd::OpenDocument,Cmd::OpenRecent,Cmd::CopyPath,@@ -1890,6 +1892,15 @@ impl Cmd {R::No,"name, loop, own fps, first and last frame, delete, export to Godot",),+ Cmd::FirstSteps => spec(+ "help.first-steps",+ "first steps",+ icon::INFO,+ G::Panels,+ T::None,+ R::No,+ "three steps for someone new: draw a shape, fill it, hand the drawing to an agent",+ ),Cmd::CloseDocument => spec("file.close","close the drawing",@@ -2320,6 +2331,7 @@ pub const MENUS: [Menu; 7] = [Menu {title: "Help",items: &[+ Run(Cmd::FirstSteps),Run(Cmd::Palette),Run(Cmd::Keys),Line,diff --git a/crates/app/src/editor.rs b/crates/app/src/editor.rsindex a87e93b..3ced7b0 100644--- a/crates/app/src/editor.rs+++ b/crates/app/src/editor.rs@@ -10,6 +10,7 @@ mod compare;mod copy;mod depth;mod export;+mod first;mod history;mod keys;mod layers;@@ -618,6 +619,7 @@ pub(crate) struct Editor {paintover: paintover::Form,compare: Option<compare::Compared>,bones: bones::BoneTool,+ first: first::FirstSteps,key_ease: klad_core::keys::Ease,bindings: crate::commands::Bindings,capturing: Option<Cmd>,@@ -782,6 +784,7 @@ impl Editor {paintover: paintover::Form::default(),compare: None,bones: bones::BoneTool::default(),+ first: first::FirstSteps::default(),key_ease: klad_core::keys::Ease::Linear,bindings: crate::commands::Bindings::default(),capturing: None,@@ -2585,6 +2588,7 @@ impl Editor {self.dirty.extend(touched);let saving = Instant::now();let bytes = self.scene.save_active("stroke")?;+ self.first.drew |= !erasing;if !erasing {self.used_colour();}@@ -2671,6 +2675,7 @@ impl Editor {let touched = self.scene.commit_fill(fill, &self.brushes)?;self.dirty.extend(touched);let bytes = self.scene.save_active("fill")?;+ self.first.filled = true;self.used_colour();let text = format!("{}: {pixels} px computed in {computed:.0} ms, painted and saved in {:.0} ms\nlayer file {bytes} B",diff --git a/crates/app/src/editor/commands.rs b/crates/app/src/editor/commands.rsindex b0f6e6f..5e3edff 100644--- a/crates/app/src/editor/commands.rs+++ b/crates/app/src/editor/commands.rs@@ -354,6 +354,7 @@ impl Editor {Cmd::NotesPane => layout.dock && layout.is_open(Pane::Notes),Cmd::HistoryPane => layout.dock && layout.is_open(Pane::History),Cmd::Timeline => layout.timeline,+ Cmd::FirstSteps => self.first.open,Cmd::Numbers => layout.numbers,Cmd::Settings => self.windows.settings,Cmd::About => self.windows.about,@@ -601,6 +602,7 @@ impl Editor {Cmd::ClipSettings => self.windows.clip = !self.windows.clip,Cmd::NewDocument => self.wants = Some(super::Want::New),Cmd::CloseDocument => self.wants = Some(super::Want::Close),+ Cmd::FirstSteps => self.first.open = !self.first.open,Cmd::Quit => self.ctx.send_viewport_cmd(egui::ViewportCommand::Close),Cmd::OpenDocument => self.wants = Some(super::Want::Open),Cmd::OpenRecent => self.wants = Some(super::Want::Recent),diff --git a/crates/app/src/editor/first.rs b/crates/app/src/editor/first.rsnew file mode 100644index 0000000..a8692fa--- /dev/null+++ b/crates/app/src/editor/first.rs@@ -0,0 +1,110 @@+use super::Editor;+use crate::commands::Cmd;+use crate::messages::Tone;+use crate::theme::{self, Hint, icon};+use egui::RichText;+use std::path::Path;++#[derive(Clone, Debug, Default, PartialEq, Eq)]+pub(super) struct FirstSteps {+ pub open: bool,+ pub drew: bool,+ pub filled: bool,+ pub handed: bool,+}++pub(super) fn prompt(path: &Path) -> String {+ format!(+ "I am drawing in klad; my drawing is {path}. Run `klad skill` and read it first. \+ Then look at the drawing with `klad render \"{path}\"` and add a soft shadow under the shape I drew, on a new layer below it. \+ I have the drawing open in the klad editor, so I see your edits as they land.",+ path = path.display()+ )+}++fn step(ui: &mut egui::Ui, done: bool, number: &str, text: &str) {+ ui.horizontal_top(|ui| {+ let (mark, colour) = match done {+ true => (icon::CHECK, theme::DONE),+ false => (number, theme::TEXT),+ };+ ui.label(RichText::new(mark).strong().color(colour));+ ui.add(+ egui::Label::new(RichText::new(text).color(match done {+ true => theme::WEAK,+ false => theme::TEXT,+ }))+ .wrap(),+ );+ });+}++impl Editor {+ pub(crate) fn start_first_steps(&mut self) {+ self.first = FirstSteps {+ open: true,+ ..FirstSteps::default()+ };+ }++ pub(super) fn first_steps_window(&mut self, ctx: &egui::Context) {+ if !self.first.open {+ return;+ }+ let mut open = true;+ let corner = self.canvas_rect.right_top() + egui::vec2(-344.0, 12.0);+ egui::Window::new("First steps")+ .open(&mut open)+ .default_pos(corner)+ .resizable(false)+ .collapsible(false)+ .show(ctx, |ui| {+ ui.set_width(320.0);+ step(+ ui,+ self.first.drew,+ "1",+ "Draw a closed shape with the brush (B): a stone, a leaf, a cloud. A pen draws with its pressure; a mouse works too.",+ );+ step(+ ui,+ self.first.filled,+ "2",+ "Fill it: pick the fill tool (G) and click inside the shape.",+ );+ step(+ ui,+ self.first.handed,+ "3",+ "Hand it to an agent that works in a terminal (Claude Code, Codex and others): install the klad command, then copy a first request and paste it into your agent. Its edits show up here as they land.",+ );+ ui.horizontal(|ui| {+ self.command_button(ui, Cmd::InstallCommand, Some("install the klad command"));+ if ui+ .button(format!("{} copy a request", icon::COPY))+ .hint("a first request for your agent, with this drawing's path in it")+ .clicked()+ {+ ui.ctx().copy_text(prompt(&self.scene.bundle.root));+ self.first.handed = true;+ self.say(Tone::Done, "copied a request: paste it into your agent");+ }+ });+ if self.first.drew && self.first.filled && self.first.handed {+ ui.add_space(4.0);+ ui.add(+ egui::Label::new(+ RichText::new(+ "Done. File > Close the drawing shows the samples to look at; Help > Every key lists the keys.",+ )+ .color(theme::DONE),+ )+ .wrap(),+ );+ }+ });+ if !open {+ self.first.open = false;+ }+ }+}diff --git a/crates/app/src/editor/panels.rs b/crates/app/src/editor/panels.rsindex 759419f..23be290 100644--- a/crates/app/src/editor/panels.rs+++ b/crates/app/src/editor/panels.rs@@ -136,6 +136,7 @@ impl Editor {egui::CentralPanel::no_frame().show(ui, |ui| self.check(|e| e.canvas(ui)));let after = Instant::now();self.windows(&ctx);+ self.first_steps_window(&ctx);self.import_window(&ctx);self.dropped_pictures(&ctx);self.tend_thumbs(&ctx);diff --git a/crates/app/src/editor/ui_tests.rs b/crates/app/src/editor/ui_tests.rsindex b2eb562..ddcae9a 100644--- a/crates/app/src/editor/ui_tests.rs+++ b/crates/app/src/editor/ui_tests.rs@@ -2529,6 +2529,72 @@ fn text_is_typed_on_the_canvas_and_edited_in_place() {assert!(path.join("fonts/Cinzel.ttf").is_file(), "picking a font copies it in");}+#[test]+fn first_steps_tick_as_a_shape_is_drawn_filled_and_handed_to_an_agent() {+ let path = sample("first-steps");+ let mut h = harness(editor(&path), vec2(1440.0, 1000.0));+ activate(&mut h, "colour");+ h.state_mut().start_first_steps();+ h.run_steps(2);+ assert!(+ h.query_by_label_contains("Draw a closed shape with the brush")+ .is_some()+ );+ let first = || super::first::FirstSteps {+ open: true,+ ..Default::default()+ };+ assert_eq!(h.state().first, first());+ h.key_press(Key::B);+ h.run_steps(1);+ let ring = [+ (150.0, 120.0),+ (260.0, 110.0),+ (290.0, 220.0),+ (170.0, 250.0),+ (150.0, 120.0),+ ];+ h.hover_at(canvas_at(&h, ring[0].0, ring[0].1));+ h.run_steps(1);+ h.drag_at(canvas_at(&h, ring[0].0, ring[0].1));+ h.run_steps(1);+ ring.iter().skip(1).for_each(|(x, y)| {+ h.hover_at(canvas_at(&h, *x, *y));+ h.run_steps(1);+ });+ h.drop_at(canvas_at(&h, ring[4].0, ring[4].1));+ h.run_steps(3);+ settle(&mut h, |ed| !ed.writing());+ assert_eq!(h.state().scene.active_marks().len(), 1);+ assert!(h.state().first.drew, "a stroke ticks the first step");+ assert!(!h.state().first.filled);+ h.key_press(Key::G);+ h.run_steps(1);+ let inside = canvas_at(&h, 215.0, 175.0);+ h.hover_at(inside);+ h.run_steps(1);+ [true, false].into_iter().for_each(|pressed| {+ h.event(egui::Event::PointerButton {+ pos: inside,+ button: egui::PointerButton::Primary,+ pressed,+ modifiers: Modifiers::NONE,+ });+ h.run_steps(1);+ });+ settle(&mut h, |ed| !ed.writing());+ assert!(h.state().first.filled, "a fill ticks the second step");+ h.get_by_label_contains("copy a request").click();+ h.run_steps(2);+ assert!(h.state().first.handed, "copying the request ticks the third");+ assert!(h.query_by_label_contains("Done. File > Close the drawing").is_some());+ assert!(super::first::prompt(&path).contains(&format!("klad render \"{}\"", path.display())));+ h.state_mut().invoke(Cmd::FirstSteps).unwrap();+ h.run_steps(2);+ assert!(!h.state().first.open, "Help > First steps closes them again");+ let _ = std::fs::remove_dir_all(&path);+}+#[test]fn the_menu_bar_reaches_commands_shows_their_state_and_greys_what_cannot_run() {let path = sample("menus");diff --git a/crates/app/src/home.rs b/crates/app/src/home.rsindex c76cf04..3ae057b 100644--- a/crates/app/src/home.rs+++ b/crates/app/src/home.rs@@ -335,8 +335,13 @@ impl Home {if closing {self.close(&ctx);}+ let tour = self.start.as_ref().is_some_and(|s| s.tour);if let Some(path) = chosen.or(from_menu).or_else(crate::opened::take)- && let Err(e) = self.open(&ctx, &path)+ && let Err(e) = self.open(&ctx, &path).inspect(|_| {+ if let Some(editor) = self.editor.as_mut().filter(|_| tour) {+ editor.start_first_steps();+ }+ }){let message = format!("opening {}: {e:#}", path.display());match (self.start.as_mut(), self.editor.as_mut()) {@@ -509,6 +514,55 @@ mod tests {std::fs::remove_dir_all(&dir).unwrap();}+ #[test]+ fn a_first_start_welcomes_offers_first_steps_and_opens_samples_as_copies() {+ let dir = folder("welcome");+ let shipped = dir.join("shipped/rock/rock.klad");+ Bundle::blank(&shipped, &small(), "cli").unwrap();+ let mut first = home(&dir, &[]);+ first.begin(&egui::Context::default(), None);+ first.start.as_mut().unwrap().samples = vec![klad_core::samples::Sample {+ name: "rock".into(),+ about: "a rock on its own".into(),+ path: shipped.clone(),+ }];+ let mut h = harness(first);+ assert!(+ h.query_by_label("Welcome to klad").is_some(),+ "a first start says hello"+ );+ assert!(+ h.query_by_label("a rock on its own").is_some(),+ "the samples show with what they are"+ );+ h.get_by_label("rock").click();+ h.run_steps(3);+ assert_eq!(+ opened(&h),+ dir.join("rock.klad"),+ "a sample opens as a copy in the drawings folder"+ );+ assert!(shipped.join("doc.json").is_file());+ assert!(h.state().settings.welcomed, "opening anything counts as welcomed");+ let mut again = home(&dir, &[]);+ again.begin(&egui::Context::default(), None);+ let mut h = harness(again);+ h.get_by_label("First steps").click();+ h.run_steps(3);+ assert_eq!(opened(&h), dir.join("first steps.klad"));+ assert!(+ h.query_by_label_contains("Draw a closed shape with the brush")+ .is_some(),+ "first steps open on the new drawing"+ );+ let mut later = home(&dir, &[]);+ later.settings.welcomed = true;+ later.begin(&egui::Context::default(), None);+ let h = harness(later);+ assert!(h.query_by_label("Welcome to klad").is_none());+ std::fs::remove_dir_all(&dir).unwrap();+ }+#[test]fn a_new_version_shows_in_the_start_window_with_what_changed() {let dir = folder("update");diff --git a/crates/app/src/settings.rs b/crates/app/src/settings.rsindex d615b9e..2b5462f 100644--- a/crates/app/src/settings.rs+++ b/crates/app/src/settings.rs@@ -83,6 +83,8 @@ pub struct Settings {pub check_updates: bool,#[serde(default, rename = "updatesChecked")]pub updates_checked: u64,+ #[serde(default)]+ pub welcomed: bool,}fn yes() -> bool {@@ -104,6 +106,7 @@ impl Default for Settings {drawings: None,check_updates: true,updates_checked: 0,+ welcomed: false,}}}@@ -201,6 +204,7 @@ impl Settings {self.documents.retain(|p| *p != text);self.documents.insert(0, text);self.documents.truncate(DOCUMENTS);+ self.welcomed = true;}pub fn forget(&mut self, path: &str) {diff --git a/crates/app/src/start.rs b/crates/app/src/start.rsindex c70747a..235392f 100644--- a/crates/app/src/start.rs+++ b/crates/app/src/start.rs@@ -4,6 +4,7 @@ use crate::theme::{self, icon};use anyhow::{Result, anyhow, bail};use egui::{RichText, TextureHandle, vec2};use klad_core::bundle::{Blank, Bundle};+use klad_core::samples::{self, Sample};use std::collections::BTreeMap;use std::path::{Path, PathBuf};use std::sync::Mutex;@@ -53,6 +54,8 @@ pub struct Start {pub error: Option<String>,pub section: Section,pub changed: bool,+ pub samples: Vec<Sample>,+ pub tour: bool,focused: bool,thumbs: BTreeMap<String, Thumb>,}@@ -75,6 +78,8 @@ impl Start {error: None,section,changed: false,+ samples: samples::shipped(),+ tour: false,focused: false,thumbs: BTreeMap::new(),}@@ -124,9 +129,100 @@ impl Start {Ok(path)}+ pub fn first_steps(&self, settings: &mut Settings) -> Result<PathBuf> {+ let folder = settings.drawings_folder();+ std::fs::create_dir_all(&folder)?;+ let path = samples::free_path(&folder, "first steps");+ let blank = Blank {+ width: 1280,+ height: 800,+ background: Some("#f4efe6".into()),+ sketch: false,+ ..Blank::default()+ };+ Bundle::blank(&path, &blank, "editor")?;+ Ok(path)+ }++ fn welcome(&mut self, ui: &mut egui::Ui, settings: &mut Settings) -> Option<PathBuf> {+ let mut chosen = None;+ ui.group(|ui| {+ ui.set_width(726.0);+ ui.label(RichText::new("Welcome to klad").strong().size(16.0));+ ui.add_space(4.0);+ ui.label(+ "New here? First steps take a few minutes: draw a shape with your pen, fill it, and hand the drawing to an agent. \+ Or open a sample below and look around: it opens as a copy, yours to change.",+ );+ ui.add_space(6.0);+ ui.horizontal(|ui| {+ if ui+ .add(egui::Button::new("First steps").min_size(vec2(120.0, 28.0)))+ .clicked()+ {+ match self.first_steps(settings) {+ Ok(path) => {+ self.tour = true;+ self.changed = true;+ chosen = Some(path);+ }+ Err(e) => self.error = Some(format!("making the first steps drawing: {e:#}")),+ }+ }+ if ui.add(egui::Button::new("Not now").min_size(vec2(96.0, 28.0))).clicked() {+ settings.welcomed = true;+ self.changed = true;+ }+ });+ });+ chosen+ }++ fn samples_section(&mut self, ui: &mut egui::Ui, settings: &mut Settings) -> Option<PathBuf> {+ if self.samples.is_empty() {+ return None;+ }+ ui.label(RichText::new(format!("{} Samples", icon::IMAGE)).strong().size(16.0));+ ui.label(+ RichText::new("Open one to look around or draw on it: it opens as a copy in your drawings folder.")+ .color(theme::WEAK),+ );+ ui.add_space(6.0);+ let mut chosen = None;+ let shown = self.samples.clone();+ ui.horizontal_wrapped(|ui| {+ ui.spacing_mut().item_spacing = vec2(12.0, 12.0);+ shown.iter().for_each(|sample| {+ ui.vertical(|ui| {+ ui.set_width(THUMB + 8.0);+ let key = sample.path.display().to_string();+ let picked = self+ .picture(ui, &key, &sample.path, sample_thumb(&sample.path), &sample.name, true)+ .on_hover_text(&sample.about)+ .clicked();+ ui.add(egui::Label::new(RichText::new(&sample.about).color(theme::WEAK).size(11.0)).wrap());+ if picked {+ match samples::copy(sample, &settings.drawings_folder()) {+ Ok(path) => {+ self.changed = true;+ chosen = Some(path);+ }+ Err(e) => self.error = Some(format!("{e:#}")),+ }+ }+ });+ });+ });+ chosen+ }+pub fn ui(&mut self, ui: &mut egui::Ui, settings: &mut Settings) -> Option<PathBuf> {let mut chosen = None;egui::ScrollArea::vertical().auto_shrink([false, true]).show(ui, |ui| {+ if !settings.welcomed {+ chosen = self.welcome(ui, settings);+ ui.add_space(10.0);+ }ui.horizontal_top(|ui| {ui.group(|ui| {ui.vertical(|ui| {@@ -147,6 +243,8 @@ impl Start {}ui.add_space(10.0);chosen = chosen.take().or_else(|| self.recent_section(ui, settings));+ ui.add_space(14.0);+ chosen = chosen.take().or_else(|| self.samples_section(ui, settings));});self.focused = true;chosen@@ -310,14 +408,17 @@ impl Start {chosen}- fn card(&mut self, ui: &mut egui::Ui, doc: &str) -> Card {- let path = PathBuf::from(doc);- let there = path.join("doc.json").is_file();- let name = path- .file_stem()- .map_or_else(|| doc.to_string(), |s| s.to_string_lossy().to_string());+ fn picture(+ &mut self,+ ui: &mut egui::Ui,+ key: &str,+ bundle: &Path,+ png: PathBuf,+ name: &str,+ there: bool,+ ) -> egui::Response {let (rect, response) = ui.allocate_exact_size(vec2(THUMB + 8.0, THUMB + 32.0), egui::Sense::click());- response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, there, &name));+ response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, there, name));let look = ui.style().interact(&response);let fill = match there {true => look.weak_bg_fill,@@ -326,7 +427,7 @@ impl Start {ui.painter().rect(rect, 6.0, fill, look.bg_stroke, egui::StrokeKind::Inside);let picture = egui::Rect::from_min_size(rect.min + vec2(4.0, 4.0), vec2(THUMB, THUMB));- if let Some(texture) = there.then(|| self.thumb(ui.ctx(), doc)).flatten() {+ if let Some(texture) = there.then(|| self.thumb(ui.ctx(), key, bundle, png)).flatten() {egui::Image::new(&texture).paint_at(ui,egui::Rect::from_center_size(picture.center(), fit(texture.size_vec2())),@@ -336,7 +437,7 @@ impl Start {true => look.text_color(),false => theme::WEAK,};- let galley = egui::WidgetText::from(name.as_str()).into_galley(+ let galley = egui::WidgetText::from(name).into_galley(ui,Some(egui::TextWrapMode::Truncate),THUMB - 8.0,@@ -344,6 +445,16 @@ impl Start {);ui.painter().galley(egui::pos2(rect.min.x + 8.0, rect.max.y - 24.0), galley, colour);+ response+ }++ fn card(&mut self, ui: &mut egui::Ui, doc: &str) -> Card {+ let path = PathBuf::from(doc);+ let there = path.join("doc.json").is_file();+ let name = path+ .file_stem()+ .map_or_else(|| doc.to_string(), |s| s.to_string_lossy().to_string());+ let response = self.picture(ui, doc, &path, path.join(".cache").join("thumb.png"), &name, there);let folder = path.parent().and_then(Path::file_name)@@ -362,13 +473,13 @@ impl Start {Card::Idle}- fn thumb(&mut self, ctx: &egui::Context, doc: &str) -> Option<TextureHandle> {+ fn thumb(&mut self, ctx: &egui::Context, doc: &str, bundle: &Path, png: PathBuf) -> Option<TextureHandle> {let state = self.thumbs.entry(doc.to_string()).or_insert_with(|| {let (tx, rx) = channel();- let path = PathBuf::from(doc);+ let path = bundle.to_path_buf();let repaint = ctx.clone();std::thread::spawn(move || {- let image = thumbnail(&path);+ let image = thumbnail(&path, &png);let _ = tx.send(image);repaint.request_repaint();});@@ -447,10 +558,18 @@ fn modified(path: &Path) -> Option<SystemTime> {std::fs::metadata(path).and_then(|m| m.modified()).ok()}-fn thumbnail(bundle: &Path) -> Option<egui::ColorImage> {+fn sample_thumb(bundle: &Path) -> PathBuf {+ let stem = bundle+ .file_stem()+ .map_or_else(String::new, |s| s.to_string_lossy().to_string());+ bundle.with_file_name(format!("{stem}.thumb.png"))+}++fn thumbnail(bundle: &Path, png: &Path) -> Option<egui::ColorImage> {static ONE_AT_A_TIME: Mutex<()> = Mutex::new(());- let png = bundle.join(".cache").join("thumb.png");- let fresh = matches!((modified(&png), modified(&bundle.join("doc.json"))), (Some(t), Some(d)) if t >= d);+ let png = png.to_path_buf();+ let kept = !png.starts_with(bundle) && png.is_file();+ let fresh = kept || matches!((modified(&png), modified(&bundle.join("doc.json"))), (Some(t), Some(d)) if t >= d);if !fresh {let _turn = ONE_AT_A_TIME.lock().ok()?;let doc: serde_json::Value =@@ -518,7 +637,7 @@ mod tests {..Blank::default()};Bundle::blank(&dir, &blank, "cli").unwrap();- let image = thumbnail(&dir).unwrap();+ let image = thumbnail(&dir, &dir.join(".cache").join("thumb.png")).unwrap();assert_eq!(image.size, [336, 168]);let middle = image.pixels[84 * 336 + 168];assert!(@@ -527,11 +646,11 @@ mod tests {);let png = dir.join(".cache").join("thumb.png");let first = modified(&png).unwrap();- thumbnail(&dir).unwrap();+ thumbnail(&dir, &dir.join(".cache").join("thumb.png")).unwrap();assert_eq!(modified(&png), Some(first));std::thread::sleep(Duration::from_millis(20));Bundle::open(&dir).unwrap().save().unwrap();- thumbnail(&dir).unwrap();+ thumbnail(&dir, &dir.join(".cache").join("thumb.png")).unwrap();assert!(modified(&png).unwrap() > first);assert_eq!(free_name(dir.parent().unwrap()), "untitled");std::fs::remove_dir_all(&dir).unwrap();diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rsindex 43ba68b..2b58d4a 100644--- a/crates/cli/src/main.rs+++ b/crates/cli/src/main.rs@@ -1703,6 +1703,18 @@ enum Command {},#[command(about = "Print the agent skill: how an agent draws with klad (the same text as docs/skill/SKILL.md)")]Skill,+ #[command(+ about = "List the sample drawings that come with klad, or copy one to draw on",+ long_about = "List the sample drawings that come with klad (the editor's start window shows the same ones), or copy one into a folder to open, render and draw on; the copy is yours, the samples stay as they are. Without --into it goes in the current folder, as <name>.klad (or <name> 2.klad when that is taken). KLAD_SAMPLES points at another samples folder (one holding shipped.json).\n\n klad samples\n klad samples --copy lantern\n klad samples --copy rig --into ~/Drawings"+ )]+ Samples {+ #[arg(long, help = "The sample to copy, by name")]+ copy: Option<String>,+ #[arg(long, help = "The folder the copy goes in (default: the current folder)")]+ into: Option<PathBuf>,+ #[arg(long)]+ json: bool,+ },#[command(hide = true, about = "Print the command reference, docs/cli.md")]Reference,#[cfg(feature = "editor")]@@ -3298,6 +3310,7 @@ fn run() -> Result<()> {Command::Licences => print!("{}\n{}", klad_core::notices::LICENSE, klad_core::notices::NOTICES),Command::Install { dir } => install::install(dir.as_deref())?,Command::Skill => print!("{}", include_str!("../../../docs/skill/SKILL.md")),+ Command::Samples { copy, into, json } => samples(copy.as_deref(), into, json)?,Command::Reference => print!("{}", reference()),#[cfg(feature = "editor")]Command::Updates => {@@ -3579,6 +3592,45 @@ This reference is licensed under the MIT License (`LICENSE-MIT`), unlike klad it";+fn samples(copy: Option<&str>, into: Option<PathBuf>, json: bool) -> Result<()> {+ use klad_core::samples;+ let dir = samples::dir().ok_or_else(|| {+ anyhow!("this klad has no samples next to it (a build from source has them after just samples)")+ })?;+ let found = samples::listed(&dir)?;+ let Some(name) = copy else {+ match json {+ true => println!(+ "{}",+ serde_json::to_string_pretty(+ &found+ .iter()+ .map(|s| serde_json::json!({"name": s.name, "about": s.about, "path": s.path}))+ .collect::<Vec<_>>()+ )?+ ),+ false => {+ found.iter().for_each(|s| println!("{:10} {}", s.name, s.about));+ println!("copy one to draw on: klad samples --copy <name>");+ }+ }+ return Ok(());+ };+ let sample = found.iter().find(|s| s.name == name).ok_or_else(|| {+ anyhow!(+ "no sample {name}; there are {}",+ found.iter().map(|s| s.name.as_str()).collect::<Vec<_>>().join(", ")+ )+ })?;+ let folder = match into {+ Some(f) => f,+ None => std::env::current_dir()?,+ };+ let made = samples::copy(sample, &folder)?;+ println!("copied {name} to {}", made.display());+ Ok(())+}+fn reference() -> String {use clap::CommandFactory;let mut cli = Cli::command();diff --git a/crates/cli/tests/binary.rs b/crates/cli/tests/binary.rsindex a922882..3c63414 100644--- a/crates/cli/tests/binary.rs+++ b/crates/cli/tests/binary.rs@@ -138,3 +138,44 @@ fn updates_says_what_the_feed_holds() {assert!(String::from_utf8_lossy(&missing.stderr).starts_with("error: could not check: reading"));std::fs::remove_dir_all(&dir).unwrap();}++#[test]+fn samples_are_listed_and_copied_to_draw_on() {+ let dir = std::env::temp_dir().join(format!("draw-binary-samples-{}", std::process::id()));+ let _ = std::fs::remove_dir_all(&dir);+ let shipped = dir.join("shipped");+ let run = |args: &[&str]| {+ Command::new(env!("CARGO_BIN_EXE_klad"))+ .args(args)+ .env("KLAD_SAMPLES", &shipped)+ .current_dir(&dir)+ .output()+ .unwrap()+ };+ std::fs::create_dir_all(&shipped).unwrap();+ let rock = shipped.join("rock/rock.klad");+ let out = run(&["new", rock.to_str().unwrap(), "--width", "64", "--height", "64"]);+ assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));+ std::fs::write(+ shipped.join("shipped.json"),+ r#"[{"name":"rock","bundle":"rock/rock.klad","about":"a rock on its own"}]"#,+ )+ .unwrap();+ let listed = String::from_utf8_lossy(&run(&["samples"]).stdout).to_string();+ assert!(listed.starts_with("rock a rock on its own"), "{listed}");+ let copied = run(&["samples", "--copy", "rock"]);+ assert!(copied.status.success(), "{}", String::from_utf8_lossy(&copied.stderr));+ assert!(+ dir.join("rock.klad/doc.json").is_file(),+ "the copy goes in the current folder"+ );+ let into = dir.join("mine");+ let out = run(&["samples", "--copy", "rock", "--into", into.to_str().unwrap()]);+ assert_eq!(+ String::from_utf8_lossy(&out.stdout).trim(),+ format!("copied rock to {}", into.join("rock.klad").display())+ );+ let wrong = run(&["samples", "--copy", "stone"]);+ assert!(String::from_utf8_lossy(&wrong.stderr).contains("no sample stone; there are rock"));+ std::fs::remove_dir_all(&dir).unwrap();+}diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rsindex a49deee..7b5c5c7 100644--- a/crates/core/src/lib.rs+++ b/crates/core/src/lib.rs@@ -18,6 +18,7 @@ pub mod pathedit;pub mod retime;pub mod rig;pub mod rng;+pub mod samples;pub mod stroke;pub mod synth;pub mod timing;diff --git a/crates/core/src/samples.rs b/crates/core/src/samples.rsnew file mode 100644index 0000000..3dcdfa4--- /dev/null+++ b/crates/core/src/samples.rs@@ -0,0 +1,122 @@+use anyhow::{Context, Result, bail};+use serde::Deserialize;+use std::fs;+use std::path::{Path, PathBuf};++pub const MANIFEST: &str = "shipped.json";++#[derive(Clone, Debug, Deserialize)]+#[serde(deny_unknown_fields)]+struct Entry {+ name: String,+ bundle: String,+ about: String,+}++#[derive(Clone, Debug, PartialEq, Eq)]+pub struct Sample {+ pub name: String,+ pub about: String,+ pub path: PathBuf,+}++pub fn dir() -> Option<PathBuf> {+ if let Some(dir) = std::env::var_os("KLAD_SAMPLES") {+ return Some(PathBuf::from(dir)).filter(|d| d.join(MANIFEST).is_file());+ }+ let exe = std::env::current_exe().ok()?;+ let dir = exe.parent()?;+ [+ dir.join("samples"),+ dir.join("../Resources/samples"),+ dir.join("../share/klad/samples"),+ ]+ .into_iter()+ .chain(dir.ancestors().skip(1).take(5).map(|a| a.join("samples")))+ .find(|d| d.join(MANIFEST).is_file())+}++pub fn listed(dir: &Path) -> Result<Vec<Sample>> {+ let text =+ fs::read_to_string(dir.join(MANIFEST)).with_context(|| format!("reading {}", dir.join(MANIFEST).display()))?;+ let entries: Vec<Entry> = serde_json::from_str(&text).with_context(|| format!("{} does not parse", MANIFEST))?;+ Ok(entries+ .into_iter()+ .map(|e| Sample {+ name: e.name,+ about: e.about,+ path: dir.join(e.bundle),+ })+ .filter(|s| s.path.join("doc.json").is_file())+ .collect())+}++pub fn shipped() -> Vec<Sample> {+ dir().and_then(|d| listed(&d).ok()).unwrap_or_default()+}++pub fn free_path(folder: &Path, name: &str) -> PathBuf {+ (1..)+ .map(|i| match i {+ 1 => folder.join(format!("{name}.klad")),+ n => folder.join(format!("{name} {n}.klad")),+ })+ .find(|p| !p.exists())+ .unwrap_or_else(|| folder.join(format!("{name}.klad")))+}++pub fn copy(sample: &Sample, folder: &Path) -> Result<PathBuf> {+ if !sample.path.join("doc.json").is_file() {+ bail!("the sample {} is not there: {}", sample.name, sample.path.display());+ }+ fs::create_dir_all(folder).with_context(|| format!("making {}", folder.display()))?;+ let to = free_path(folder, &sample.name);+ copy_dir(&sample.path, &to).with_context(|| format!("copying {} to {}", sample.name, to.display()))?;+ Ok(to)+}++fn copy_dir(from: &Path, to: &Path) -> Result<()> {+ fs::create_dir_all(to)?;+ fs::read_dir(from)?+ .filter_map(|e| e.ok())+ .filter(|e| e.file_name() != ".cache")+ .try_for_each(|e| {+ let target = to.join(e.file_name());+ match e.file_type()?.is_dir() {+ true => copy_dir(&e.path(), &target),+ false => fs::copy(e.path(), target).map(|_| ()).map_err(Into::into),+ }+ })+}++#[cfg(test)]+mod tests {+ use super::*;+ use crate::bundle::{Blank, Bundle};++ #[test]+ fn a_sample_is_copied_without_its_cache_under_a_free_name() {+ let dir = std::env::temp_dir().join(format!("klad-samples-{}", std::process::id()));+ let _ = fs::remove_dir_all(&dir);+ let shipped = dir.join("shipped");+ Bundle::blank(shipped.join("rock/rock.klad"), &Blank::default(), "cli").unwrap();+ fs::create_dir_all(shipped.join("rock/rock.klad/.cache")).unwrap();+ fs::write(shipped.join("rock/rock.klad/.cache/thumb.png"), b"x").unwrap();+ fs::write(+ shipped.join(MANIFEST),+ r#"[{"name":"rock","bundle":"rock/rock.klad","about":"a rock"},{"name":"gone","bundle":"gone/gone.klad","about":"not built"}]"#,+ )+ .unwrap();+ let found = listed(&shipped).unwrap();+ assert_eq!(found.len(), 1, "samples that are not built are left out");+ assert_eq!(found[0].about, "a rock");+ let mine = dir.join("mine");+ let first = copy(&found[0], &mine).unwrap();+ let second = copy(&found[0], &mine).unwrap();+ assert_eq!(first, mine.join("rock.klad"));+ assert_eq!(second, mine.join("rock 2.klad"));+ assert!(Bundle::open(&second).is_ok());+ assert!(!first.join(".cache/thumb.png").exists(), "the cache stays behind");+ fs::remove_dir_all(&dir).unwrap();+ }+}diff --git a/docs/DESIGN.md b/docs/DESIGN.mdindex 9aca5ba..9f187e4 100644--- a/docs/DESIGN.md+++ b/docs/DESIGN.md@@ -1,4 +1,4 @@-_Last updated: 2026-11-06 17:17_+_Last updated: 2026-11-06 17:33_# klad: design@@ -29,7 +29,7 @@ crates/Two binaries from one crate: `klad`, the command line, and `klad-editor`, the editor alone (a windowed program on Windows, the executable of `klad.app` on a Mac, started by the Linux AppImage). `klad open [bundle]` launches the same editor from the command line, on the bundle or, without one, on the start window (new, open, recent). `--no-default-features` builds `klad` without the editor. `klad --version` and the editor's About show the version and `git describe` of the commit it was built from (`crates/version.rs`, shared by both crates' build scripts; `KLAD_BUILD` overrides it).-**Platforms and packaging (M7).** Folders follow each platform: settings in `~/Library/Application Support/klad`, `%APPDATA%\klad` or `$XDG_CONFIG_HOME/klad`; downloaded fonts in the same places' data folder; drawings in `~/Drawings` by default. The open panel is `NSOpenPanel` on macOS and `rfd` elsewhere (the XDG portal on Linux, the common dialog on Windows). The pen: macOS reads `NSEvent`; elsewhere a pen that the system reports as a touch with force (Windows pens through `WM_POINTER`) draws with that pressure (`pen::from_egui`), and anything else draws as a mouse at full pressure; Linux tablets report no pressure through `winit` yet. `packaging/` makes the downloads: `macos/app.sh` builds `klad.app` (both binaries, lipo'd when several targets are given, the fonts, licences and skill in `Resources`, `.klad` declared as a document package of type `com.indicode.klad.drawing` so Finder shows a drawing as one item and opens it in klad) and a disk image; `archive.sh <target>` builds a `tar.gz` or `zip` with both binaries, `fonts/`, the licences and `SKILL.md`, and an AppImage on Linux when `APPIMAGETOOL` is set; `icon/` draws the icon in klad and packs `klad.icns` and `klad.ico`. Builds use the `dist` profile (no debug info, stripped, thin LTO); the samples hash the same from it. The fonts are found next to the binary (`fonts/`), in `../Resources/fonts` or `../share/klad/fonts`. On macOS a drawing opened from Finder arrives as an `application:openURLs:` message, which klad adds to `NSObject` before the event loop starts so it reaches whatever delegate `winit` installs; the paths queue up (`opened.rs`) and the start window or editor opens the last. `klad install` puts `klad` on the terminal's path (a link in `/usr/local/bin` through an administrator prompt on macOS, `~/.local/bin` on Linux, the user's `PATH` on Windows); the editor's document menu runs it as a job. `klad skill` prints the agent skill compiled into the binary. Builds are sold on itch.io (later Steam) for macOS and Windows, and Linux is built from source: on a version tag the `release` workflow builds the Windows version and pushes it to itch.io with butler (never as a workflow artifact, which anyone could download from a public repository) and publishes the changelog section as the release notes, and `just itch-mac` builds and pushes the Mac app from a Mac; `check` runs lint, tests and the audit on every pull request, tests on macOS and builds on Windows. The editor asks the GitHub releases API at most once a day (`updates.rs`, curl on a thread, off in the settings window) and, when a newer version is out, says so in the start window, the message line and About, with a link to what changed; it installs nothing. About's "check now" and `klad updates` check on demand (`updates::spawn`, a channel per check) and say why a check failed: no release published yet, no network, or a feed that does not parse.+**Platforms and packaging (M7).** Folders follow each platform: settings in `~/Library/Application Support/klad`, `%APPDATA%\klad` or `$XDG_CONFIG_HOME/klad`; downloaded fonts in the same places' data folder; drawings in `~/Drawings` by default. The open panel is `NSOpenPanel` on macOS and `rfd` elsewhere (the XDG portal on Linux, the common dialog on Windows). The pen: macOS reads `NSEvent`; elsewhere a pen that the system reports as a touch with force (Windows pens through `WM_POINTER`) draws with that pressure (`pen::from_egui`), and anything else draws as a mouse at full pressure; Linux tablets report no pressure through `winit` yet. `packaging/` makes the downloads: `macos/app.sh` builds `klad.app` (both binaries, lipo'd when several targets are given, the fonts, licences and skill in `Resources`, `.klad` declared as a document package of type `com.indicode.klad.drawing` so Finder shows a drawing as one item and opens it in klad) and a disk image; `archive.sh <target>` builds a `tar.gz` or `zip` with both binaries, `fonts/`, the licences and `SKILL.md`, and an AppImage on Linux when `APPIMAGETOOL` is set; `icon/` draws the icon in klad and packs `klad.icns` and `klad.ico`. Builds use the `dist` profile (no debug info, stripped, thin LTO); the samples hash the same from it. The fonts are found next to the binary (`fonts/`), in `../Resources/fonts` or `../share/klad/fonts`. On macOS a drawing opened from Finder arrives as an `application:openURLs:` message, which klad adds to `NSObject` before the event loop starts so it reaches whatever delegate `winit` installs; the paths queue up (`opened.rs`) and the start window or editor opens the last. `klad install` puts `klad` on the terminal's path (a link in `/usr/local/bin` through an administrator prompt on macOS, `~/.local/bin` on Linux, the user's `PATH` on Windows); the editor's document menu runs it as a job. `klad skill` prints the agent skill compiled into the binary; `klad samples` lists and copies the sample drawings a build carries (First start, below). Builds are sold on itch.io (later Steam) for macOS and Windows, and Linux is built from source: on a version tag the `release` workflow builds the Windows version and pushes it to itch.io with butler (never as a workflow artifact, which anyone could download from a public repository) and publishes the changelog section as the release notes, and `just itch-mac` builds and pushes the Mac app from a Mac; `check` runs lint, tests and the audit on every pull request, tests on macOS and builds on Windows. The editor asks the GitHub releases API at most once a day (`updates.rs`, curl on a thread, off in the settings window) and, when a newer version is out, says so in the start window, the message line and About, with a link to what changed; it installs nothing. About's "check now" and `klad updates` check on demand (`updates::spawn`, a channel per check) and say why a check failed: no release published yet, no network, or a feed that does not parse.### Stack@@ -423,6 +423,7 @@ An error is one line on stderr (`error: reading a.klad/doc.json: No such file or| `klad paintover <bundle> <layer> [--from] [--in] [--sizes 32,16,8] [--threshold 6] [--length 1,8] [--curve 0.5] [--brush oil] [--focus] [--vary] [--like <cel> [--frames a-b]] [--part] [--seed]` | brushwork from what is below the layer (see Paint over) || `klad compare <drawing\|png> <reference> [--frame] [--region name=x,y,w,h]... [--heat out.png] [--json]` | values, saturation, texture, edges and colour against a reference, in numbers and words || `klad install [--dir]`, `klad skill` | put `klad` on the terminal's path; print the agent skill |+| `klad samples [--json]`, `klad samples --copy <name> [--into <folder>]` | the sample drawings a build carries; copy one to draw on |Scripts are any language that prints edit ops as JSON lines into `klad apply`. Generators that should stay editable (scatter, repeat, symmetry) are built-in vector node kinds with parameters.@@ -434,6 +435,7 @@ Scripts are any language that prints edit ops as JSON lines into `klad apply`. G- Layout (M4 batch 1): a tool strip on the left (the tools with their key letter, undo and redo, and at its foot settings, numbers and the command palette); a dock on the right holding panes (colour and brush, layers, inspector, notes for the agent, history), each with a title row that folds it, closes it and, dragged at its top edge, resizes the pane above; the timeline along the bottom, resizable and foldable to its toolbar; a status line under everything. Panes share the dock's height: they keep the sizes the user gave them, the last open one takes what is left, and when they do not fit they shrink towards their minimums and scroll inside (`layout::Layout::bodies`). Tab hides every panel but the status line, shift Tab the dock. Which panels are open, the dock's width, the timeline's height and each pane's size are kept in the user's settings (`layout`) and restored, clamped to the window. Pen calibration lives in the settings window (cmd ,); the performance numbers in a numbers window that can stay open over the canvas.- Commands (M4 batch 1): every editor action is a `Cmd` in one list (`commands.rs`): an id (`tool.brush`, `drawing.new`, kept in settings), a name in plain words, a Phosphor icon, a group, its keys or the hold that triggers it, whether a held key repeats it, and a line on what it does. Keys, the strip, panel buttons, the timeline's buttons and context menu, and the palette all run commands through `Editor::invoke`, which first asks `can_run` (a reason when it cannot, shown as a refusal) and remembers the last twelve run. A key matches only with exactly its modifiers (shift K is not K); key repeats run commands that repeat (`=`, `[`, cmd Z) and frame steps only once the frame on screen caught up. cmd K opens the palette: type to filter (name start, then a key, a word, a substring, the letters in order, the group; hyphens ignored, so "inb" finds in-between), arrows and Return run, rows grey out with the reason, recent commands first; `?` opens it too. Every control has a hover hint after 0.35 s (from its command where there is one) and is at least 24 pt high; a test walks every control of every panel and window to keep it so.- Tool options and selections (M4 batch 2): a bar over the canvas holds the active tool's settings (brush: picker, size, opacity, flow, and a "more" menu for hardness, lightest size, curve, taper, stabiliser and smoothing; fill: reference, gap, tolerance, grow, opacity; strokes: cut at the lasso edge, select all; points: corner, smooth, simplify, make it a path). The strip shows the eraser while the eraser brush or the pen's eraser end is on, and two colours (the current one over the second; X or a click swaps them; picking a colour from a swatch, the hex field or the eyedropper makes the old one the second). cmd alt drag sideways on the canvas sizes the brush (doubling every 120 pt), the circle staying where the drag began. H flips the view left-right (the view's mappings and the GPU matrix mirror; the document does not change); the status line's zoom takes a click for 100% and a double-click to fit, its rotation a click to turn upright. A selection bar sits under (or over) the selection's box: for strokes flips, quarter turns, recolour, thinner, thicker, opacity, copy, paste, duplicate in place, delete, deselect; for a shape flips (sx or sy negated and its rotation mirrored), quarter turns, duplicate in place (an `add` of the node without ids, above it), delete, deselect; for points corner, smooth, nudges, delete. Arrows nudge strokes, a shape or points by 1 px, 10 px with shift. Strokes select across layers (M5 batch 2 round 1): cmd or shift click on rows in the layers panel adds paint layers to the active one (marked with a blue edge); S then lassos, clicks and selects all on all of them, and the selection (one part per layer) moves, turns, scales, flips, recolours, cuts at the lasso edge, copies and deletes as one edit, each layer's marks staying on their layer. A selection on several layers drags as its outline (no GPU lift) and lands on release; copies of several layers paste back into their own layers, a copy of one layer into the active one. The strip's panels button lists the five panels and the timeline with a tick each, so a closed panel always has a way back. U draws rectangles and ellipses on a vector layer (shift for a square or circle, alt from the centre, rounded corners for rectangles; fill, outline and width shared with the pen, the fill in the first colour and the outline in the second, as for the pen's paths) as `rect` and `ellipse` nodes. Mirror painting (the brush bar's "mirror" and its axis) paints every stroke's mirror image as it is drawn, in a second stroke buffer landed after the first, and commits both as plain marks in one history step. Handles are drawn at 12 pt and hit within 12 pt (`grab`); shapes whose rotation is a quarter turn get edge handles too (`lift::stretched` scales their own axis). Pen events that arrive while a shape move or point edit is being written are held and replayed in order after it. The colour and brush pane shows the palette (swatches drag to reorder; the x in a hovered swatch's corner, or a right-click, removes it), recent colours, size presets and the brushes as tiles, each with a sample stroke drawn by `klad-brush` once per brush definition.+- First start (S8.7, `start.rs`, `editor/first.rs`, `klad_core::samples`): until the settings say `welcomed` (set when any drawing opens, or by "Not now"), the start window opens with a welcome offering first steps. First steps make `first steps.klad` (1280 by 800 on paper, one paint layer) in the drawings folder and open it with a small window of three steps that tick as they happen: a brush stroke is saved, a fill is saved, the request for an agent is copied (a sentence with the drawing's path asking the agent to read `klad skill`, render the drawing and add a shadow; "install the klad command" sits next to it). Help > First steps opens and closes the window on any drawing. The checklist is the editor's alone: it teaches the hands on the canvas, and an agent's first steps are `klad skill`. Revisit the third step when klad is an MCP server (S8.10). Under the recent drawings the start window shows the samples: the drawings `samples/shipped.json` names (name, bundle, a line on what it shows), each a card with its thumbnail and that line; a click copies it into the drawings folder without its `.cache` (`samples::copy`, `<name>.klad` or `<name> 2.klad`) and opens the copy, so a sample is never changed. `klad samples` lists the same set and `--copy <name> [--into folder]` copies one (default the current folder). Samples are found like the fonts: `KLAD_SAMPLES`, then `samples/` next to the binary, `../Resources/samples`, `../share/klad/samples`, and a source checkout's `samples/` up to five folders above the binary (where they exist after `just samples`; a sample not built is left out). `packaging/samples.sh` puts them in every build: it builds any that are missing with that build's `klad` (through the sample's `build.sh`, `PYTHON` naming the interpreter), copies them without caches, and renders each one's `<name>.thumb.png` next to it at 336 px, so the start window never renders into the app (a thumbnail outside the bundle is used as it is; only recent drawings' `.cache/thumb.png` are remade when the drawing changes). `app.sh` puts them in `Resources/samples`, `archive.sh` in the archive's `samples/` and the AppImage's `usr/share/klad/samples`; the six weigh about 4 MB.- Menus (S8.6, `commands::MENUS`, `menus.rs`): one list of menus (File, Edit, Draw, View, Layer, Frame, Help) holds every command but the holds (pan, zoom, the eyedropper, flipping, rolling, the parallax preview and sizing on the canvas, which are gestures), so the menus, the palette and the keys stay one list; a test fails when a command is in no menu or in two. Items are the commands' names with their first letter capitalised and their keys; toggles show a tick; a command that cannot run now is greyed out (its reason is the palette's). On macOS the list becomes the system menu bar (`menus::install`, rebuilt when the keys or the recent drawings change): an app menu with About, Settings, Services, hide and Quit, then the list, Window and Help. Items target one Objective-C object (`KladMenuTarget`, `define_class!`) whose `kladRun:` queues the command for the next frame (the editor runs it through `Editor::invoke` as any key would) and whose `validateMenuItem:` reads a snapshot of what is off and on that the app refreshes every 0.4 s. The item keys are shown but not claimed: the object is each menu's delegate and answers no to `menuHasKeyEquivalent:forEvent:target:action:`, so a key still reaches the editor's own dispatch (which knows holds, repeats and text fields) and nothing runs twice; only the app menu's own keys (cmd , cmd Q cmd H) and Window's cmd M are AppKit's. On Windows and Linux (and in tests) the same list is an egui menu bar over the window, hidden with the panels (Tab). File > Open recent lists the last ten drawings; File > Close the drawing (cmd W, refused while a job runs) goes back to the start window, where only new, open, recent and quit run. Settings, About and Quit sit in the app menu on macOS and in Edit, Help and File elsewhere.- Messages and jobs (M4 batch 1): every result, refusal and error goes through `Editor::say` with a tone (info, done, refused, error). Done and refused messages show for 3.5 and 6 s as a toast next to the pointer where the user acted (jobs' messages at the bottom right), errors until dismissed, info only in the status line; the status line shows the latest message (a click opens the message log, the last 200 with times), the frame, where the next stroke goes ("draws into c12 on lines, frames 4 to 7"), running jobs with a cancel button, slow internal work (preparing a selection, drawing an edited path, loading a frame), zoom and rotation. Times that used to be status text (stroke, fill, edit, undo, sync, frame step, last play, last job) are kept by name for the numbers window. Background jobs (in-betweens, Godot export) run the same `klad` binary through one job list (`jobs.rs`); when the CLI exits with code 75 (the document changed while it computed) the job runs again, up to three times, so an edit made in the editor meanwhile is never overwritten.- Tools: brush, eraser, smudge, fill (inside lines, gap closing), lasso select and transform, move/rotate/scale handles, path point editing, eyedropper.diff --git a/docs/cli.md b/docs/cli.mdindex 5abb09a..7d201d8 100644--- a/docs/cli.md+++ b/docs/cli.md@@ -75,6 +75,7 @@ This reference is licensed under the MIT License (`LICENSE-MIT`), unlike klad it- [`klad licences`](#klad-licences): Print the licence and the third-party notices (every open source part klad is built on)- [`klad install`](#klad-install): Put klad on the terminal's path, for you and for agents- [`klad skill`](#klad-skill): Print the agent skill: how an agent draws with klad (the same text as docs/skill/SKILL.md)+- [`klad samples`](#klad-samples): List the sample drawings that come with klad, or copy one to draw on- [`klad updates`](#klad-updates): Check now whether a newer klad is out (the editor also checks once a day by itself)- [`klad bench`](#klad-bench): Measure stroke storage, brush speed, replay, cache and compositing- [`klad open`](#klad-open): Open the editor, on a bundle or on the start window (new, open, recent)@@ -3298,6 +3299,31 @@ Options:Print help```+## klad samples++```text+List the sample drawings that come with klad (the editor's start window shows the same ones), or copy one into a folder to open, render and draw on; the copy is yours, the samples stay as they are. Without --into it goes in the current folder, as <name>.klad (or <name> 2.klad when that is taken). KLAD_SAMPLES points at another samples folder (one holding shipped.json).++ klad samples+ klad samples --copy lantern+ klad samples --copy rig --into ~/Drawings++Usage: klad samples [OPTIONS]++Options:+ --copy <COPY>+ The sample to copy, by name++ --into <INTO>+ The folder the copy goes in (default: the current folder)++ --json+++ -h, --help+ Print help (see a summary with '-h')+```+## klad updates```textdiff --git a/docs/skill/SKILL.md b/docs/skill/SKILL.mdindex 28e94a2..35061b2 100644--- a/docs/skill/SKILL.md+++ b/docs/skill/SKILL.md@@ -6,7 +6,7 @@ description: Make and edit 2D art with the klad CLI (`klad`) in a `.klad` bundle# klad-A `.klad` bundle is a folder: `doc.json` (layers, cels, vector nodes, palette), `strokes/<layer>/<cel>.strokes` (paint strokes and fills as data), `brushes/<id>.json` (every brush its strokes use) and `.cache/` (renders, history, notes, tiles). The `klad` CLI edits it; the user edits the same bundle in the editor (`klad open`, or the klad app). Both see each other's changes within a second. The user starts and opens drawings from the editor's start window (cmd N, cmd O, recent) and can copy a drawing's path from the document menu at the bottom of the tool strip to hand it to you. To start one yourself: `klad new art.klad --width 1600 --height 1200 --background '#e9e4da' --sketch` (one paint layer, `l1`, and a vector layer named sketch on top, `l3`). If `klad` is not on the path, the user can run "install the klad command" from that menu (or `klad install` from the folder they unpacked); `klad skill` prints these instructions, matching the version installed.+A `.klad` bundle is a folder: `doc.json` (layers, cels, vector nodes, palette), `strokes/<layer>/<cel>.strokes` (paint strokes and fills as data), `brushes/<id>.json` (every brush its strokes use) and `.cache/` (renders, history, notes, tiles). The `klad` CLI edits it; the user edits the same bundle in the editor (`klad open`, or the klad app). Both see each other's changes within a second. The user starts and opens drawings from the editor's start window (cmd N, cmd O, recent) and can copy a drawing's path from File (the menu bar) or the document menu at the bottom of the tool strip to hand it to you. To start one yourself: `klad new art.klad --width 1600 --height 1200 --background '#e9e4da' --sketch` (one paint layer, `l1`, and a vector layer named sketch on top, `l3`). If `klad` is not on the path, the user can run "install the klad command" from that menu (or `klad install` from the folder they unpacked); `klad skill` prints these instructions, matching the version installed. `klad samples` lists the sample drawings that come with klad, and `klad samples --copy lantern` copies one into the current folder to read, render or draw on: a quick way to see how a finished piece is layered.Working on klad itself: the repository's `CLAUDE.md`, `CONTRIBUTING.md` and `docs/DESIGN.md` are the source of truth. Build the CLI with `just compile` (`just build` also counts the version up, for the person making a build); the binary is `target/release/klad` on macOS and `target/linux/release/klad` on Linux.diff --git a/packaging/archive.sh b/packaging/archive.shindex 1790555..9c88d4e 100755--- a/packaging/archive.sh+++ b/packaging/archive.sh@@ -23,6 +23,7 @@ mkdir -p "$stage/fonts"(cd "$root/fonts" && tar cf - --exclude update.py .) | (cd "$stage/fonts" && tar xf -)cp "$root/LICENSE" "$root/LICENSE-MIT" "$root/THIRD-PARTY-NOTICES.md" "$root/docs/skill/SKILL.md" "$stage/"cp "$root/packaging/icon/icon.png" "$stage/klad.png"+bash "$root/packaging/samples.sh" "${KLAD:-$stage/klad$ext}" "$stage/samples" >/dev/nullcase "$platform" inwindows)(cd "$out" && rm -f "$name.zip" && (command -v 7z >/dev/null && 7z a -tzip "$name.zip" "$name" >/dev/null || powershell -NoProfile -Command "Compress-Archive -Path '$name' -DestinationPath '$name.zip'"))@@ -38,7 +39,7 @@ if [ "$platform" = linux ] && [ -n "${APPIMAGETOOL:-}" ]; thenrm -rf "$app"mkdir -p "$app/usr/bin" "$app/usr/share/klad"cp "$stage/klad" "$stage/klad-editor" "$app/usr/bin/"- cp -R "$stage/fonts" "$app/usr/share/klad/"+ cp -R "$stage/fonts" "$stage/samples" "$app/usr/share/klad/"cp "$root/packaging/linux/AppRun" "$app/AppRun"cp "$root/packaging/linux/klad.desktop" "$app/klad.desktop"cp "$root/packaging/icon/icon.png" "$app/klad.png"diff --git a/packaging/macos/app.sh b/packaging/macos/app.shindex 0894bf3..57e8820 100755--- a/packaging/macos/app.sh+++ b/packaging/macos/app.sh@@ -30,6 +30,7 @@ rsync -a --exclude update.py "$root/fonts/" "$app/Contents/Resources/fonts/"cp "$root/LICENSE" "$root/LICENSE-MIT" "$root/THIRD-PARTY-NOTICES.md" "$app/Contents/Resources/"mkdir -p "$app/Contents/Resources/skill"cp "$root/docs/skill/SKILL.md" "$app/Contents/Resources/skill/"+bash "$root/packaging/samples.sh" "${KLAD:-$app/Contents/MacOS/klad}" "$app/Contents/Resources/samples" >/dev/nullcodesign --force --deep --sign - "$app" 2>/dev/null || trueecho "$app"if [ "${KLAD_DMG:-1}" = "1" ]; thendiff --git a/packaging/samples.sh b/packaging/samples.shnew file mode 100755index 0000000..9905b9b--- /dev/null+++ b/packaging/samples.sh@@ -0,0 +1,28 @@+#!/usr/bin/env bash+set -euo pipefail+root="$(cd "$(dirname "$0")/.." && pwd)"+klad="${1:?give the klad binary that builds the samples}"+dest="${2:?give the folder the samples go in}"+python="$(command -v python3 || command -v python)"+rm -rf "$dest"+mkdir -p "$dest"+"$python" - "$root/samples" "$dest" "$klad" "$python" <<'PY'+import json, os, pathlib, shutil, subprocess, sys+src, dest, klad, python = pathlib.Path(sys.argv[1]), pathlib.Path(sys.argv[2]), sys.argv[3], sys.argv[4]+def run(command, env=None):+ done = subprocess.run(command, env=env, capture_output=True, text=True)+ if done.returncode != 0:+ sys.exit(f"{' '.join(command)} failed:\n{done.stderr}")+for entry in json.loads((src / "shipped.json").read_text()):+ bundle = src / entry["bundle"]+ if not (bundle / "doc.json").is_file():+ env = dict(os.environ, KLAD=klad, PYTHON=python, FORCE="1")+ run(["bash", str(bundle.parent / "build.sh"), str(bundle)], env)+ shutil.copytree(bundle, dest / entry["bundle"], ignore=shutil.ignore_patterns(".cache"))+ canvas = json.loads((bundle / "doc.json").read_text())["canvas"]+ scale = min(1.0, 336 / max(canvas["width"], canvas["height"]))+ thumb = (dest / entry["bundle"]).with_name(bundle.stem + ".thumb.png")+ run([klad, "render", str(bundle), "--scale", f"{scale:.4f}", "-o", str(thumb)])+shutil.copy2(src / "shipped.json", dest / "shipped.json")+PY+echo "$dest"diff --git a/samples/bounce/build.sh b/samples/bounce/build.shindex 8934a29..052544c 100755--- a/samples/bounce/build.sh+++ b/samples/bounce/build.sh@@ -15,7 +15,7 @@ if [ -e "$out" ] && [ "${FORCE:-0}" != 1 ]; thenfirm -rf "$out""$klad" new "$out" --width 1024 --height 768 --layers 0 --fps 12 --frames 20 --background '#f4efe6' >/dev/null-python3 "$here/generate.py" | "$klad" apply "$out" >/dev/null+"${PYTHON:-python3}" "$here/generate.py" | "$klad" apply "$out" >/dev/null"$klad" render "$out" --frame 7 -o "${out%.klad}.png""$klad" frames "$out""$klad" hash "$out" --all --no-cachediff --git a/samples/courier/build.sh b/samples/courier/build.shindex e4d3b6e..e5a435d 100755--- a/samples/courier/build.sh+++ b/samples/courier/build.sh@@ -15,7 +15,7 @@ if [ -e "$out" ] && [ "${FORCE:-0}" != 1 ]; thenfirm -rf "$out""$klad" new "$out" --width 640 --height 560 --layers 0 --fps 12 --frames 16 >/dev/null-python3 "$here/generate.py" | "$klad" apply "$out" >/dev/null+"${PYTHON:-python3}" "$here/generate.py" | "$klad" apply "$out" >/dev/null"$klad" clip "$out" --add idle --from 0 --to 7 --loop >/dev/null"$klad" clip "$out" --add run --from 8 --to 15 --loop >/dev/null"$klad" timeline "$out" --origin 300,500 >/dev/nulldiff --git a/samples/creature/build.sh b/samples/creature/build.shindex 52fe812..401af6d 100755--- a/samples/creature/build.sh+++ b/samples/creature/build.sh@@ -21,7 +21,7 @@ layers=shadow,far,colour,shade,rim,linesrm -rf "$out""$klad" new "$out" --width 1024 --height 1024 --layers 0 --fps 12 --frames 11 --background '#e9e4d8' >/dev/nullecho "keys: idle at 0 and 2, walk at 3, 5, 7 and 9 (parts: body, sprout, leaf, second leaf, near leg, far leg)"-python3 "$here/generate.py" | "$klad" apply "$out" >/dev/null 2>&1+"${PYTHON:-python3}" "$here/generate.py" | "$klad" apply "$out" >/dev/null 2>&1"$klad" clip "$out" --add idle --from 0 --to 2 --loop >/dev/null"$klad" clip "$out" --add walk --from 3 --to 10 --loop >/dev/nullecho "colour every key from the first one:"diff --git a/samples/ink-shapes/build.sh b/samples/ink-shapes/build.shindex dc4b38b..d40347d 100755--- a/samples/ink-shapes/build.sh+++ b/samples/ink-shapes/build.sh@@ -11,6 +11,6 @@ klad="${KLAD:-$root/${KLAD_TARGET_DIR:-$built}/release/klad}"out="${1:-$here/ink-shapes.klad}"rm -rf "$out""$klad" new "$out" --width 960 --height 900 --layers 0 --background '#f4efe6' >/dev/null-python3 "$here/generate.py" | "$klad" apply "$out" >/dev/null+"${PYTHON:-python3}" "$here/generate.py" | "$klad" apply "$out" >/dev/null"$klad" render "$out" -o "${out%.klad}.png""$klad" hash "$out" --no-cachediff --git a/samples/lantern/build.sh b/samples/lantern/build.shindex 53d4fbe..d692842 100755--- a/samples/lantern/build.sh+++ b/samples/lantern/build.sh@@ -15,7 +15,7 @@ if [ -e "$out" ] && [ "${FORCE:-0}" != 1 ]; thenfirm -rf "$out""$klad" new "$out" --width 1024 --height 1280 --layers 0 >/dev/null-python3 "$here/generate.py" ${PAINTED:+--painted} | "$klad" apply "$out" >/dev/null+"${PYTHON:-python3}" "$here/generate.py" ${PAINTED:+--painted} | "$klad" apply "$out" >/dev/null"$klad" render "$out" -o "${out%.klad}.png""$klad" export "$out" --scale 2 -o "${out%.klad}@2x.png""$klad" hash "$out" --no-cachediff --git a/samples/lemons/build.sh b/samples/lemons/build.shindex eac5cea..286f661 100755--- a/samples/lemons/build.sh+++ b/samples/lemons/build.sh@@ -15,7 +15,7 @@ if [ -e "$out" ] && [ "${FORCE:-0}" != 1 ]; thenfirm -rf "$out""$klad" new "$out" --width 1200 --height 900 --layers 0 >/dev/null-python3 "$here/generate.py" ${PLAIN:+--plain} ${RELIEF:+--relief} | "$klad" apply "$out" >/dev/null+"${PYTHON:-python3}" "$here/generate.py" ${PLAIN:+--plain} ${RELIEF:+--relief} | "$klad" apply "$out" >/dev/null"$klad" render "$out" -o "${out%.klad}.png""$klad" export "$out" --scale 2 -o "${out%.klad}@2x.png""$klad" hash "$out" --no-cachediff --git a/samples/meadow/build.sh b/samples/meadow/build.shindex f0a8a3f..8e28046 100755--- a/samples/meadow/build.sh+++ b/samples/meadow/build.sh@@ -19,12 +19,12 @@ rm -rf "$out""$klad" new "$out" --width 1600 --height 760 --layers 0 >/dev/nullfor name in tuft tuft-b; do"$klad" new "$work/$name.klad" --width 256 --height 256 --layers 0 >/dev/null- python3 "$here/generate.py" --picture "$name" | "$klad" apply "$work/$name.klad" >/dev/null+ "${PYTHON:-python3}" "$here/generate.py" --picture "$name" | "$klad" apply "$work/$name.klad" >/dev/null"$klad" render "$work/$name.klad" -o "$work/$name.png" >/dev/null"$klad" brushes "$out" --picture "$name" "$work/$name.png" >/dev/nulldone-python3 "$here/generate.py" --brush > "$work/tuft.json"+"${PYTHON:-python3}" "$here/generate.py" --brush > "$work/tuft.json""$klad" brushes "$out" --set tuft "$work/tuft.json" >/dev/null-python3 "$here/generate.py" | "$klad" apply "$out" >/dev/null+"${PYTHON:-python3}" "$here/generate.py" | "$klad" apply "$out" >/dev/null"$klad" render "$out" -o "${out%.klad}.png""$klad" hash "$out" --no-cachediff --git a/samples/paintover/build.sh b/samples/paintover/build.shindex 20a3823..79495b4 100755--- a/samples/paintover/build.sh+++ b/samples/paintover/build.sh@@ -22,6 +22,6 @@ KLAD="$klad" FORCE=1 bash "$root/samples/lemons/build.sh" "$still" >/dev/null"$klad" render "$still" -o "${still%.klad}.png" | tail -1"$klad" hash "$still" --no-cache | sed -n 1pKLAD="$klad" FORCE=1 bash "$root/samples/creature/build.sh" "$walk" >/dev/null-python3 "$here/build.py" "$klad" "$walk"+"${PYTHON:-python3}" "$here/build.py" "$klad" "$walk""$klad" render "$walk" --sheet walk --drawings -o "${walk%.klad}-sheet.png" | tail -1"$klad" hash "$walk" --all --no-cache | sed -n 1,3pdiff --git a/samples/rig/build.sh b/samples/rig/build.shindex 686aac3..cec620d 100755--- a/samples/rig/build.sh+++ b/samples/rig/build.sh@@ -16,7 +16,7 @@ firm -rf "$out""$klad" new "$out" --width 800 --height 800 --layers 0 --background '#e9e2d4' >/dev/nullfor step in drawing rig weights poses keys; do- python3 "$here/generate.py" "$step" | "$klad" apply "$out" >/dev/null+ "${PYTHON:-python3}" "$here/generate.py" "$step" | "$klad" apply "$out" >/dev/nulldone"$klad" inbetween "$out" --layers colour,lines --from 0 --to 4 | grep 'on bones' || truefor keys in "4 8" "8 12" "12 16"; dodiff --git a/samples/ruin/build.sh b/samples/ruin/build.shindex b285c30..dc03db4 100755--- a/samples/ruin/build.sh+++ b/samples/ruin/build.sh@@ -15,6 +15,6 @@ if [ -e "$out" ] && [ "${FORCE:-0}" != 1 ]; thenfirm -rf "$out""$klad" new "$out" --width 1920 --height 1080 --layers 0 --background '#1c2232' >/dev/null-python3 "$here/generate.py" | "$klad" apply "$out" >/dev/null+"${PYTHON:-python3}" "$here/generate.py" | "$klad" apply "$out" >/dev/null"$klad" render "$out" -o "${out%.klad}.png""$klad" hash "$out" --no-cache | sed -n 1pdiff --git a/samples/shipped.json b/samples/shipped.jsonnew file mode 100644index 0000000..a8bcef7--- /dev/null+++ b/samples/shipped.json@@ -0,0 +1,8 @@+[+ { "name": "lantern", "bundle": "lantern/lantern.klad", "about": "a prop: shapes inked, filled, lit and hatched" },+ { "name": "lemons", "bundle": "lemons/lemons.klad", "about": "a still life painted by form, with lavender shadows" },+ { "name": "bounce", "bundle": "bounce/bounce.klad", "about": "frame by frame: keys, holds and a clip" },+ { "name": "creature", "bundle": "creature/creature.klad", "about": "a walk and an idle from keys, in-betweened" },+ { "name": "rig", "bundle": "rig/rig.klad", "about": "a figure posed with bones, and a lantern on keys" },+ { "name": "ruin", "bundle": "ruin/ruin.klad", "about": "a game background in depth planes, lit by one lantern" }+]diff --git a/samples/sign/build.sh b/samples/sign/build.shindex 13d563d..8398179 100755--- a/samples/sign/build.sh+++ b/samples/sign/build.sh@@ -15,7 +15,7 @@ if [ -e "$out" ] && [ "${FORCE:-0}" != 1 ]; thenfirm -rf "$out""$klad" new "$out" --width 1024 --height 640 --layers 0 >/dev/null-python3 "$here/generate.py" | "$klad" apply "$out" >/dev/null+"${PYTHON:-python3}" "$here/generate.py" | "$klad" apply "$out" >/dev/null"$klad" render "$out" -o "${out%.klad}.png""$klad" export "$out" --scale 2 -o "${out%.klad}@2x.png""$klad" hash "$out" --no-cachediff --git a/samples/solids/build.sh b/samples/solids/build.shindex e02e127..d815184 100755--- a/samples/solids/build.sh+++ b/samples/solids/build.sh@@ -15,7 +15,7 @@ if [ -e "$out" ] && [ "${FORCE:-0}" != 1 ]; thenfirm -rf "$out""$klad" new "$out" --width 1200 --height 900 --layers 0 >/dev/null-python3 "$here/generate.py" > "$out.jsonl"+"${PYTHON:-python3}" "$here/generate.py" > "$out.jsonl""$klad" apply "$out" --file "$out.jsonl" >/dev/nullrm "$out.jsonl""$klad" render "$out" -o "${out%.klad}.png" | sed -n 1pdiff --git a/samples/tree/build.sh b/samples/tree/build.shindex ae4b333..8657ecd 100755--- a/samples/tree/build.sh+++ b/samples/tree/build.sh@@ -15,7 +15,7 @@ if [ -e "$out" ] && [ "${FORCE:-0}" != 1 ]; thenfirm -rf "$out""$klad" new "$out" --width 1024 --height 1280 --layers 0 >/dev/null-python3 "$here/generate.py" | "$klad" apply "$out" >/dev/null+"${PYTHON:-python3}" "$here/generate.py" | "$klad" apply "$out" >/dev/null"$klad" render "$out" -o "${out%.klad}.png""$klad" export "$out" --scale 2 -o "${out%.klad}@2x.png""$klad" hash "$out" --no-cache