PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Merge origin/main into feat/tool-213-7-live-retouch
David Mannc951480e99f4
diff --cc crates/engine/src/eraser_cmds.rsindex 7d415a39c,920c96a01..c702b16b7--- a/crates/engine/src/eraser_cmds.rs+++ b/crates/engine/src/eraser_cmds.rs@@@ -158,24 -155,6 +160,24 @@@ fn background_eraser(s: &mut Session, pOk(damage(s, dmg, true))}+/// A `paint.backgroundEraser` stroke shown while it is drawn: the same params, checks and+/// erasing per dab as the commit (on a Background already turned into a normal layer), so the+/// preview at the last point is the committed result.+pub fn live_background_eraser(s: &Session, p: &Value) -> Result<crate::retouch_cmds::LiveDab> {+ const CMD: &str = "paint.backgroundEraser";+ let (stroke, bs, id) = background_eraser_setup(s, p)?;+ let mut doc = (*s.active().ok_or(EngineError::NoDocument)?.doc).clone();+ doc.layer(id).ok_or(EngineError::NoLayer(id))?;+ crate::extra_cmds::background_to_layer(&mut doc, id);+ let stroke = background_eraser_stroke(&stroke);- crate::retouch_cmds::LiveDab::with_effect_on(doc, CMD, &json!({}), stroke, Some(id), 0, true, |pre| match background_eraser_effect(pre.format(), &bs) {++ crate::retouch_cmds::LiveDab::with_effect_on(doc, CMD, &json!({}), stroke, Some(id), 0, true, |pre| match background_eraser_effect(pre, &bs) {+ Some(effect) => Box::new(effect),+ // No alpha: the commit erases nothing either.+ None => Box::new(|_: &mut photocraft_paint::retouch::Region, _: &photocraft_paint::retouch::Footprint| {}),+ })?+ .with_tail_preview()+}+/// Eraser-group command specs.pub fn specs() -> Vec<CommandSpec> {vec![diff --cc crates/engine/src/retouch_cmds.rsindex f314828a2,c25608bb2..3fd492b3d--- a/crates/engine/src/retouch_cmds.rs+++ b/crates/engine/src/retouch_cmds.rs@@@ -26,8 -26,8 +26,9 @@@ use crate::{EngineError, Result, Sessiomod content_aware_move;mod patch;mod pattern_stamp;+pub use pattern_stamp::live_impressionist as live_pattern_impressionist;mod remove;+ pub use content_aware_move::{ContentAwarePreview, preview as content_aware_move_preview};pub use patch::preview as patch_preview;fn bad(cmd: &str, msg: impl Into<String>) -> EngineError {@@@ -369,14 -374,10 +387,15 @@@ impl LiveRetouch}}"paint.historyBrush" => LivePaint::History(history_source(s, id, p, cmd)?),- other => return Err(bad(other, "live retouching strokes are the Clone Stamp, Healing Brush and History Brush")),+ other => return Err(bad(other, "live retouching strokes are the Clone Stamp, Healing Brush, History Brush and Pattern Stamp")),};+ Self::with_paint(s, cmd, p, stroke, id, paint, mode)+ }++ /// Start a live stroke of `cmd` painting `paint` through `stroke`'s coverage.+ fn with_paint(s: &Session, cmd: &str, p: &Value, stroke: Stroke, id: Option<LayerId>, paint: LivePaint, mode: BlendMode) -> Result<Self> {- let pre = s.active().ok_or(EngineError::NoDocument)?.doc.clone();+ let st = s.active().ok_or(EngineError::NoDocument)?;+ let (pre, base) = (st.doc.clone(), (st.doc.id, st.revision));let mut doc = (*pre).clone();let sel = doc.selection.clone();let (surf, lock) = crate::channel_cmds::target_surface(&mut doc, id, p)?;diff --cc crates/paint/src/bg_erase.rsindex c6689fd7b,ec0ce0907..323a90036--- a/crates/paint/src/bg_erase.rs+++ b/crates/paint/src/bg_erase.rs@@@ -50,24 -49,8 +49,25 @@@ fn dist(a: &[f32], b: &[f32]) -> f32/// the selection limits the effect. Returns the damaged rectangle; empty when the surface has no/// alpha channel.pub fn apply_background_eraser(target: &mut Surface, stroke: &Stroke, bs: &BgEraseSettings, selection: Option<&Surface>) -> Rect {- let Some(effect) = background_eraser_effect(target.format(), bs) else { return Rect::EMPTY };- let fmt = target.format();- let Some(a) = alpha_index(&fmt) else { return Rect::EMPTY };++ let Some(effect) = background_eraser_effect(target, bs) else { return Rect::EMPTY };+ apply_dab_stroke(target, &background_eraser_stroke(stroke), selection, false, 0, effect)+}++/// The stroke [`apply_background_eraser`] runs its dabs along: full opacity (the tool has none),+/// never the brush's erase flag. Live previews run the same dabs.+pub fn background_eraser_stroke(stroke: &Stroke) -> Stroke {+ let mut stroke = stroke.clone();+ stroke.brush.opacity = 1.0;+ stroke.brush.erase = false;+ stroke+}+- /// One Background Eraser dab's edit of a working copy in format `fmt`: shared by- /// [`apply_background_eraser`] and live previews that run the dabs as they come, so both erase- /// the same pixels. `None` when `fmt` has no alpha channel (nothing can be erased).- pub fn background_eraser_effect(fmt: PixelFormat, bs: &BgEraseSettings) -> Option<impl FnMut(&mut Region, &Footprint) + use<>> {++/// One Background Eraser dab's edit of a working copy of `pre` (the target before the stroke):++/// shared by [`apply_background_eraser`] and live previews that run the dabs as they come, so both++/// erase the same pixels. `None` when `pre` has no alpha channel (nothing can be erased).++pub fn background_eraser_effect(pre: &Surface, bs: &BgEraseSettings) -> Option<impl FnMut(&mut Region, &Footprint) + use<>> {++ let fmt = pre.format();+ let a = alpha_index(&fmt)?;let nc = a;let tol = if bs.tolerance.is_finite() { bs.tolerance.clamp(0.0, 1.0) } else { 0.0 };let soft = bs.limits != Limits::FindEdges;@@@ -86,23 -68,31 +86,33 @@@1.0}};- let mut stroke = stroke.clone();- stroke.brush.opacity = 1.0;- stroke.brush.erase = false;- // The pixels before the stroke, taken at the first dab. Sampling and matching read these, so a- // dab landing on pixels earlier dabs already erased still samples and matches (#1280).++ let pre = pre.clone();++ // The pixels before the stroke under the working copy, read once per working area. Sampling++ // and matching read these, so a dab landing on pixels earlier dabs already erased still++ // samples and matches (#1280).+ let mut orig: Option<Region> = None;- apply_dab_stroke(target, &stroke, selection, false, 0, |work: &mut Region, fp| {+ Some(move |work: &mut Region, fp: &Footprint| {let r = fp.rect.intersect(&work.rect);if r.is_empty() {return;}- let orig = &*orig.get_or_insert_with(|| work.clone());++ if orig.as_ref().is_none_or(|o| o.rect != work.rect) {++ orig = Some(Region::read(&pre, work.rect));++ }++ let Some(orig) = orig.as_ref() else { return };let (cx, cy) = (fp.dab.center.x.floor() as i32, fp.dab.center.y.floor() as i32);- // The hotspot's colour (None where it is already transparent or off the working area).- let hotspot = |work: &Region| -> Option<Vec<f32>> {- if !work.rect.contains(cx, cy) {+ // The hotspot's colour (None where it was transparent before the stroke or is off the+ // working area).+ let hotspot = || -> Option<Vec<f32>> {+ if !orig.rect.contains(cx, cy) {return None;}- let p = work.px(cx, cy);+ let p = orig.px(cx, cy);(p[a] > 0.0).then(|| p[..nc].to_vec())};- let sampled = match bs.sampling {+ let sampled = match sampling {- Sampling::Continuous => hotspot(work),- Sampling::Once => once.get_or_insert_with(|| hotspot(work)).clone(),+ Sampling::Continuous => hotspot(),+ Sampling::Once => once.get_or_insert_with(hotspot).clone(),Sampling::BackgroundSwatch => Some(swatch.clone()),};let Some(sampled) = sampled else { return };diff --cc docs/brush-parity.mdindex a89b5df3b,39efd3637..2a8035871--- a/docs/brush-parity.md+++ b/docs/brush-parity.md@@@ -1,6 -1,6 +1,6 @@@# Brush and painting parity- > **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-12 · **Change:** minor (checkbox-only Brush Settings rows and non-destructive Smoothing switch; 2026-10-11: Pattern Stamp and Background Eraser draw live, TOOL-213-7) · **Target:** Adobe Photoshop 2026-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (Brush Settings minimum fields follow their Control; checkbox-only rows and non-destructive Smoothing switch; shaped-tip cursor follows the view) · **Target:** Adobe Photoshop 2026++> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (Brush Settings minimum fields follow their Control; checkbox-only rows and non-destructive Smoothing switch; shaped-tip cursor follows the view; 2026-10-11: Pattern Stamp and Background Eraser draw live, TOOL-213-7) · **Target:** Adobe Photoshop 2026Painting is where Photoshop users notice differences first, so it gets its own checklist: thebrush engine (`crates/paint/src/brush.rs`), the Brush Settings UIdiff --cc docs/gaps.mdindex d32a65e7b,23b375123..807f273d8--- a/docs/gaps.md+++ b/docs/gaps.md@@@ -1,6 -1,6 +1,6 @@@# Where PhotoCraft falls short of Photoshop- > **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-12 · **Change:** minor (G4: checkbox-only Brush Settings rows; stroke-quality and performance gaps unchanged; G11: Load/Save Actions `.atn` landed, AUTO-219-2 partial; 2026-10-11: G4: Pattern Stamp and Background Eraser draw live, TOOL-213-7) · **Target:** Adobe Photoshop 2026-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (G4: minimum field interaction, #3825 partial; G1: CMYK Invert, Posterize and Threshold on the inks, 16-bit Lab Invert; Photoshop-oracle floor 145/258; G11: `.atn` import maps 112 events: Select and Mask, Filter Gallery Spatter, Ripple, Crystallize, Pattern Fill layers, mask targeting, Step Backward, nudges in points, Bitmap mode; G5: Free Transform H/V skew fields; G9: toolbar tool shortcut editing; refreshed against main: G2, G5, G7, G9, G10, G13, G14, G17 items that landed; G10: DPX read and write, #1049; G4: checkbox-only Brush Settings rows; G11: Load/Save Actions `.atn` landed, AUTO-219-2 partial; G5: hold-a-key spring-loaded tools landed, #2672; G1: #2465 fixed) · **Target:** Adobe Photoshop 2026++> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (G4: minimum field interaction, #3825 partial; G1: CMYK Invert, Posterize and Threshold on the inks, 16-bit Lab Invert; Photoshop-oracle floor 145/258; G11: `.atn` import maps 112 events: Select and Mask, Filter Gallery Spatter, Ripple, Crystallize, Pattern Fill layers, mask targeting, Step Backward, nudges in points, Bitmap mode; G5: Free Transform H/V skew fields; G9: toolbar tool shortcut editing; refreshed against main: G2, G5, G7, G9, G10, G13, G14, G17 items that landed; G10: DPX read and write, #1049; G4: checkbox-only Brush Settings rows; G11: Load/Save Actions `.atn` landed, AUTO-219-2 partial; G5: hold-a-key spring-loaded tools landed, #2672; G1: #2465 fixed; 2026-10-11: G4: Pattern Stamp and Background Eraser draw live, TOOL-213-7) · **Target:** Adobe Photoshop 2026Every known shortfall against Photoshop 2026 (27.11.0), one entry each, ranked by user impacton the way to beta. This is the work list agents pick from: take the highest-ranked entry thatdiff --cc docs/target-app-parity.mdindex c4cfbfb7b,f6209c58d..88923e1d7--- a/docs/target-app-parity.md+++ b/docs/target-app-parity.md@@@ -1,6 -1,6 +1,6 @@@# PhotoCraft vs Adobe Photoshop: target-app parity- > **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-12 · **Change:** minor (Photoshop Actions `.atn` load and save; 2026-10-11: retouching evidence: Pattern Stamp and Background Eraser draw live, only the Mixer Brush is left of TOOL-213-7; 2026-10-10: Tilt-Shift measurements added; earlier the same day: major, full re-measure against Photoshop 2026 27.11.0; merged `parity-estimate.md` and the roadmap's honest assessment) · **Target:** Adobe Photoshop 2026-> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-12 · **Change:** minor (`.atn` import maps 112 events; Free Transform H/V skew fields; stale rows corrected against `main` and the scorecard, estimates unchanged; Photoshop Actions `.atn` load and save; 2026-10-10: Tilt-Shift measurements added; earlier the same day: major, full re-measure against Photoshop 2026 27.11.0; merged `parity-estimate.md` and the roadmap's honest assessment) · **Target:** Adobe Photoshop 2026++> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-12 · **Change:** minor (`.atn` import maps 112 events; Free Transform H/V skew fields; stale rows corrected against `main` and the scorecard, estimates unchanged; Photoshop Actions `.atn` load and save; 2026-10-11: retouching evidence: Pattern Stamp and Background Eraser draw live, only the Mixer Brush is left of TOOL-213-7; 2026-10-10: Tilt-Shift measurements added; earlier the same day: major, full re-measure against Photoshop 2026 27.11.0; merged `parity-estimate.md` and the roadmap's honest assessment) · **Target:** Adobe Photoshop 2026The authoritative answer to "how close is PhotoCraft to Photoshop, and how much work is left". Theone-page summary is [`ROADMAP.md`](../ROADMAP.md); the ranked work list is [`gaps.md`](gaps.md);@@@ -167,17 -167,17 +167,17 @@@ parity for the area and are already con| Area | % | Hours | Notes ||---|---:|---:|---|- | Layers, groups, masks, blend modes, smart objects, layer styles | 65% | 150–250 | Broad and GPU-accelerated. Open: multi-layer Smart Object conversion (#2604, #2648), layer clipboard between documents (UI-217-23), Stamp Visible, contour editor, smart-object perspective (FILE-215-6), mask targeting by command (#2458) |- | Selections, Select and Mask, channels | 55% | 120–200 | All selection tools, single row/column marquee included (#2837). Select and Mask is a generic dialog (TOOL-214-1), no Refine Hair (#2671); Select Subject/Sky classical, 559 ms p50 on 24 MP vs a 100 ms budget |+ | Layers, groups, masks, blend modes, smart objects, layer styles | 65% | 150–250 | Broad and GPU-accelerated. Open: layer clipboard between documents (UI-217-23: `layer.copyToDocument` exists, no copy/paste), smart-object perspective (FILE-215-6), a user contour library (FILE-215-15). Multi-layer Smart Object conversion (#2052, #2651), Stamp Visible (UI-217-22) and mask targeting by command (#2458) are done |+ | Selections, Select and Mask, channels | 55% | 120–200 | All selection tools, single row/column marquee included (#2837). Select and Mask is a dialog with Photoshop's view modes, a Refine Edge Brush and six outputs, not a workspace (TOOL-214-1), no Refine Hair (#2671); Select Subject/Sky classical, 559 ms p50 on 24 MP vs a 100 ms budget || Painting and brush engine | 55% | 150–250 | Every Brush Settings section exists; feel is the gap: lag on big brushes, pressure jumps, smoothing and edge quality reports ([brush-parity.md](brush-parity.md)) |-| Retouching (healing, clone, patch, remove, content-aware) | 50% | 100–180 | Remove tool non-generative; Content-Aware Fill has no workspace (TOOL-214-15); live stroke preview only for Brush/Eraser (TOOL-213-7) |+| Retouching (healing, clone, patch, remove, content-aware) | 50% | 100–180 | Remove tool non-generative; Content-Aware Fill has no workspace (TOOL-214-15); no live stroke preview for the Mixer Brush yet (TOOL-213-7) |- | Transform, warp, puppet, perspective, liquify | 55% | 100–180 | Free Transform modifiers right; no transform context menu (TOOL-214-5), no skew fields, puppet mesh is a block grid (TOOL-214-6), Liquify called "useless" by a user (#2606) |+ | Transform, warp, puppet, perspective, liquify | 55% | 100–180 | Free Transform modifiers right, with a right-click transform menu (TOOL-214-5) and H/V skew fields; Puppet Warp mesh follows the object outline (TOOL-214-6); Liquify called "useless" by a user (#2606) || Adjustments and filters | 70% | 120–200 | All present; smart-filter re-render matches Photoshop on 5 of 30 files; Filter Gallery looks approximate; no Neural Filters || Type | 40% | 120–200 | Engine works; no type on a path, manual kerning, RTL paragraphs, OpenType panel UI, live Warp Text preview; Type tool freeze on macOS (#2518) |- | Vector shapes and paths | 55% | 80–140 | Pen, Direct/Path Selection, shapes, shape strokes. Freeform and Curvature Pen (#1054). Missing anchor tools, on-canvas corner radius, path-point nudge; shape parity tracking issue #2496 |+ | Vector shapes and paths | 55% | 80–140 | Pen, Direct/Path Selection, shapes, shape strokes. Freeform and Curvature Pen (#1054). Add/Delete Anchor Point and Convert Point tools exist (`Tool` enum); missing on-canvas corner radius (TOOL-214-12), path-point nudge; shape parity tracking issue #2496 || Colour management and modes | 70% | 60–100 | Own ICC engine, soft proof, CMYK/Lab/Indexed/Duotone/Multichannel; no Adobe CMYK profiles, no spot plates (FILE-215-17), monitor profile only at launch || Camera Raw and computational photo (Photomerge, HDR, lens) | 45% | 120–200 | Raw for DNG/CR2/NEF/ARW/RW2/ORF/RAF(uncompressed)/PEF; no CR3; ACR dialog partial (no masking, calibration); generic lens profiles only |- | Automation, actions, batch, scripting | 45% | 120–200 | CLI/MCP/control channel ahead of Photoshop; Actions panel and recording not document-independent (AUTO-219-1/2); `.atn` load/save since 2026-10-12 (108 events mapped, the rest kept verbatim); no ExtendScript/UXP |+ | Automation, actions, batch, scripting | 45% | 120–200 | CLI/MCP/control channel ahead of Photoshop; Actions panel and recording not document-independent (AUTO-219-1/2); `.atn` load/save since 2026-10-12 (112 events mapped, the rest kept verbatim); no ExtendScript/UXP || File I/O | 60% | 300–500 | See [file-format-parity.md](file-format-parity.md) || Print, export, Save for Web | 50% | 60–100 | JPEG Options dialog missing (FILE-215-19), no Photoshop PDF, no separations, Save for Web settings not remembered || Video / timeline, data-driven graphics | 30% | 100–200 | Menu items live; frame model persists in `.pcraft`; no PSD video-layer mapping |@@@ -563,8 -563,10 +563,11 @@@ See [method, raw measurements and repro| Date | Change | Summary ||---|---|---|+ | 2026-10-12 | minor | Free Transform options bar H/V skew fields; percentages unchanged |+ | 2026-10-12 | minor | `.atn` import: 112 events mapped (TrueGrit Texture Supply sets play end to end); percentages unchanged || 2026-10-12 | minor | Photoshop Actions `.atn` load and save (90 events mapped both ways); percentages unchanged |+ | 2026-10-12 | minor | Rows checked against `main` and the regenerated scorecard: menu count 631, Workspace checklist and preference count, transform context menu, Puppet Warp mesh, Select and Mask, anchor-point tools, Smart Object conversion, Stamp Visible, mask targeting, Free Transform commit/cancel, Vietnamese catalog, Windows ARM64; percentages, weights and hours not re-measured |+| 2026-10-11 | minor | Retouching evidence: Pattern Stamp and Background Eraser draw live (#3754), only the Mixer Brush is left of TOOL-213-7; percentages unchanged || 2026-10-10 | minor | Added measured Tilt-Shift computation/filtered-proxy gains and inconclusive cases; parity percentages and budgets unchanged || 2026-10-10 | minor | Readiness-by-audience table: percent and hours for full, mainstream and essentials; full number confirmed as the additive weighted sum over dimensions (46%, reported ~45%) || 2026-10-10 | minor | Added mainstream-practitioner (~43%) and essentials-user (~61%) numbers with written weights and discounts; full ready-for-real-work rechecked against its written weights (46%, reported ~45%), unchanged |