A drawing app built for agent/human collaboration
Rust
Docs for attached erasers, smudges and blends
Indicode BVcba592c79641
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8b7236a..6579e67 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -4,8 +4,9 @@The first builds, and klad's licences.-- Drawings are `.klad` folders in a fresh format, `klad/5` (drawings from the first builds open as they are, except their bones, which are dropped). Drawings from before (`.draw` folders) do not open and are not converted.+- Drawings are `.klad` folders in a fresh format, `klad/6` (drawings from the first builds open as they are, except their bones, which are dropped). Drawings from before (`.draw` folders) do not open and are not converted.- Drawings live well in git: an edit changes only the files of what it edits (`doc.json` keeps no revision or id counter), and copies of a drawing edited apart, in a clone or a worktree, never make the same id, so edits to different layers merge. New ids end in the copy's two-letter tag (`l48qa`, `c12:s349qa`); `klad info` shows it. The editor follows a `git checkout` of an open drawing, and klad never renders an old picture from its cache after one. Recolouring several strokes or fills at once (the selection bar in the editor, or `klad recolour`) moves them to the new colour together and keeps each one's own shade, so a painted-over area stays painted. If a merge still leaves an id used twice, `klad repair` (or **Repair and open** when the drawing won't open) gives every later one a new id and moves its stroke files along.+- Erasers, smudges and blends stay with the strokes they were drawn over: move, copy or delete the strokes and they come along (or split, when only some of the strokes move), and an eraser erases only its own strokes, so moving them never bites into the paint they land on. The selection bar shows what is attached, "attached only" moves it on its own (it attaches to what it lands on), and detach frees it (`klad detach`); a stroke its erasers wipe out completely is skipped by clicks and the lasso. `klad strokes --json` lists `on`, `attached` and `hidden`. Stroke files move to version 2 (format `klad/6`); older drawings open with nothing attached.- klad is source-available, not open source: the app is under the PolyForm Internal Use License 1.0.0, with permission for personal use (building from source is free for it), to propose contributions and to share the drawings you make (`LICENSE`). Companies with 100,000 euros or more in revenue a year buy a licence for each person who uses klad; a bought build is that licence, under the same terms. The file format (`docs/format.md`), the command reference (`docs/cli.md`), the agent skill and the new `klad-client` crate are MIT (`LICENSE-MIT`), so any program or agent can read, write and make klad drawings. Contributions come in under a contributor licence agreement (`CLA.md`).- `klad-client`: run klad from Rust, apply edits as JSON ops, read drawings back as JSON, render them.- Builds for macOS (an app, Apple silicon and Intel in one) and Windows, sold on itch.io; Linux from source. Each has the `klad` command line, the editor, the fonts, the licences and the agent skill.diff --git a/docs/DESIGN.md b/docs/DESIGN.mdindex 851942d..a38d575 100644--- a/docs/DESIGN.md+++ b/docs/DESIGN.md@@ -1,4 +1,4 @@-_Last updated: 2026-11-09 09:02_+_Last updated: 2026-11-09 21:30_# klad: design@@ -101,11 +101,11 @@ art.klad/Committed: everything except `.cache/`. A fresh clone rebuilds the cache by replaying strokes and fills.-### doc.json (format `klad/5`)+### doc.json (format `klad/6`)```json{- "format": "klad/5",+ "format": "klad/6","canvas": { "width": 2048, "height": 2048, "background": "#f4efe6" },"timeline": { "fps": 12, "frames": 24, "origin": [1024, 1800],"clips": [{ "name": "run", "from": 0, "to": 11, "loop": true, "fps": 24 }, { "name": "jump", "from": 12, "to": 23 }] },@@ -301,6 +301,16 @@ When the marks change (an edit, a removal, an undo, an insert), the old and newThe editor keeps this record per paint cel. The CLI keeps the final tiles in `.cache/tiles/<cel>.raster` and the keys and footprints in `<cel>.marks`, so the first render after an edit updates the cached tiles the same way (without checkpoints). "Bake" turns a cel into plain pixels stored as compressed tiles and drops its strokes (later).+### Attached modifier strokes++An eraser, smudge or blender stroke (a brush with `blend: erase`, or `paint` of `smudge` or `blend`) records the marks it changed: when it is added (an op, or pen-up in the editor) `klad_core::attach::targets` takes the earlier marks in its drawing whose paint comes within both brushes' reach of its path (fills by their pixels), and the marks of any earlier smudge or blender whose work it reaches, so trimming a smear attaches to what was smeared. Detection is generous on purpose: attaching too much only splits a modifier more often, missing a mark is what would show. It costs 0.1 ms for a small eraser and 2.7 ms for a 160 px soft eraser over 1,800 strokes of a 4,300-stroke painting (container, release). The ids are stored on the modifier (stroke files version 2), so undo, diffs and copies carry them; ids that no longer exist are ignored everywhere.++Edits follow them (`markedit::apply_following`, `attach::follow`, `prune`, `join`): a transform or lasso moves the modifiers whose marks all move and splits one whose marks move in part, a copy for the moved marks landing right after the original; turns and scales stay about the chosen marks; a delete removes a modifier left with no marks; copies take every modifier attached to a copied mark; the lasso picks plain marks, and a piece it cuts off joins its mark's modifiers. A modifier moved on its own is attached again where it lands (`Bundle::reattach`). `detach` clears the list, and the modifier then acts as before attachments existed.++Smudges and blenders still act on whatever is under them; only erasers are scoped (`klad_brush::scope`). From an attached eraser's first mark up to the eraser, the replay keeps three layers over the eraser's reach (its padded bounds, grown to take in any smudge or blender in between): what was there before the first mark, the eraser's marks alone, and the other marks since, each painted in order with the same f16 landing code as the drawing (unattached erasers erase all three, smudges and blenders are run again on each). At the eraser, pixels it covers become the others over its marks erased, over what was before; others stay. When the eraser is drawn, everything under it is its marks, so the result is bit for bit the in-order erase (a test checks soft and hard erasers with fills, lock alpha, colour brushes, smudges and blenders). Moved, its marks erase together and composite over what they land on, and an unattached mark under it sits below its marks if it is older than the first of them, above them otherwise. Overlapping attached erasers scale each other's layers by whether they share marks. A wet stroke, or a smudge or blender with lock alpha, in range leaves the eraser erasing in order, since their landing is not linear in the pixels under them; height (`body`) is erased in order. The tiled replay keeps a scope per tile; an update that touches an eraser's area widens back to the checkpoint before its first mark, after drawing the new marks once to know every tile the edit changes. A drawing without attachments takes none of this. Costs (container, release): 600 attached trims on 300 ink lines render in 101 ms instead of 87, and moving one line takes 14 ms instead of 10; a 4,300-stroke painting with a big attached soft eraser renders as fast as without.++A mark its attached erasers wipe out completely (its coverage times what they leave under 1/255 everywhere, `scope::hidden`) is skipped by clicks and the lasso and listed as `hidden` by `klad strokes --json`.+## Brush engine- **Dabs.** A stroke's samples are interpolated along arc length and a dab is placed every `spacing x size` (the size at that point, taper included).@@ -435,13 +445,13 @@ Scripts are any language that prints edit ops as JSON lines into `klad apply`. G- Canvas: pan, zoom, rotate; pen pressure, tilt and eraser end; 120 Hz on Apple Silicon. The window around the canvas is a neutral grey (`theme::SURROUND`), so colours read true.- Layout (M4 batch 1): a tool strip on the left (the tools with their key letter, undo and redo, and at its foot the document and panels menus, the command palette, settings and, with developer tools on, numbers; the strip only has the height between the menu bar and the timeline, so when both groups do not fit its buttons shrink from 36 to 28 pt, then the foot folds into one menu pinned at the bottom, and last the tools scroll, never overlapping; each size is measured as it is drawn, so the choice does not flicker); a dock on the right holding panes (colour, brush, layers, layer settings (`Pane::Inspector` in code), 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 modal (cmd ,); the performance numbers in a numbers window that can stay open over the canvas, shown only with developer tools on (Settings > Layout, `developerTools`, off by default; `commands::DEVELOPER` lists its commands, which are in no menu, not in the palette and refused without it).- 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, fill with the colour and outline in the colour (rectangles, ellipses, paths and text: `fill`, or `stroke.paint`, or a new `stroke` at the pen's width when it had none; Edit > Shape; `klad set <id> fill=...` is the CLI form), 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 moves as one edit, each layer previewed while it is dragged; 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 six 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`); a press becomes a drag once it has moved 3 pt on screen, so a tap that wobbles selects and does not move; shapes whose rotation is a quarter turn get edge handles too (`lift::stretched` scales their own axis). Pen events that arrive while a point edit is being written are held and replayed in order after it. The colour pane shows the picker and the palette (swatches drag to reorder; the x in a hovered swatch's corner, or a right-click, removes it) and recent colours; the brush pane (its own since 2026-11-08, Kevin: "make brush its own palette, like colour and layers") the size presets and the brushes as tiles, each with a sample stroke drawn by `klad-brush` once per brush definition. A saved layout without a pane gets it after the pane it follows by default.+- 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, and when erasers, smudges or blends are attached to the strokes their count (a click selects only them, Edit > Strokes > Attached only) and detach; for a shape flips (sx or sy negated and its rotation mirrored), quarter turns, fill with the colour and outline in the colour (rectangles, ellipses, paths and text: `fill`, or `stroke.paint`, or a new `stroke` at the pen's width when it had none; Edit > Shape; `klad set <id> fill=...` is the CLI form), 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 moves as one edit, each layer previewed while it is dragged; 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 six 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`); a press becomes a drag once it has moved 3 pt on screen, so a tap that wobbles selects and does not move; shapes whose rotation is a quarter turn get edge handles too (`lift::stretched` scales their own axis). Pen events that arrive while a point edit is being written are held and replayed in order after it. The colour pane shows the picker and the palette (swatches drag to reorder; the x in a hovered swatch's corner, or a right-click, removes it) and recent colours; the brush pane (its own since 2026-11-08, Kevin: "make brush its own palette, like colour and layers") the size presets and the brushes as tiles, each with a sample stroke drawn by `klad-brush` once per brush definition. A saved layout without a pane gets it after the pane it follows by default.- 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.- Messages and problem reports (S8.8, `report.rs`): a message says what happened and what to do next ("nothing to fill there: click inside closed lines, or raise the gap so small openings close"); a refusal names the step that makes the command possible. Errors that mean klad itself went wrong (an invariant broken, a picture missing that should be there) are `report::Bug`s: the editor says "something went wrong inside klad (what), everything up to your last edit is saved; Help > Report a problem sends it to [email protected] or to klad's issues" instead of the bare detail; a job whose CLI crashed reads the same, and a job that failed says "<job> did not finish: <the CLI's reason>". Every error message, job failure and crash of the editor or the CLI is appended to `klad.log` next to the settings (`KLAD_LOG` overrides it; past 512 KB the older half goes), one dated line each. Help > Report a problem opens a window with the report as it will be copied: klad's version and where it ran, the system (macOS version, the Linux distribution, Windows' version, and the processor), a place for what happened, the drawing's size, the last 40 messages and the last 40 lines of the log, with the home folder written as `~` and the drawing's folder as `<the drawing's folder>`. "include the drawing" zips the drawing without its cache next to it (`<name> for a report.zip`, stored entries, written by klad itself) and the report names the file to attach; "copy the report" copies it, "email it to support" opens an email to the support address with the report in it (the person attaches the zip), and "open klad's issues" opens GitHub. Help > Contact support opens an email with the version and the system filled in, and About links klad.studio and the address. Help > Guides and Help > What's new open the guides and the changelog on klad.studio, and the start window's welcome links the guides. The address, the site, the issues page, the guides and the changelog are constants in `klad_core::contact`; the site's sync reads the address from there. Nothing is sent by klad. `klad report [--drawing <bundle>]` prints the same report from the command line (version, system, log, the drawing zipped).- Menus (S8.6, `commands::MENUS`, `menus.rs`): one list of menus 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 (the developer tools are the exception: in none). The menus, in order: File (new, open, recent, close; import; export; the path and the command line tool), Edit (undo; copy, paste, duplicate, delete; selecting; Transform, Strokes and Points submenus), Tools (the tools, the brush, the colours), Layer (new, duplicate, rename, group, delete; show, lock, clip, lock alpha; Mask and Shape generators submenus, paint over; refill and gaps), Frame (stepping, drawings, holds and moves, inserting and removing frames), Animation (playback, onion skin, exposure, Selected frames and Clip submenus, the checks across frames), View (zoom, rotation, flip, the reference), Window (the panels, the message log) and Help. Each command has a short menu label (`Cmd::menu`: "Show", "Clip to layer below", "Export…"), since the menu says what it acts on, while the palette and hints keep the longer names; "…" marks a command that opens a window. Items show one key each (Backspace for delete); toggles show a tick, except commands that open a window; a command that cannot run now is greyed out (its reason is the palette's). A test keeps labels unique in each menu and under 30 characters. 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, whose Window menu also gets the system's Minimize, Zoom and Bring all to front (it is the app's windows menu). 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 and Quit sit in the app menu on macOS and in Edit and File elsewhere; About (with the licences) is in Help everywhere and also in the macOS app menu.- 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 in the bottom left corner of the canvas, newest lowest (2026-11-08: they used to follow the pointer, which got in the way), 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 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. Nothing a user sees names an internal id: the status line, layer settings, the selection, the in-between window, undo messages and the history pane say layers by name and drawings by frame (`Editor::plain` rewrites history summaries and CLI reports), the timeline numbers each layer's drawings 1, 2, 3 in frame order, and new layers are named "paint 1", "vector 2" instead of by id. A kittest scan (`scan` in the control audit and over every tool) fails on an id (`c12`, `l6`, `n357`, `s4`), a milestone or a story number in any visible label. 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.-- Stroke select (S, M2): a click picks the mark you see under the pointer. With "all layers" (the S and V options and Edit > Pick from all layers, `pickAllLayers` in the settings, on by default) that is on the topmost visible, unlocked paint layer that shows paint there, which becomes active: a layer shows paint where its raster's alpha, times its own and its groups' opacity, outside its mask and inside its clip base, passes 5%, and a layer whose pixels are not loaded counts by its marks' shapes (`Scene::seen_at`, `Scene::marks_at`); with "this layer" it is the active layer. In that layer the mark is the topmost one covering the point (inside a stroke's painted width or a fill's coverage, never an eraser stroke), and only when none covers it does one within 5 pt of the point count, so a thin line is still easy to take (`markedit::pick`); when no layer shows paint there, the topmost mark within those 5 pt on any of the layers is taken. A shift click adds or removes on the active layer, a dragged loop picks every stroke whose samples are all inside it and every fill whose pixels are, shift adds or toggles. With "a lasso cuts strokes at its edge" (on by default) the loop also takes the parts of strokes and fills crossing it: the selection shows the dashed lasso and the parts that will move, and the first edit (move, recolour, delete, ...) writes one `lasso` op that splits them, after which the selection is the moved marks. The selection shows as thin lines and a box with corner handles (uniform scale), edge handles (stretch one axis; dragging past the other edge flips) and a rotate knob; dragging moves it on the GPU (the selected marks drawn alone, over the cel replayed without them) and release writes one `transform` or `lasso` op. Layer settings recolour (the current colour), makes thinner or thicker, sets opacity, flips left-right or up-down and deletes, each as one history step. The selection is shared with the agent as addresses.+- Stroke select (S, M2): a click picks the mark you see under the pointer. With "all layers" (the S and V options and Edit > Pick from all layers, `pickAllLayers` in the settings, on by default) that is on the topmost visible, unlocked paint layer that shows paint there, which becomes active: a layer shows paint where its raster's alpha, times its own and its groups' opacity, outside its mask and inside its clip base, passes 5%, and a layer whose pixels are not loaded counts by its marks' shapes (`Scene::seen_at`, `Scene::marks_at`); with "this layer" it is the active layer. In that layer the mark is the topmost one covering the point (inside a stroke's painted width or a fill's coverage, never an eraser stroke or a mark its attached erasers wipe out), and only when none covers it does one within 5 pt of the point count, so a thin line is still easy to take (`markedit::pick`); when no layer shows paint there, the topmost mark within those 5 pt on any of the layers is taken. A shift click adds or removes on the active layer, a dragged loop picks every stroke whose samples are all inside it and every fill whose pixels are (attached erasers, smudges and blends follow their marks instead), shift adds or toggles. With "a lasso cuts strokes at its edge" (on by default) the loop also takes the parts of strokes and fills crossing it: the selection shows the dashed lasso and the parts that will move, and the first edit (move, recolour, delete, ...) writes one `lasso` op that splits them, after which the selection is the moved marks. The selection shows as thin lines and a box with corner handles (uniform scale), edge handles (stretch one axis; dragging past the other edge flips) and a rotate knob; dragging moves it on the GPU (the selected marks drawn alone, over the cel replayed without them) and release writes one `transform` or `lasso` op. Layer settings recolour (the current colour), makes thinner or thicker, sets opacity, flips left-right or up-down and deletes, each as one history step. The selection is shared with the agent as addresses.- Layers (M2 batch 4): layer settings sets clip to the layer below and lock alpha, adds a mask (empty, or hiding all), turns it on and off, removes it, and "paint on the mask" makes the mask the active layer (it also has its own row under its layer). Painting on a mask hides the layer under the strokes; the eraser shows it again. While a mask is active, what it hides is tinted red ("show the mask in red", on by default), and the brush panel says whether the brush or the eraser is on. The brush and fill tools record lock alpha from the active layer.- Live previews and clipping: the editor composes the active layer between cached images of everything below and above it only when that is exact (the active layer and the groups around it are not clipped, masked or a clip base); otherwise each dirty tile composes the whole stack. A drag (a shape with V, strokes with S or V, any grab: move, scale, turn, stretch, an alt-drag copy) previews the edit it will commit: at its first move the editor takes a snapshot of the document and the pixels (tiles are shared, so this is cheap), and while the pointer moves a background job applies the drag's ops in memory, redraws only the tiles they change (vector nodes through the tile patching below, strokes through the cel's replay) and composes those tiles through the whole stack, so clips, masks, blends, group effects and everything above the dragged thing stay exactly right. One job runs at a time and the newest pointer position wins; only tiles on screen are composed while dragging. The composed tiles go straight to the canvas plane, which is shown while a preview is up. On release the edit is written at once (it costs only its tiles), a last job composes the final position, and its tiles are taken as they are when the edit only moved vector nodes; tiles the preview touched that the edit did not are composed again. In a lean scene, while a mask is tinted, or before the canvas has caught up, a drag shows only its outline and lands on release.- Vector edits redraw only their tiles: a changed vector cel whose node order is kept is patched where its changed nodes were and are (their bounds grown for strokes, miter joins, blur and generator instances; added, removed and hidden nodes count), drawn on one surface that holds every node touching those tiles and starts on a tile boundary, so no node is cut at a tile edge, big blurs downsample on the same grid, and the tiles are bit-identical to a full rasterization; hidden nodes and nodes without bounds draw nothing and are left out; a new order, or a node without bounds, redraws the cel. A swapped vector raster (an edit, undo or redo from the remembered rasters) dirties only the tiles whose pixels differ.diff --git a/docs/guide/painting.md b/docs/guide/painting.mdindex fa8d0ff..b42c469 100644--- a/docs/guide/painting.md+++ b/docs/guide/painting.md@@ -1,4 +1,4 @@-_Last updated: 2026-11-08 14:50_+_Last updated: 2026-11-09 21:00_# Painting@@ -10,6 +10,8 @@ Paint with klad's brushes, blend colours on the canvas and make brushes of yourPress **B** and paint on a paint layer. **E** switches to the eraser and back, and so does the eraser end of the pen. **[** and **]** make the brush smaller and bigger.+An eraser stroke stays with the strokes it erased, like a mask that travels with them: move them and the cut goes along, without biting into what they land on. Smudges and blends stay with their strokes the same way. [Move an eraser on its own](selecting.md#move-an-eraser-on-its-own) to change that.+## Pick a brush and a colourClick a brush in the **Brush** pane: Inking pen, Pencil and Marker for lines, Oil, Loaded oil and the bristle brushes for paint. Hold **alt** and click the canvas to pick up a colour from it.diff --git a/docs/guide/selecting.md b/docs/guide/selecting.mdindex da42d8c..c5b5d73 100644--- a/docs/guide/selecting.md+++ b/docs/guide/selecting.md@@ -1,4 +1,4 @@-_Last updated: 2026-11-09 12:23_+_Last updated: 2026-11-09 21:00_# Changing strokes@@ -20,6 +20,13 @@ To pick on every layer instead of only the active one, switch the bar over the cDrag inside the box to move it, a corner to scale it and the knob to turn it. The bar next to the selection recolours it with the current colour, makes strokes thinner or thicker, duplicates it (**cmd D**) and deletes it (**Backspace**). Recolouring several strokes keeps each one's own lighter or darker shade, so a painted area stays painted.+## Move an eraser on its own++1. Select the strokes it erased. The bar shows what is attached to them, such as **1 attached**.+2. Click it, and drag. The eraser attaches to the strokes it lands on.++To let it erase whatever is under it instead, choose **Edit > Strokes > Detach**.+## Bend a stroke1. Press **A** and click the stroke.diff --git a/docs/skill/SKILL.md b/docs/skill/SKILL.mdindex 368e130..1c3e853 100644--- a/docs/skill/SKILL.md+++ b/docs/skill/SKILL.md@@ -77,6 +77,8 @@ klad render art.klad --focus c4:s12- `transform` moves, rotates (degrees, clockwise) and scales about `--pivot` (default: the middle of the marks' bounds). Stroke sizes and tapers scale with them; fills move by whole pixels and are resampled when turned or scaled. Ids in several cels need a `--pivot`.- In `apply`: `{"op":"set","id":"c4:s12","color":"#c84a3a"}`, `{"op":"rm","ids":["c4:s12"]}`, `{"op":"transform","ids":["c4:s3","c4:s5"],"x":40,"y":-10,"rotate":15,"sx":1.2,"sy":1.2}`.- Edits redraw only the tiles the marks touch, from the nearest checkpoint, so they are cheap on large cels.+- Erasers, smudges and blenders attach to the marks they were drawn over (earlier marks in the drawing with paint under them; reaching a smudge's smear takes the smudge's marks). `klad strokes --json` gives a modifier `on` (the addresses it is attached to), a mark `attached` (the modifiers on it), and `hidden: true` for a mark its attached erasers wipe out completely. An attached eraser erases only its marks, so moved with them it leaves what they land on whole.+- Edits follow attachments: `transform` and `lasso` move the modifiers whose marks all move, and split one whose marks move only in part (a copy for the moved marks lands right after it); `rm` removes a modifier left with no marks; `copy` takes every modifier attached to a copied mark. Addressing a modifier itself moves it on its own, and it attaches again to what it lands on. `klad detach art.klad c4:s40` (a modifier, or a mark to free everything attached to it; `{"op":"detach","ids":[...]}`) leaves it where it is, erasing or smudging whatever is under it again.## Lasso@@ -89,6 +91,7 @@ klad lasso art.klad l4 --polygon '...' --cut --rm```- Without a move, turn, scale, flip or `--rm` it lists the strokes and fills inside the polygon and those crossing its edge.+- The lasso picks plain marks; erasers, smudges and blenders attached to them follow (see above).- Without `--cut` only whole marks move (strokes whose points are all inside, fills whose pixels are). With `--cut` each mark crossing the edge is split: the outside part stays put, the inside part becomes a new mark that moves with the rest, so nothing outside the lasso changes. The output names the moved marks (`lasso on l4 moved c2:s10 ...`); they stay strokes and can be edited again.- `klad transform` takes `--flip h` or `--flip v` too. In `transform` and `lasso`, `--scale` scales the marks; their previews use the default size.- In `apply`: `{"op":"lasso","layer":"l4","polygon":[[600,600],[1400,560],[1450,1300]],"cut":true,"x":40,"y":-25}` (also `rotate`, `sx`, `sy`, `scale`, `pivot`, or `"rm":true`).