A drawing app built for agent/human collaboration
Rust
In-betweens blend colour evenly, a heel-to-toe roll is not a slide, stills replay tile by tile
Indicode BV35154d6da606
diff --git a/crates/brush/src/cache.rs b/crates/brush/src/cache.rsindex c9b3e10..48368b1 100644--- a/crates/brush/src/cache.rs+++ b/crates/brush/src/cache.rs@@ -156,7 +156,7 @@ impl CelCache {Err(_) => {let count = marks.len();let (replay, raster, dabs) =- CelReplay::replay(w, h, marks, brushes).with_context(|| format!("cel {cel}"))?;+ CelReplay::replay_tiled(w, h, marks, brushes).with_context(|| format!("cel {cel}"))?;(replay, raster, How::Replayed, count, dabs)}};diff --git a/crates/brush/src/engine.rs b/crates/brush/src/engine.rsindex ef94037..2705fde 100644--- a/crates/brush/src/engine.rs+++ b/crates/brush/src/engine.rs@@ -8,6 +8,7 @@ use klad_core::color::Rgba;use klad_core::cut::Cut;use klad_core::rng::{Rng, hash2_unit};use klad_core::stroke::{Mark, Sample, Stroke};+use std::ops::Range;const MIN_RADIUS: f32 = 0.6;const SPEED_EASE: f32 = 0.5;@@ -713,7 +714,15 @@ fn stamp(buffer: &mut StrokeBuffer, brush: &Brush, dab: Dab, bristles: Option<(&mut paint,mut lift,mut ridge,- } = buffer.tiles_mut(ty * cols + tx);+ } = buffer.tiles_mut(+ ty * cols + tx,+ [+ x0.max(tx * TILE) - tx * TILE,+ y0.max(ty * TILE) - ty * TILE,+ x1.min(tx * TILE + TILE) - tx * TILE,+ y1.min(ty * TILE + TILE) - ty * TILE,+ ],+ );let (ox, oy) = (tx * TILE, ty * TILE);for y in y0.max(oy)..y1.min(oy + TILE) {let py = y as f32 + 0.5 - cy;@@ -850,7 +859,7 @@ fn stamp_replace(changes.into_iter().for_each(|(x, y, value, height)| {let index = (y / TILE) * cols + x / TILE;let at = (y % TILE) * TILE + x % TILE;- let tiles = buffer.tiles_mut(index);+ let tiles = buffer.tiles_mut(index, [x % TILE, y % TILE, x % TILE + 1, y % TILE + 1]);tiles.coverage[at] = 1.0;if let Some(paint) = tiles.paint {paint[at * 4..at * 4 + 4].copy_from_slice(&value);@@ -933,20 +942,33 @@ fn blend_replace(target: &mut [f16], coverage: &[f32], paint: &[f32], opacity: f});}+#[allow(clippy::too_many_arguments)]fn land(target: &mut [f16],coverage: &[f32],paint: Option<&[f32]>,+ rows: &[Range<usize>],mode: Mode,color: Rgba,opacity: f32,blend: StrokeBlend,) {- match (mode, paint) {- (Mode::Colour, Some(paint)) => blend_colours(target, coverage, paint, color, opacity, blend),- (Mode::Replace, Some(paint)) => blend_replace(target, coverage, paint, opacity, blend == StrokeBlend::Atop),- _ => blend_coverage(target, coverage, color, opacity, blend),- }+ rows.iter().cloned().for_each(|r| {+ let (a, b) = (r.start * 4, r.end * 4);+ match (mode, paint) {+ (Mode::Colour, Some(paint)) => {+ blend_colours(&mut target[a..b], &coverage[r], &paint[a..b], color, opacity, blend)+ }+ (Mode::Replace, Some(paint)) => blend_replace(+ &mut target[a..b],+ &coverage[r],+ &paint[a..b],+ opacity,+ blend == StrokeBlend::Atop,+ ),+ _ => blend_coverage(&mut target[a..b], &coverage[r], color, opacity, blend),+ }+ });}pub fn land_tile(@@ -958,10 +980,12 @@ pub fn land_tile(blend: StrokeBlend,) {if let Some(coverage) = buffer.coverage(index) {+ let rows: Vec<Range<usize>> = buffer.rows(index).collect();land(target,coverage,buffer.paint(index),+ &rows,buffer.mode,color,opacity,@@ -1010,8 +1034,18 @@ fn commit_cut((StrokeBlend::Normal, _) | (_, Mode::Replace) => Some(raster.ensure(index)),(StrokeBlend::Erase | StrokeBlend::Atop, _) => raster.at_mut(index),};+ let rows: Vec<Range<usize>> = buffer.rows(index).collect();if let (Some(target), Some(coverage)) = (target, buffer.coverage(index)) {- land(target, coverage, buffer.paint(index), mode, color, opacity, blend);+ land(+ target,+ coverage,+ buffer.paint(index),+ &rows,+ mode,+ color,+ opacity,+ blend,+ );}land_body(raster, buffer, index, color, opacity, blend);});@@ -1047,13 +1081,14 @@ fn land_body(raster: &mut Raster, buffer: &StrokeBuffer, index: usize, color: Rg_ => None,};let mode = buffer.mode;+ let rows: Vec<Range<usize>> = buffer.rows(index).collect();let heights = raster.heights_mut().ensure(index);- coverage- .iter()- .zip(heights.iter_mut())- .enumerate()- .filter(|(_, (c, _))| **c > 0.0)- .for_each(|(px, (&c, h))| {+ rows.into_iter()+ .flatten()+ .map(|px| (px, coverage[px]))+ .filter(|(_, c)| *c > 0.0)+ .for_each(|(px, c)| {+ let h = &mut heights[px];let mut a = (c * alpha).clamp(0.0, 1.0);if let Some(under) = &under {a *= under[px];@@ -1154,8 +1189,7 @@ pub fn replay_onto(raster: &mut Raster, marks: &[Mark], brushes: &BrushSet) -> R}pub fn replay(width: u32, height: u32, marks: &[Mark], brushes: &BrushSet) -> Result<Replayed> {- let mut raster = Raster::new(width, height);- let dabs = replay_onto(&mut raster, marks, brushes)?;+ let (_, raster, dabs) = crate::replay::CelReplay::replay_tiled(width, height, marks.to_vec(), brushes)?;Ok(Replayed { raster, dabs })}diff --git a/crates/brush/src/replay.rs b/crates/brush/src/replay.rsindex 42ad274..9356794 100644--- a/crates/brush/src/replay.rs+++ b/crates/brush/src/replay.rs@@ -1,14 +1,17 @@use crate::brush::{BrushSet, StrokeBlend};use crate::engine::{commit, draw_stroke_on, land_stroke};use crate::fill::{fill_tiles, paint_fill_where};-use crate::tiles::{Raster, StrokeBuffer, TILE_PX, Tile};+use crate::tiles::{Raster, StrokeBuffer, TILE, TILE_PX, Tile};use anyhow::Result;use half::f16;-use klad_core::stroke::{Mark, Stroke, fingerprint};+use klad_core::brushes::Curve;+use klad_core::stroke::{Mark, Sample, Stroke, fingerprint};+use rayon::prelude::*;use std::collections::{BTreeMap, BTreeSet};use std::sync::Arc;pub const EVERY: usize = 128;+const TILED_FROM: usize = 32;pub const BUDGET: usize = 128 << 20;#[derive(Clone)]@@ -50,6 +53,117 @@ fn painted(})}+fn reach(stroke: &Stroke, brushes: &BrushSet) -> Option<f32> {+ let def = brushes.def(&stroke.brush)?;+ let most = |c: Option<Curve>| c.map_or(1.0, |c| c.min.abs().max(c.max.abs()));+ let size = &def.dynamics.size;+ let radius =+ 0.5 * stroke.size * most(size.pressure) * most(size.tilt) * most(size.speed) * (1.0 + def.jitter.size.abs());+ Some((radius.max(0.6) * (1.0 + 2.0 * def.jitter.scatter.abs()) + 2.0) * 1.25)+}++fn guess(raster: &Raster, brushes: &BrushSet, mark: &Mark) -> Vec<usize> {+ let (cols, rows) = (raster.cols, raster.rows);+ let span = |a: f32, b: f32, n: usize| {+ let last = n as f32 * TILE as f32 - 1.0;+ ((a.clamp(0.0, last) as usize) / TILE)..=((b.clamp(0.0, last) as usize) / TILE)+ };+ match mark {+ Mark::Fill(fill) => crate::fill::fill_tiles(raster, fill),+ Mark::Stroke(stroke) => {+ let points: Vec<(f32, f32)> = stroke.samples.iter().map(Sample::pos).collect();+ let Some(pad) = reach(stroke, brushes).filter(|_| !points.is_empty()) else {+ return (0..cols * rows).collect();+ };+ let (x0, x1) = points+ .iter()+ .fold((f32::MAX, f32::MIN), |(a, b), p| (a.min(p.0), b.max(p.0)));+ let (y0, y1) = points+ .iter()+ .fold((f32::MAX, f32::MIN), |(a, b), p| (a.min(p.1), b.max(p.1)));+ span(y0 - pad, y1 + pad, rows)+ .flat_map(|ty| span(x0 - pad, x1 + pad, cols).map(move |tx| ty * cols + tx))+ .collect()+ }+ }+}++type Tiled = (Raster, Vec<Vec<u32>>, usize);+type TileJob = (usize, Tile, Vec<(usize, Vec<usize>, usize)>);++fn tiled(width: u32, height: u32, marks: &[Mark], brushes: &BrushSet) -> Result<Option<Tiled>> {+ let mut raster = Raster::new(width, height);+ let tiles = raster.cols * raster.rows;+ let reads = marks.iter().any(|m| match m {+ Mark::Stroke(stroke) => brushes.def(&stroke.brush).is_none_or(|d| d.reads_pixels()),+ Mark::Fill(_) => false,+ });+ if reads || tiles < 2 || marks.len() < TILED_FROM {+ return Ok(None);+ }+ let guesses: Vec<Vec<usize>> = marks.iter().map(|m| guess(&raster, brushes, m)).collect();+ let mut jobs: Vec<Vec<usize>> = vec![Vec::new(); tiles];+ guesses+ .iter()+ .enumerate()+ .for_each(|(i, g)| g.iter().for_each(|&t| jobs[t].push(i)));+ let done: Vec<TileJob> = jobs+ .par_iter()+ .enumerate()+ .filter(|(_, job)| !job.is_empty())+ .map(|(t, job)| {+ let mut own = Raster::new(width, height);+ let mut buffer = StrokeBuffer::new(width, height);+ let mut only = vec![false; tiles];+ only[t] = true;+ buffer.set_mask(Some(only));+ let seen = job+ .iter()+ .map(|&i| {+ let (footprint, dabs) = painted(&mut own, &mut buffer, brushes, &marks[i])?;+ Ok((i, footprint, dabs))+ })+ .collect::<Result<Vec<_>>>()?;+ Ok((t, own.tile(t), seen))+ })+ .collect::<Result<Vec<_>>>()?;+ let mut footprints: Vec<Option<Vec<u32>>> = vec![None; marks.len()];+ let mut fills: Vec<Vec<u32>> = vec![Vec::new(); marks.len()];+ let mut dabs = 0;+ done.iter().for_each(|(_, _, seen)| {+ seen.iter().for_each(|(i, footprint, n)| match &marks[*i] {+ Mark::Fill(_) => fills[*i].extend(footprint.iter().map(|&t| t as u32)),+ Mark::Stroke(_) => {+ if footprints[*i].is_none() {+ footprints[*i] = Some(footprint.iter().map(|&t| t as u32).collect());+ dabs += n;+ }+ }+ })+ });+ let footprints: Vec<Vec<u32>> = marks+ .iter()+ .enumerate()+ .map(|(i, m)| match m {+ Mark::Fill(_) => {+ let mut f = std::mem::take(&mut fills[i]);+ f.sort_unstable();+ f+ }+ Mark::Stroke(_) => footprints[i].take().unwrap_or_default(),+ })+ .collect();+ let guessed = footprints+ .iter()+ .zip(&guesses)+ .all(|(f, g)| f.iter().all(|t| g.contains(&(*t as usize))));+ if !guessed {+ return Ok(None);+ }+ done.iter().for_each(|(t, tile, _)| put(&mut raster, *t, tile));+ Ok(Some((raster, footprints, dabs)))+}+fn put(raster: &mut Raster, index: usize, tile: &Tile) {raster.restore(index, tile);}@@ -82,6 +196,24 @@ impl CelReplay {Ok((cel, raster, dabs))}+ pub fn replay_tiled(+ width: u32,+ height: u32,+ marks: Vec<Mark>,+ brushes: &BrushSet,+ ) -> Result<(Self, Raster, usize)> {+ match tiled(width, height, &marks, brushes)? {+ Some((raster, footprints, dabs)) => {+ let mut cel = Self::new(width, height);+ cel.keys = marks.iter().map(|m| (m.id(), fingerprint(m))).collect();+ cel.footprints = footprints;+ cel.marks = marks;+ Ok((cel, raster, dabs))+ }+ None => Self::replay(width, height, marks, brushes),+ }+ }+pub fn from_cache(width: u32, height: u32, keys: Vec<(u32, u64)>, footprints: Vec<Vec<u32>>) -> Self {Self {keys,@@ -387,6 +519,39 @@ mod tests {BrushSet::presets()}+ #[test]+ fn tiles_replayed_on_their_own_match_one_replay_for_every_dry_brush() {+ let set = brushes();+ let mut synth = Synth::canvas(W as f32, H as f32);+ synth.brushes = set+ .defs()+ .filter(|(_, d)| !d.reads_pixels())+ .map(|(id, _)| id.to_string())+ .collect();+ assert!(synth.brushes.len() > 10, "{:?}", synth.brushes);+ let mut all = sample(30);+ all.extend(marks(synth.strokes(260, 11)));+ all.iter_mut().enumerate().for_each(|(i, m)| m.set_id(i as u32 + 1));+ let (one, raster, dabs) = CelReplay::replay(W, H, all.clone(), &set).unwrap();+ let (tiled, fast, fast_dabs) = CelReplay::replay_tiled(W, H, all.clone(), &set).unwrap();+ assert_eq!(fast.hash(), raster.hash());+ assert_eq!(+ (fast_dabs, tiled.footprints(), tiled.keys()),+ (dabs, one.footprints(), one.keys())+ );+ assert_eq!(tiled.checkpoints(), [0], "the tiled path was taken");+ let mut wet = all.clone();+ let mut synth = Synth::canvas(W as f32, H as f32);+ synth.brushes = vec!["wet".into()];+ wet.extend(marks(synth.strokes(2, 5)));+ wet.iter_mut().enumerate().for_each(|(i, m)| m.set_id(i as u32 + 1));+ let (serial, _, _) = CelReplay::replay_tiled(W, H, wet, &set).unwrap();+ assert!(+ serial.checkpoints().len() > 1,+ "a brush that reads pixels replays in order"+ );+ }+fn edited(marks: &[Mark], changes: Vec<MarkChange>) -> Vec<Mark> {let mut out = marks.to_vec();changesdiff --git a/crates/brush/src/tiles.rs b/crates/brush/src/tiles.rsindex fccb623..d632b49 100644--- a/crates/brush/src/tiles.rs+++ b/crates/brush/src/tiles.rs@@ -6,6 +6,7 @@ use std::sync::Arc;pub const TILE: usize = 256;pub const TILE_PX: usize = TILE * TILE;+const EMPTY: [u16; 4] = [TILE as u16, TILE as u16, 0, 0];#[derive(Clone)]pub struct TileGrid<T, const C: usize> {@@ -265,6 +266,7 @@ pub struct StrokeBuffer {pub lifting: bool,touched: Vec<usize>,marked: Vec<bool>,+ rects: Vec<[u16; 4]>,dirty: Vec<usize>,dirty_marked: Vec<bool>,mask: Option<Vec<bool>>,@@ -284,6 +286,7 @@ impl StrokeBuffer {lifting: false,touched: Vec::new(),dirty_marked: marked.clone(),+ rects: vec![EMPTY; marked.len()],marked,dirty: Vec::new(),mask: None,@@ -317,7 +320,14 @@ impl StrokeBuffer {&self.grid}- pub fn tile_mut(&mut self, index: usize) -> &mut [f32] {+ pub fn tile_mut(&mut self, index: usize, rect: [usize; 4]) -> &mut [f32] {+ let r = &mut self.rects[index];+ *r = [+ r[0].min(rect[0] as u16),+ r[1].min(rect[1] as u16),+ r[2].max(rect[2] as u16),+ r[3].max(rect[3] as u16),+ ];if !self.marked[index] {self.marked[index] = true;self.touched.push(index);@@ -329,8 +339,18 @@ impl StrokeBuffer {self.grid.ensure(index)}- pub fn tiles_mut(&mut self, index: usize) -> Tiles<'_> {- self.tile_mut(index);+ pub fn rect(&self, index: usize) -> Option<[usize; 4]> {+ let r = self.rects[index];+ (r[0] < r[2] && r[1] < r[3]).then(|| r.map(usize::from))+ }++ pub fn rows(&self, index: usize) -> impl Iterator<Item = std::ops::Range<usize>> + use<> {+ let r = self.rect(index).unwrap_or([0; 4]);+ (r[1]..r[3]).map(move |y| y * TILE + r[0]..y * TILE + r[2])+ }++ pub fn tiles_mut(&mut self, index: usize, rect: [usize; 4]) -> Tiles<'_> {+ self.tile_mut(index, rect);Tiles {coverage: self.grid.ensure(index),paint: match self.mode {@@ -391,18 +411,22 @@ impl StrokeBuffer {let touched = std::mem::take(&mut self.touched);touched.iter().for_each(|&i| {self.marked[i] = false;- if let Some(tile) = self.grid.at_mut(i) {- tile.fill(0.0);- }- if let Some(tile) = self.paint.at_mut(i) {- tile.fill(0.0);- }- if let Some(tile) = self.lift.at_mut(i) {- tile.fill(0.0);- }- if let Some(tile) = self.ridge.at_mut(i) {- tile.fill(0.0);- }+ let rows: Vec<std::ops::Range<usize>> = self.rows(i).collect();+ rows.iter().for_each(|row| {+ if let Some(tile) = self.grid.at_mut(i) {+ tile[row.clone()].fill(0.0);+ }+ if let Some(tile) = self.paint.at_mut(i) {+ tile[row.start * 4..row.end * 4].fill(0.0);+ }+ if let Some(tile) = self.lift.at_mut(i) {+ tile[row.clone()].fill(0.0);+ }+ if let Some(tile) = self.ridge.at_mut(i) {+ tile[row.clone()].fill(0.0);+ }+ });+ self.rects[i] = EMPTY;});self.touched = touched;self.touched.clear();@@ -451,7 +475,7 @@ mod tests {buffer.set_mask(Some(mask));assert!(buffer.skip(1));assert!(!buffer.skip(2));- buffer.tile_mut(2)[0] = 0.5;+ buffer.tile_mut(2, [0, 0, 1, 1])[0] = 0.5;assert_eq!(buffer.touched(), &[1, 2]);assert!(buffer.coverage(1).is_none());buffer.reset();@@ -461,8 +485,8 @@ mod tests {#[test]fn buffer_reset_clears_only_touched() {let mut buffer = StrokeBuffer::new(512, 512);- buffer.tile_mut(3)[10] = 0.5;- buffer.tile_mut(3)[11] = 0.25;+ buffer.tile_mut(3, [10, 0, 12, 1])[10] = 0.5;+ buffer.tile_mut(3, [10, 0, 12, 1])[11] = 0.25;assert_eq!(buffer.touched(), &[3]);assert_eq!(buffer.take_dirty(), vec![3]);assert!(buffer.take_dirty().is_empty());diff --git a/crates/cli/src/arcs.rs b/crates/cli/src/arcs.rsindex 6a19c9d..4a4d61d 100644--- a/crates/cli/src/arcs.rs+++ b/crates/cli/src/arcs.rs@@ -63,6 +63,7 @@ impl Track {pub struct Spot {pub centre: [f32; 2],pub bottom: [f32; 2],+ pub sole: [f32; 2],}#[derive(Clone, Debug, PartialEq)]@@ -109,9 +110,14 @@ fn spot_of(marks: &[Mark], ids: &[u32]) -> Option<Spot> {.collect();let low = all.iter().map(|p| p[1]).fold(f32::MIN, f32::max);let sole: Vec<f32> = all.iter().filter(|p| p[1] >= low - 1.0).map(|p| p[0]).collect();+ let contact: Vec<f32> = all.iter().filter(|p| p[1] >= low - SLACK).map(|p| p[0]).collect();(!sole.is_empty()).then(|| Spot {centre: [(x0 + x1) / 2.0, (y0 + y1) / 2.0],bottom: [sole.iter().sum::<f32>() / sole.len() as f32, low],+ sole: [+ contact.iter().copied().fold(f32::MAX, f32::min),+ contact.iter().copied().fold(f32::MIN, f32::max),+ ],})}@@ -234,6 +240,7 @@ pub fn track(bundle: &Bundle, tracks: &[Track], (from, to): (u32, u32)) -> Resul.map(|(x, y)| Spot {centre: [x, y],bottom: [x, y],+ sole: [x, x],});Ok((f, at))})@@ -272,7 +279,7 @@ pub fn ground(path: &Path, y: f32, travel: f32, slack: f32) -> Ground {|mut out: Vec<(u32, Spot)>, (f, s)| {if out.last()- .is_none_or(|(_, last)| last.bottom != s.bottom || last.centre != s.centre)+ .is_none_or(|(_, last)| last.bottom != s.bottom || last.centre != s.centre || last.sole != s.sole){out.push((f, s));}@@ -296,7 +303,8 @@ pub fn ground(path: &Path, y: f32, travel: f32, slack: f32) -> Ground {.filter_map(|w| {let ((fa, a), (fb, b)) = (w[0], w[1]);let expected = -travel * (fb - fa) as f32;- let off = (b.bottom[0] - a.bottom[0] - expected).abs();+ let end = |i: usize| (b.sole[i] - a.sole[i] - expected).abs();+ let off = end(0).min(end(1));(touching(&a) && touching(&b) && off > slack).then_some((fa, fb, off))}).collect(),@@ -428,6 +436,7 @@ pub fn report(bundle: &Bundle, tracks: &[Track], span: (u32, u32), checks: &Chec"frame": f,"at": s.map(|s| s.centre),"bottom": s.map(|s| s.bottom),+ "sole": s.map(|s| s.sole),"moved": steps.get(f),})).collect::<Vec<_>>(),"under": g.as_ref().map(|g| g.under.iter().map(|(f, d)| json!({"frame": f, "by": d})).collect::<Vec<_>>()),@@ -522,6 +531,7 @@ mod tests {Some(Spot {centre: [x, y - 10.0],bottom: [x, y],+ sole: [x, x],}),)})@@ -662,6 +672,63 @@ mod tests {assert!(moved(&foot)[0].1 > 3.9);}+ #[test]+ fn a_foot_rolling_from_heel_to_toe_does_not_slide_and_a_pushed_one_does() {+ use klad_core::stroke::Stroke;+ let foot = |heel: (f32, f32), toe: (f32, f32)| -> Vec<Mark> {+ let line: Vec<(f32, f32, f32)> = (0..=12)+ .map(|i| {+ let t = i as f32 / 12.0;+ (heel.0 + (toe.0 - heel.0) * t, heel.1 + (toe.1 - heel.1) * t, 1.0)+ })+ .collect();+ vec![+ Stroke::new(1, "ink", [0.0, 0.0, 0.0, 1.0], 4.0, 1)+ .with_points(&line, 0.0)+ .into(),+ ]+ };+ let at = |marks: Vec<Mark>| spot_of(&marks, &[1]);+ let roll = Path {+ label: "foot".into(),+ spots: [+ foot((100.0, 250.0), (128.0, 238.0)),+ foot((100.0, 250.0), (130.0, 250.0)),+ foot((102.0, 238.0), (130.0, 250.0)),+ ]+ .into_iter()+ .enumerate()+ .map(|(f, m)| (f as u32, at(m)))+ .collect(),+ };+ let bottoms: Vec<f32> = roll.spots.iter().map(|(_, s)| s.unwrap().bottom[0]).collect();+ assert!(+ bottoms[2] - bottoms[0] > 20.0,+ "the lowest point jumps from heel to toe: {bottoms:?}"+ );+ let g = ground(&roll, 250.0, 0.0, SLACK);+ assert_eq!(g.touches, [0, 1, 2]);+ assert!(g.slides.is_empty(), "a roll is not a slide: {:?}", g.slides);+ let pushed = Path {+ label: "foot".into(),+ spots: [+ foot((100.0, 250.0), (130.0, 250.0)),+ foot((110.0, 250.0), (140.0, 250.0)),+ ]+ .into_iter()+ .enumerate()+ .map(|(f, m)| (f as u32, at(m)))+ .collect(),+ };+ let g = ground(&pushed, 250.0, 0.0, SLACK);+ assert_eq!(g.slides.len(), 1);+ assert!((g.slides[0].2 - 10.0).abs() < 0.5, "{:?}", g.slides);+ assert!(+ ground(&pushed, 250.0, -10.0, SLACK).slides.is_empty(),+ "travel accounts for it"+ );+ }+#[test]fn crossing_feet_are_reported_once_per_crossing() {let near = path(diff --git a/crates/cli/src/bench.rs b/crates/cli/src/bench.rsindex 8b5c601..b49cf10 100644--- a/crates/cli/src/bench.rs+++ b/crates/cli/src/bench.rs@@ -1,6 +1,6 @@use crate::layers::compress_raster;use anyhow::Result;-use klad_brush::{BrushSet, Raster, StrokeBuffer, draw_stroke, replay};+use klad_brush::{BrushSet, CelReplay, Raster, StrokeBuffer, draw_stroke, replay};use klad_core::doc::{Document, Layer, Node, Shape};use klad_core::rng::Rng;use klad_core::stroke::{Mark, Stroke, decode_cel, encode_cel, encode_raw, marks};@@ -25,6 +25,7 @@ pub fn run(count: usize, size: u32, seed: u64) -> Result<()> {brush_speed(&brushes)?;repaint_speed(&brushes)?;replay_speed(&strokes, size, &brushes)?;+ still_speed(&brushes, seed)?;compose_speed(&brushes, seed)?;Ok(())}@@ -177,6 +178,43 @@ fn replay_speed(strokes: &[Stroke], size: u32, brushes: &BrushSet) -> Result<()>Ok(())}+fn still_speed(brushes: &BrushSet, seed: u64) -> Result<()> {+ let (w, h) = (960u32, 480u32);+ let mut rng = Rng::new(seed ^ 0x5717);+ let all: Vec<Mark> = (0..41_731u32)+ .map(|i| {+ let (x, y) = (rng.unit() * w as f32, rng.unit() * h as f32);+ let a = rng.unit() * std::f32::consts::TAU;+ let length = 8.0 + rng.unit() * 32.0;+ let size = match i < 31_735 {+ true => 4.0 + rng.unit() * 12.0,+ false => 1.5 + rng.unit() * 1.5,+ };+ let points: Vec<(f32, f32, f32)> = (0..5)+ .map(|k| {+ let t = k as f32 / 4.0;+ (x + a.cos() * length * t, y + a.sin() * length * t, [0.2, 0.9, 1.0, 0.8, 0.1][k])+ })+ .collect();+ let colour = [0.3 + rng.unit() * 0.6, 0.3 + rng.unit() * 0.5, 0.3 + rng.unit() * 0.4, 1.0];+ Stroke::new(i + 1, "oil", colour, size, i).with_points(&points, 8.0).into()+ })+ .collect();+ let start = Instant::now();+ let (_, serial, dabs) = CelReplay::replay(w, h, all.clone(), brushes)?;+ let one = ms(start);+ let start = Instant::now();+ let (_, tiled, _) = CelReplay::replay_tiled(w, h, all, brushes)?;+ let spread = ms(start);+ println!(+ "still 41731 oil strokes at {w}x{h}, {dabs} dabs: in order {:.2} s, tile by tile {:.2} s, identical pixels {}",+ one / 1000.0,+ spread / 1000.0,+ serial.hash() == tiled.hash()+ );+ Ok(())+}+fn compose_speed(brushes: &BrushSet, seed: u64) -> Result<()> {let size = 2048u32;let synth = Synth::canvas(size as f32, size as f32);diff --git a/crates/cli/src/layers.rs b/crates/cli/src/layers.rsindex 7658648..584b417 100644--- a/crates/cli/src/layers.rs+++ b/crates/cli/src/layers.rs@@ -188,7 +188,7 @@ fn load_cel(bundle: &Bundle, brushes: &BrushSet, layer: &str, cel: &str, use_cac};let count = marks.len();let (replay, raster, dabs) =- CelReplay::replay(width, height, marks, brushes).with_context(|| format!("cel {cel}"))?;+ CelReplay::replay_tiled(width, height, marks, brushes).with_context(|| format!("cel {cel}"))?;cache.store(cel, cache.key(&bytes), &raster, &replay)?;klad_brush::cache::CelLoad {raster,diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rsindex 6cf3238..03e7316 100644--- a/crates/cli/src/main.rs+++ b/crates/cli/src/main.rs@@ -300,7 +300,7 @@ enum Command {},#[command(about = "Make the drawings between two keys: a new cel on each frame between them",- long_about = "Make in-betweens of two keys on paint layers: the drawings shown at --from and --to (the second key is the frame where a drawing starts; a link there names its source, so a loop's last in-betweens can lead back to its first drawing). By default a new cel on every frame between them; --count n spreads n of them, each holding until the next.\n\n klad inbetween art.draw --layers lines,colour --from 0 --to 6\n klad inbetween art.draw --layers lines --from 0 --to 8 --count 3 --spacing in-out\n klad inbetween art.draw --layers arm --from 4 --to 10 --match near --pair s3=s7\n klad inbetween art.draw --redo after a key changed\n\nStrokes pair by id (a key duplicated from the other keeps its ids), by --match order or by nearest shape; --pair forces pairs (first key id = second key id). Each pair is resampled along its length; points, pressure, tilt, size, opacity, flow and taper move at the spacing, and the pair turns and scales along an arc about the point its best-fit rotation turns around, so a swinging limb keeps its length. A line end that touches another line in both keys touches it in every in-between. Lasso fills are interpolated; flood fills are recomputed in each in-between from a seed carried with the lines next to it (the layers they fill against go first). Unpaired marks and fills that fail (a seed on a line, a leak) are left out and listed.\n\nSpacing: even, in (eases in: the in-betweens bunch near the first key), out (they bunch near the second key), in-out, or the positions themselves, 0.2,0.5,0.9. Every in-between remembers its keys (tween in klad show), so --redo remakes them after a key changed; it refuses cels changed since they were made unless --force. One history step."+ long_about = "Make in-betweens of two keys on paint layers: the drawings shown at --from and --to (the second key is the frame where a drawing starts; a link there names its source, so a loop's last in-betweens can lead back to its first drawing). By default a new cel on every frame between them; --count n spreads n of them, each holding until the next.\n\n klad inbetween art.draw --layers lines,colour --from 0 --to 6\n klad inbetween art.draw --layers lines --from 0 --to 8 --count 3 --spacing in-out\n klad inbetween art.draw --layers arm --from 4 --to 10 --match near --pair s3=s7\n klad inbetween art.draw --redo after a key changed\n\nStrokes pair by id (a key duplicated from the other keeps its ids), by --match order or by nearest shape; --pair forces pairs (first key id = second key id). Each pair is resampled along its length; points, pressure, tilt, size, opacity, flow, taper and colour move at the spacing (colour evenly in OKLab, so colour the second key for its light and the in-betweens carry the change), and the pair turns and scales along an arc about the point its best-fit rotation turns around, so a swinging limb keeps its length. A line end that touches another line in both keys touches it in every in-between. Lasso fills are interpolated; flood fills are recomputed in each in-between from a seed carried with the lines next to it (the layers they fill against go first). Unpaired marks and fills that fail (a seed on a line, a leak) are left out and listed.\n\nSpacing: even, in (eases in: the in-betweens bunch near the first key), out (they bunch near the second key), in-out, or the positions themselves, 0.2,0.5,0.9. Every in-between remembers its keys (tween in klad show), so --redo remakes them after a key changed; it refuses cels changed since they were made unless --force. One history step.")]Inbetween {bundle: PathBuf,diff --git a/crates/core/src/tween.rs b/crates/core/src/tween.rsindex 743c23d..d9f3769 100644--- a/crates/core/src/tween.rs+++ b/crates/core/src/tween.rs@@ -1,3 +1,4 @@+use crate::color::{from_oklab, from_u16, to_oklab, to_u16};use crate::fill::{Coverage, Fill, FillSource};use crate::markedit::Affine;use crate::stroke::{Author, Mark, Sample, Stroke, fingerprint};@@ -1169,7 +1170,13 @@ fn lerp32(a: f32, b: f32, t: f32) -> f32 {}fn colour(a: [u16; 4], b: [u16; 4], t: f32) -> [u16; 4] {- std::array::from_fn(|i| lerp32(a[i] as f32, b[i] as f32, t).round().clamp(0.0, 65535.0) as u16)+ if a == b {+ return a;+ }+ let (ca, cb) = (from_u16(a), from_u16(b));+ let (la, lb) = (to_oklab(ca), to_oklab(cb));+ let lab = std::array::from_fn(|i| lerp32(la[i], lb[i], t));+ to_u16(from_oklab(lab, lerp32(ca[3], cb[3], t)))}fn stroke_at(s: &StrokePlan, line: &[P], sim: Sim, t: f32) -> Stroke {@@ -1285,6 +1292,7 @@ pub fn made_hash(marks: &[Mark]) -> String {#[cfg(test)]mod tests {use super::*;+ use crate::color::Rgba;use crate::fill::{FillRef, Seed};fn stroke(id: u32, points: &[(f32, f32)], size: f32) -> Mark {@@ -1478,6 +1486,45 @@ mod tests {assert_eq!(plan.floods().len(), 1);}+ #[test]+ fn colours_blend_between_keys_through_oklab() {+ let coloured = |c: Rgba| -> Mark {+ let pts: Vec<(f32, f32, f32)> = arm(0.0).iter().map(|&(x, y)| (x, y, 1.0)).collect();+ Stroke::new(1, "ink", c, 6.0, 7).with_points(&pts, 8.0).into()+ };+ let lit = [0.93, 0.62, 0.25, 1.0];+ let shade = [0.36, 0.38, 0.72, 1.0];+ let fill = |c: Rgba| {+ Mark::Fill(Fill::new(+ 3,+ c,+ FillSource::Polygon(vec![[0.0, 0.0], [10.0, 0.0], [10.0, 10.0]]),+ Coverage::default(),+ ))+ };+ let made = plan(+ &[coloured(lit), fill(lit)],+ &[coloured(shade), fill(shade)],+ Match::Id,+ &[],+ );+ let mid = made.at(0.5);+ let (la, lb) = (to_oklab(lit), to_oklab(shade));+ let want: [f32; 3] = std::array::from_fn(|i| (la[i] + lb[i]) / 2.0);+ [mid[0].as_stroke().unwrap().color, mid[1].as_fill().unwrap().color]+ .iter()+ .for_each(|&c| {+ let got = to_oklab(from_u16(c));+ assert!((0..3).all(|i| (got[i] - want[i]).abs() < 0.004), "{got:?} {want:?}");+ });+ let same = plan(&[coloured(lit)], &[coloured(lit)], Match::Id, &[]);+ assert_eq!(+ same.at(0.5)[0].as_stroke().unwrap().color,+ to_u16(lit),+ "keys of one colour keep it exactly"+ );+ }+#[test]fn anchors_carry_a_point_with_the_line_it_sits_by() {let line = vec![(0.0, 0.0), (100.0, 0.0)];diff --git a/docs/DESIGN.md b/docs/DESIGN.mdindex 25b8780..afff5b8 100644--- a/docs/DESIGN.md+++ b/docs/DESIGN.md@@ -1,4 +1,4 @@-_Last updated: 2026-11-05 12:30_+_Last updated: 2026-11-05 20:00_# klad: design@@ -199,12 +199,12 @@ Unknown keys are errors that list the valid ones, so a typo never passes silentl- Pairing: by id (default: a key duplicated from the other keeps its ids), by `order` (strokes, lasso fills and flood fills each in order) or `near` (greedy on the mean distance between 16 points along each, trying a stroke backwards too). `pair` forces pairs first. A stroke never pairs with a fill, nor a lasso fill with a flood fill; unpaired marks are left out and listed.- Each stroke pair is resampled by arc length to the longer one's sample count; pressure, tilt and time ride along. The best-fit rotation and scale from the first key's points to the second's (a similarity, least squares) is followed along its arc: about its fixed point, the angle and the log of the scale moving with t, and what the fit leaves is added on top in proportion. So a swinging stroke turns about the point it swings around and keeps its length.- Strokes ride on the lines they touch: a stroke end that touches another stroke in both keys (within half that stroke's size plus 2 px, plus a quarter of its own) joins them in a tree rooted at the longest stroke of each connected group, and a child moves in its parent's frame: the parent's motion at t, then the child's own turn relative to the parent along its arc. A hand bending at the wrist stays on the turning arm. The touching end is then moved onto the other line at the interpolated contact (its place along that line and its offset, both interpolated), pulling the nearest third of the stroke (up to 48 px) with it, so closed shapes stay closed. On a closed line, the second key's contact is the one nearest along the line to the first key's, and a contact that jumps more than half the line is not kept.-- Size, opacity, flow, taper and colour interpolate; brush, seed, lock alpha and cuts come from the first key (cuts move with the stroke); in-between marks keep the first key's ids and are marked agent.+- Size, opacity, flow, taper and colour interpolate (colour in OKLab, so lightness and hue change evenly; keys of one colour keep it exactly), so light can follow a turning limb when the second key is coloured for it; brush, seed, lock alpha and cuts come from the first key (cuts move with the stroke); in-between marks keep the first key's ids and are marked agent.- Lasso fills interpolate their polygons the same way. Flood fills are recomputed in each in-between: the seed is carried by the lines it sits next to (the nearest point on the nearest paired stroke of the reference, its place along that stroke and its offset across, found in each key, placed on the in-between strokes and blended by t), moved onto the nearest open pixel when it lands on a line, and the fill is computed with its own settings against the in-between's reference. Layers whose fills reference another in-betweened layer go after it, `all` last. A fill that lands on a line, covers nothing, or comes out over 1.6 times (plus 64 px) or under 0.4 times what the keys' areas say is left out and listed.**Fills like another drawing.** A `fill` with `like` carries every flood fill of one drawing to the layer's other drawings on `frames` (all, a range or a clip): for each target, the reference at the frame where it first shows is cut into regions as the fill would see them (its colour, tolerance and gap); each region near the old fill is compared with the old coverage shifted onto the region's centre (overlap over union, falling off with the distance moved), regions open to the canvas edge only when the old fill touched it; the seed goes to the best region's pixel nearest the shifted old seed and the fill is computed there. A target that already has a fill with that id has it replaced in place, otherwise the fill goes on top with that id (or the next free one). Fills that find no region, cover nothing or come out over 2.5 times (plus 256 px) the old one are listed. One history step for all targets.-**Parts, arcs and hand work in in-betweens (M4.5 batch 2).** Pairing for in-betweens goes forced pairs first (`--pair`), then part by part for every part name both keys have (within a part and a kind of mark, in drawing order when the counts match, by nearest shape when they do not), then the `match` rule for the rest, so keys drawn separately pair whatever their ids. `--loop` takes the loop's first drawing as the second key (the clip holding `--from`, else frame 0; `--to` defaults to the loop's end), so a cycle closes without a temporary link. Marks in one key only follow `unpaired`: left out (the default, listed), `pop` at the middle or at `t`, `fade` (opacity over the in-betweens), `draw-on` (drawn along their length; one-key marks of the first key draw off); they are carried with the lines around them (`tween::carry`: every point anchored along the nearest paired line and placed on that line in the in-between), and flood fills among them are still left out. `--redo --keep-drawn` splits an in-between's marks by author: it remakes the agent's from the keys and keeps the hand-drawn ones on top, carried from the old in-between's lines to the new ones (aligned by mark id; a hand mark in a part follows the lines of that part), with new ids and their parts; `made` stays the hash of the agent's marks, so a plain `--redo` still refuses it. Arcs (`cli/src/arcs.rs`) track a mark through the drawings that show its id, a part's centre in each drawing of a layer (the first paint layer that has the part, or `layer:part`), or a point carried by the stroke nearest to it at the first frame; each frame gives a centre and a lowest point (the middle of the samples within 1 px of the lowest y). `--ground` reports the lowest point under the line, and slides: consecutive changed positions both on the line (within `--slack`) whose horizontal move differs from `-travel` per frame (a cycle drawn in place should move a planted foot back by the travel); with two tracks, frames where their left-right order flips are swaps. `--overlay arcs` draws each track as a line with a dot and a tick across the path per frame, numbered, the current frame ringed; `--overlay parts` boxes and names each part.+**Parts, arcs and hand work in in-betweens (M4.5 batch 2).** Pairing for in-betweens goes forced pairs first (`--pair`), then part by part for every part name both keys have (within a part and a kind of mark, in drawing order when the counts match, by nearest shape when they do not), then the `match` rule for the rest, so keys drawn separately pair whatever their ids. `--loop` takes the loop's first drawing as the second key (the clip holding `--from`, else frame 0; `--to` defaults to the loop's end), so a cycle closes without a temporary link. Marks in one key only follow `unpaired`: left out (the default, listed), `pop` at the middle or at `t`, `fade` (opacity over the in-betweens), `draw-on` (drawn along their length; one-key marks of the first key draw off); they are carried with the lines around them (`tween::carry`: every point anchored along the nearest paired line and placed on that line in the in-between), and flood fills among them are still left out. `--redo --keep-drawn` splits an in-between's marks by author: it remakes the agent's from the keys and keeps the hand-drawn ones on top, carried from the old in-between's lines to the new ones (aligned by mark id; a hand mark in a part follows the lines of that part), with new ids and their parts; `made` stays the hash of the agent's marks, so a plain `--redo` still refuses it. Arcs (`cli/src/arcs.rs`) track a mark through the drawings that show its id, a part's centre in each drawing of a layer (the first paint layer that has the part, or `layer:part`), or a point carried by the stroke nearest to it at the first frame; each frame gives a centre, a lowest point (the middle of the samples within 1 px of the lowest y) and the sole (the span of the samples within 2 px of it, the part on the ground). `--ground` reports the lowest point under the line, and slides: consecutive changed positions both on the line (within `--slack`) where neither end of the sole moved by `-travel` per frame (a cycle drawn in place should move a planted foot back by the travel); the slide is the smaller of the two ends' moves, so a foot rolling from heel to toe, which keeps one end still, is not a slide, and a foot pushed along the ground, which moves both, is; with two tracks, frames where their left-right order flips are swaps. `--overlay arcs` draws each track as a line with a dot and a tick across the path per frame, numbered, the current frame ringed; `--overlay parts` boxes and names each part.**Drawing from shapes.** `ink`, `light`, `hatch`, `scatter` and `fill` with `shape` read the outlines of vector shapes (rects, ellipses, paths; a group means each shape in it), flattened every 2 px and taken to canvas coordinates through the node's transforms (`klad_render::shapes`), and are turned by the CLI into ordinary strokes and fills before the transaction (`cli/src/shapes.rs`), so they replay like any mark; shapes added earlier in the same batch are seen. Ink resamples each outline, splits it at corners sharper than `break` degrees (open paths at their ends too), and gives each sample a pressure from three rules multiplied together and smoothed: the outward normal against the light (0.55 facing it to 1 facing away), the silhouette (0.7 where the outline lies inside another closed outline of the call), the curvature (down to 0.65 on tight curves); a seeded two-sine wobble moves points along the normal. A closed outline without corners is one stroke that starts at its lightest point and overlaps its start by 12 px. `light` makes lasso fills of each closed outline with a cut that keeps the outside of the same outline moved towards the light by `depth` (in `soft` steps from 0.6 to 1.4 times the depth, each at a share of the opacity) for the shade, and moved away from the light by `rimWidth` for the rim. `hatch` cuts parallel lines (or inward offsets of the outline with `along`) into pieces of the given lengths, jittered and clipped to the area; `scatter` places a mark at jittered grid points or `count` random points inside the area and outside `avoid`, scaled and turned by seeded amounts. All of it is deterministic (libm, the seeded RNG). Lasso fills skip the CLI's catch-up of earlier marks (only flood fills need to see them), so 160 fills from one `light` of 40 shapes take about 260 ms.@@ -283,6 +283,8 @@ A fill is a record in a paint cel, in order with the strokes: id, colour, opacitA layer cel's pixels are its strokes and fills replayed in order. Each replay records every mark's footprint (the tiles it touched) and its key (id and a hash of its encoded record), and keeps a checkpoint every 128 marks: the tiles as they were at that point, shared with the previous checkpoint where they did not change. Checkpoints are capped at 128 MB per cel by thinning out every other one.+A stroke lands on its tiles only inside the rectangle its dabs wrote in each tile, and only that rectangle is cleared after it, so a small mark on a large tile costs its own area. Where no mark on a cel reads pixels (no wet, smudge or blender), the CLI replays a cel tile by tile on every core (`CelReplay::replay_tiled`): each mark goes to the tiles its samples' bounds reach (padded by the brush's largest dab and its scatter), each tile replays its marks in order with the others masked out, and the tiles are put together. Every mark's real footprint is then checked against the guess; if any mark reached a tile it was not sent to, the cel replays in order instead, so the pixels are always a full replay's. The tiled replay keeps no checkpoints beyond the first; the editor replays in order, since it edits cels and wants them. A 960x480 still of 41,731 strokes (about 2 million dabs) takes 0.85 s instead of 4.8 s in the container (`klad bench`, the `still` line).+When the marks change (an edit, a removal, an undo, an insert), the old and new lists are matched by key. Marks that kept their key and their order stay; the others are removed or changed. Replay starts from the last checkpoint before the first difference and only redraws the dirty tiles: those the removed and changed marks touched, plus the tiles a changed mark touches on its way. A tile a changed mark reaches that a later unchanged mark also touches is first restored from the checkpoint and caught up; a tile no later mark touches is already right. Unchanged marks are redrawn only where their footprint meets the dirty tiles, and only inside them (dabs outside are placed but not painted). The result is bit for bit a full replay; later checkpoints are remapped to the new positions and refreshed where tiles changed. If unchanged marks changed order, the cel replays in full.The 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).diff --git a/docs/skill/SKILL.md b/docs/skill/SKILL.mdindex 9476e4c..8d20c82 100644--- a/docs/skill/SKILL.md+++ b/docs/skill/SKILL.md@@ -287,7 +287,8 @@ klad retime art.draw 0-11 --on 2 # or --on 1, --fit 16, --reverse,```- Name parts as you draw keys (`--part`, or `"part"` in ops): in-betweens pair part by part first, whatever the ids, so keys drawn separately, or redrawn, or with the user's strokes in between, still pair. Give each piece that moves on its own its own part (one per leaf, per limb): within a part marks pair in drawing order. Without parts keys pair by mark id, so make every key with the same ops in the same order, or `cel dup` a key and change the copy. `--match near` pairs drawings made separately (and turns strokes drawn backwards); `--pair` forces the odd one. Unpaired marks are left out and listed by default: read that list, or let them `--unpaired pop|fade|draw-on`.-- Check the keys' motion before in-betweening, the way an animator flips them: `klad arcs` with a track per foot (parts), `--ground` per foot (a far foot drawn higher for depth has its own line), and `--travel` for a cycle drawn in place (a planted foot moves back by the travel per frame; on twos after retime, halve it). It reports feet under the ground, planted feet sliding, and two feet swapping sides (legs crossing); `--check` makes the build stop. The creature's first keys slid their feet with the body's tilt: feet go where the ground is, not where the hip is.+- Check the keys' motion before in-betweening, the way an animator flips them: `klad arcs` with a track per foot (parts), `--ground` per foot (a far foot drawn higher for depth has its own line), and `--travel` for a cycle drawn in place (a planted foot moves back by the travel per frame; on twos after retime, halve it). It reports feet under the ground, planted feet sliding, and two feet swapping sides (legs crossing); `--check` makes the build stop. It follows the part of the sole on the ground, so a foot rolling from heel to toe is not a slide; for a foot with no flat sole, track a point on it instead (`--track 412,820`, carried by the stroke nearest to it). The creature's first keys slid their feet with the body's tilt: feet go where the ground is, not where the hip is.+- Light that changes as a limb turns: colour the second key's strokes and fills for their new light (`paint` on that key, or `set <cel>:s<id> color=...`); in-betweens blend each pair's colour evenly (in OKLab) along with its points, size, opacity and taper.- A stroke whose end touches another line in both keys rides on that line (a hand on an arm, a leaf on a stem) and its end stays on it, so closed shapes stay closed. Make joins actually touch in every key (within half the line's width plus 2 px); parts that only float near each other move on their own arcs and drift apart mid-way.- A loop's last in-betweens: `--from <last key> --loop` in-betweens towards the loop's first drawing (the clip holding the frame, else frame 0) up to the loop's end. Add the clips before in-betweening.- The editor's in-between panel runs the same `klad inbetween`; its redo takes a choice per in-between: `--redo --only c12,c14,c16 --keep-cels c14 --force-cels c16` (the rest of `--only` only if unchanged). Its History pane shows your steps as "agent" next to the user's, and they can undo back to any of them; a step keeps its author and time through undo and redo, so `klad log` still says whose it was.