Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Integration: merge main into batch 6

David Mann7a54fa9c772e
diff --cc apps/photocraft-web/src/web.rs
index 7818bdf2b,74f22b1ad..a7d8d3bb8
--- a/apps/photocraft-web/src/web.rs
+++ b/apps/photocraft-web/src/web.rs
@@@ -17,11 -17,11 +17,11 @@@ use wasm_bindgen::JsCast as _
type Inbox = Arc<Mutex<Vec<(String, Vec<u8>)>>>;
/// Everything File › Open reads: PhotoCraft, Photoshop, OpenRaster, Krita and Affinity documents, flat images, and
- /// Photoshop brushes (.abr), gradients (.grd), layer styles (.asl) and swatches (.aco, .ase), which go to the preset libraries.
-/// Photoshop brushes (.abr), gradients (.grd) and swatches (.aco, .act, .ase), which go to the preset libraries.
++/// Photoshop brushes (.abr), gradients (.grd), layer styles (.asl) and swatches (.aco, .act, .ase), which go to the preset libraries.
const OPEN_EXTS: &[&str] = &[
"pcraft", "pdn", "ora", "xcf", "xcfgz", "gz", "kra", "krz", "psd", "psb", "psdt", "png", "jpg", "jpeg", "tif", "tiff", "webp", "gif", "bmp", "tga", "ico",
"qoi", "exr", "hdr", "pbm", "pgm", "ppm", "pam", "pfm", "dds", "fits", "fit", "fts", "dpx", "cin", "heic", "heif", "hif", "dng", "cr2", "cr3", "nef",
- "nrw", "arw", "pef", "orf", "rw2", "raf", "abr", "grd", "asl", "svg", "svgz", "aco", "ase", "af", "afdesign", "afphoto", "afpub",
- "nrw", "arw", "pef", "orf", "rw2", "raf", "abr", "grd", "svg", "svgz", "aco", "act", "ase", "af", "afdesign", "afphoto", "afpub",
++ "nrw", "arw", "pef", "orf", "rw2", "raf", "abr", "grd", "asl", "svg", "svgz", "aco", "act", "ase", "af", "afdesign", "afphoto", "afpub",
];
const SVG_EXTS: &[&str] = &["svg", "svgz"];
const CANVAS_ID: &str = "photocraft_canvas";
diff --cc apps/photocraft/src/services.rs
index 2f0261532,84a15c8d5..dcfa66c4f
--- a/apps/photocraft/src/services.rs
+++ b/apps/photocraft/src/services.rs
@@@ -17,12 -17,12 +17,13 @@@ use std::sync::Arc
mod recovery_tests;
/// Everything File › Open reads: PhotoCraft, Photoshop, OpenRaster, Krita and Affinity documents, flat images, and
- /// Photoshop brushes (.abr), gradients (.grd), layer styles (.asl), swatches (.aco, .ase) and keyboard shortcut sets
-/// Photoshop brushes (.abr), gradients (.grd), swatches (.aco, .act, .ase) and keyboard shortcut sets
++/// Photoshop brushes (.abr), gradients (.grd), layer styles (.asl), swatches (.aco, .act, .ase) and keyboard shortcut sets
/// (.kys), which go to the preset libraries and Edit › Keyboard Shortcuts.
const OPEN_EXTS: &[&str] = &[
"pcraft", "pdn", "ora", "xcf", "xcfgz", "gz", "kra", "krz", "psd", "psb", "psdt", "png", "jpg", "jpeg", "tif", "tiff", "webp", "gif", "bmp", "tga", "ico",
"qoi", "exr", "hdr", "pbm", "pgm", "ppm", "pam", "pfm", "pcx", "dds", "xpm", "fits", "fit", "fts", "dpx", "cin", "heic", "heif", "hif", "dng", "cr2",
- "cr3", "nef", "nrw", "arw", "pef", "orf", "rw2", "raf", "abr", "grd", "asl", "svg", "svgz", "aco", "ase", "kys", "af", "afdesign", "afphoto", "afpub",
- "cr3", "nef", "nrw", "arw", "pef", "orf", "rw2", "raf", "abr", "grd", "svg", "svgz", "aco", "act", "ase", "kys", "af", "afdesign", "afphoto", "afpub",
++ "cr3", "nef", "nrw", "arw", "pef", "orf", "rw2", "raf", "abr", "grd", "asl", "svg", "svgz", "aco", "act", "ase", "kys", "af", "afdesign", "afphoto",
++ "afpub",
];
const SVG_EXTS: &[&str] = &["svg", "svgz"];
@@@ -70,8 -70,7 +71,8 @@@ const OPEN_FILTERS: &[(&str, &[&str])]
("Camera Raw", &["dng", "cr2", "cr3", "nef", "nrw", "arw", "pef", "orf", "rw2", "raf"]),
("Brushes", &["abr"]),
("Gradients", &["grd"]),
+ ("Styles", &["asl"]),
- ("Swatches", &["aco", "ase"]),
+ ("Swatches", &["aco", "act", "ase"]),
("Keyboard Shortcuts", &["kys"]),
];
diff --cc crates/compose/src/cmyk_tests.rs
index 4618429de,000000000..58973db9a
mode 100644,000000..100644
--- a/crates/compose/src/cmyk_tests.rs
+++ b/crates/compose/src/cmyk_tests.rs
@@@ -1,1653 -1,0 +1,1656 @@@
+use photocraft_color::blend::BlendMode;
+use photocraft_color::{ColorMode, PixelFormat, SampleType};
+use photocraft_doc::{Adjustment, Document, Knockout, Layer, LayerContent, LayerMask};
+use photocraft_geom::{Rect, Size};
+use photocraft_raster::Surface;
+use proptest::prelude::*;
+
+use super::*;
+
+const CMYKA8: PixelFormat = PixelFormat { mode: ColorMode::Cmyk, sample: SampleType::U8, alpha: true };
+const CMYK8: PixelFormat = PixelFormat { mode: ColorMode::Cmyk, sample: SampleType::U8, alpha: false };
+
+fn doc(w: u32, h: u32) -> Document {
+ Document::new("c", Size::new(w, h), ColorMode::Cmyk, SampleType::U8)
+}
+
+fn layer(rects: &[(Rect, Cmyka)]) -> Layer {
+ let mut l = Layer::raster("l", CMYKA8);
+ for (r, c) in rects {
+ if let Some(s) = l.surface_mut() {
+ s.fill_rect(*r, c);
+ }
+ }
+ l
+}
+
+/// An opaque layer without alpha (as a flattened Background is).
+fn paper(w: i32, h: i32, c: [f32; 4]) -> Layer {
+ let mut l = Layer::raster("bg", CMYK8);
+ if let Some(s) = l.surface_mut() {
+ s.fill_rect(Rect::new(0, 0, w, h), &c);
+ }
+ l
+}
+
+fn mask(rects: &[(Rect, f32)], default: f32, density: f32, enabled: bool) -> LayerMask {
+ let mut surface = Surface::with_default(PixelFormat::GRAY8, &[default]);
+ for (r, v) in rects {
+ surface.fill_rect(*r, &[*v]);
+ }
+ LayerMask { surface, enabled, linked: true, density, feather: 0.0 }
+}
+
+/// An 8-bit sample as stored.
+fn q(v: f32) -> f32 {
+ (v.clamp(0.0, 1.0) * 255.0).round() / 255.0
+}
+
+// ---- an independent per-pixel reference -------------------------------------------------------
+
+/// Porter-Duff source-over with straight alpha, written out separately from the compositor.
+fn over(b: Cmyka, s: Cmyka, opacity: f32) -> Cmyka {
+ let sa = s[4] * opacity;
+ let a = sa + b[4] * (1.0 - sa);
+ if sa <= 0.0 {
+ return b;
+ }
+ if a <= 0.0 {
+ return [0.0; 5];
+ }
+ let mut o = [0.0; 5];
+ for i in 0..4 {
+ o[i] = (s[i] * sa + b[i] * b[4] * (1.0 - sa)) / a;
+ }
+ o[4] = a;
+ o
+}
+
+fn ref_mask(l: &Layer, x: i32, y: i32) -> f32 {
+ l.mask.as_ref().map_or(1.0, |m| if m.enabled { 1.0 - m.density * (1.0 - m.surface.sample_channel(x, y, 0)) } else { 1.0 })
+}
+
+fn ref_own(l: &Layer, x: i32, y: i32) -> Cmyka {
+ let s = match &l.content {
+ LayerContent::Fill(f) => match &l.fill_cache {
+ Some(c) if c.fill == *f => Some(&c.surface),
+ _ => {
+ // A solid colour's inks and alpha, stored at the (8-bit) document's levels.
+ let photocraft_doc::Fill::Solid(color) = f else { return [0.0; 5] };
+ let c = color.in_mode(ColorMode::Cmyk);
+ return [q(c.c[0]), q(c.c[1]), q(c.c[2]), q(c.c[3]), q(color.alpha) * ref_mask(l, x, y)];
+ }
+ },
+ _ => l.surface(),
+ };
+ let Some(s) = s else { return [0.0; 5] };
+ let p = s.pixel(x, y);
+ let a = if s.format().alpha { p[4] } else { 1.0 };
+ [p[0], p[1], p[2], p[3], a * ref_mask(l, x, y)]
+}
+
+/// Source-over with coverage mixed in the type gamma, on brightness (1 − ink), worked out from
+/// the colour transfer functions directly.
+fn over_text(b: Cmyka, s: Cmyka, opacity: f32) -> Cmyka {
+ let gamma = crate::psblend::text_gamma();
+ let sa = s[4] * opacity;
+ if sa <= 0.0 {
+ return b;
+ }
+ let a = sa + b[4] * (1.0 - sa);
+ if a <= 0.0 {
+ return [0.0; 5];
+ }
+ let enc = |ink: f32| photocraft_color::convert::srgb_to_linear((1.0 - ink).max(0.0)).powf(1.0 / gamma);
+ let dec = |v: f32| 1.0 - photocraft_color::convert::linear_to_srgb(v.max(0.0).powf(gamma));
+ let mut o = [0.0; 5];
+ for i in 0..4 {
+ // Mixing an ink with itself (or with nothing) leaves it exactly as it is.
+ o[i] = if b[4] <= 0.0 || b[i] == s[i] { s[i] } else { dec((1.0 - sa) * b[4] / a * enc(b[i]) + sa / a * enc(s[i])) };
+ }
+ o[4] = a;
+ o
+}
+
+/// The blended ink of one channel: the blend function on brightness, back to ink.
+fn ref_blend(mode: BlendMode, b: f32, s: f32) -> f32 {
+ 1.0 - crate::psblend::blend_rgb(mode, [1.0 - b; 3], [1.0 - s; 3])[0]
+}
+
+/// The general compositing formula (W3C / PDF), written out on each ink.
+fn over_mode(mode: BlendMode, b: Cmyka, s: Cmyka, opacity: f32, text: bool) -> Cmyka {
+ if mode == BlendMode::Normal {
+ return if text { over_text(b, s, opacity) } else { over(b, s, opacity) };
+ }
+ let sa = s[4] * opacity;
+ if sa <= 0.0 {
+ return b;
+ }
+ let a = sa + b[4] * (1.0 - sa);
+ if a <= 0.0 {
+ return [0.0; 5];
+ }
+ let gamma = if text { crate::psblend::text_gamma() } else { 1.0 };
+ let enc = |ink: f32| photocraft_color::convert::srgb_to_linear((1.0 - ink).max(0.0)).powf(1.0 / gamma);
+ let dec = |v: f32| 1.0 - photocraft_color::convert::linear_to_srgb(v.max(0.0).powf(gamma));
+ let (wb, ws, wbs) = ((1.0 - sa) * b[4] / a, (1.0 - b[4]) * sa / a, sa * b[4] / a);
+ let mut o = [0.0; 5];
+ for i in 0..4 {
+ let m = ref_blend(mode, b[i], s[i]);
+ o[i] = if text { dec(wb * enc(b[i]) + ws * enc(s[i]) + wbs * enc(m)) } else { wb * b[i] + ws * s[i] + wbs * m };
+ }
+ o[4] = a;
+ o
+}
+
+/// `l` onto the backdrop in its blend mode (Dissolve: every pixel shown fully or not at all).
+fn over_layer(l: &Layer, b: Cmyka, s: Cmyka, opacity: f32, at: Option<(i32, i32)>) -> Cmyka {
+ if let (BlendMode::Dissolve, Some((x, y))) = (l.blend, at) {
+ let shown = crate::dissolve_noise(x, y) < s[4] * opacity;
+ return over(b, [s[0], s[1], s[2], s[3], if shown { 1.0 } else { 0.0 }], 1.0);
+ }
+ over_mode(l.blend, b, s, opacity, matches!(l.content, LayerContent::Text(_)))
+}
+
+/// Photoshop's special eight below 100% Fill, written out on each ink: the source pulled toward
+/// the mode's neutral colour is blended at full strength (`psblend::blend_rgb_fill`, on
+/// brightness), Opacity is its coverage over the backdrop, Fill × Opacity over nothing.
+fn over_special_fill(l: &Layer, b: Cmyka, s: Cmyka) -> Cmyka {
+ let f = l.fill_opacity.clamp(0.0, 1.0);
+ let over = s[4] * l.opacity;
+ if over <= 0.0 {
+ return b;
+ }
+ let a = b[4] + (1.0 - b[4]) * over * f;
+ if a <= 0.0 {
+ return [0.0; 5];
+ }
+ let text = matches!(l.content, LayerContent::Text(_));
+ let gamma = crate::psblend::text_gamma();
+ let enc = |v: f32| if text { photocraft_color::convert::srgb_to_linear(v.max(0.0)).powf(1.0 / gamma) } else { v };
+ let dec = |v: f32| if text { photocraft_color::convert::linear_to_srgb(v.max(0.0).powf(gamma)) } else { v };
+ let (wb, wbs, ws) = (b[4] * (1.0 - over) / a, b[4] * over / a, (1.0 - b[4]) * over * f / a);
+ let mut o = [0.0; 5];
+ for i in 0..4 {
+ let (bb, sb) = (1.0 - b[i], 1.0 - s[i]);
+ let m = crate::psblend::blend_rgb_fill(l.blend, [bb; 3], [sb; 3], f)[0];
+ o[i] = 1.0 - dec(wb * enc(bb) + wbs * enc(m) + ws * enc(sb));
+ }
+ o[4] = a;
+ o
+}
+
+/// An adjustment on one pixel: each ink's brightness through the channel's table (Levels and
+/// Curves: the compositor's tables for an 8-bit document, interpolated here), Invert and
+/// Posterize written out.
+fn ref_adjust(adj: &Adjustment, p: Cmyka) -> Cmyka {
+ if p[4] <= 0.0 {
+ return p;
+ }
+ let luts = crate::adjust::tone_luts_depth(adj, Some(SampleType::U8));
+ let mut o = p;
+ for c in 0..4 {
+ let v = 1.0 - p[c];
+ let r = match adj {
+ Adjustment::Invert => 1.0 - v,
+ Adjustment::Posterize { levels } => {
+ let n = (*levels).clamp(2, 255) as f32;
+ let bin = ((v * 255.0).round() * n / 256.0).floor().min(n - 1.0);
+ (bin * 255.0 / (n - 1.0)).floor() / 255.0
+ }
+ _ => {
+ let t = &luts[c];
+ let x = v.clamp(0.0, 1.0) * (t.len() - 1) as f32;
+ let i = x.floor() as usize;
+ let j = (i + 1).min(t.len() - 1);
+ t[i] + (t[j] - t[i]) * (x - i as f32)
+ }
+ };
+ o[c] = 1.0 - r;
+ }
+ o
+}
+
+/// An adjustment layer `l` (adjusting `p`, then `clipped` onto that) mixed into `p` in its blend
+/// mode by its opacity and mask; coverage stays.
+fn ref_adjusted(l: &Layer, adj: &Adjustment, clipped: &[Layer], p: Cmyka, x: i32, y: i32) -> Cmyka {
+ let mut a = ref_adjust(adj, p);
+ if p[4] > 0.0 {
+ a = ref_clip(clipped, a, x, y);
+ }
+ let k = l.opacity * l.fill_opacity * ref_mask(l, x, y);
+ let mut o = p;
+ for c in 0..4 {
+ o[c] = p[c] + (ref_blend(l.blend, p[c], a[c]) - p[c]) * k;
+ }
+ o
+}
+
+/// `clipped` onto `content` (blending as if it were opaque; its coverage stays).
+fn ref_clip(clipped: &[Layer], mut content: Cmyka, x: i32, y: i32) -> Cmyka {
+ for c in clipped.iter().filter(|c| c.visible) {
+ if let LayerContent::Adjustment(adj) = &c.content {
+ content = ref_adjusted(c, adj, &[], content, x, y);
+ } else if content[4] > 0.0 {
+ let a = content[4];
+ let r = over_layer(c, [content[0], content[1], content[2], content[3], 1.0], ref_own(c, x, y), c.opacity * c.fill_opacity, None);
+ content = [r[0], r[1], r[2], r[3], a];
+ }
+ }
+ content
+}
+
+/// Rounding to an 8-bit document's levels: stored channel brightness, and coverage.
+fn ref_round(p: Cmyka) -> Cmyka {
+ let r = |v: f32| (v * 255.0 + 0.5).floor() / 255.0;
+ [1.0 - r(1.0 - p[0]), 1.0 - r(1.0 - p[1]), 1.0 - r(1.0 - p[2]), 1.0 - r(1.0 - p[3]), r(p[4])]
+}
+
+fn ref_stack(layers: &[Layer], x: i32, y: i32, mut b: Cmyka) -> Cmyka {
+ let mut i = 0;
+ while i < layers.len() {
+ let base = &layers[i];
+ let mut j = i + 1;
+ while j < layers.len() && layers[j].clipped && !base.clipped {
+ j += 1;
+ }
+ if base.visible {
+ b = ref_layer(base, &layers[i + 1..j], x, y, b);
+ if matches!(base.content, LayerContent::Adjustment(_)) {
+ b = ref_round(b);
+ }
+ }
+ i = j;
+ }
+ b
+}
+
+fn ref_layer(l: &Layer, clipped: &[Layer], x: i32, y: i32, b: Cmyka) -> Cmyka {
+ let op = l.opacity * l.fill_opacity;
+ let mut content = match &l.content {
+ LayerContent::Group(g) if l.blend == BlendMode::PassThrough && l.fill_opacity >= 1.0 => {
+ let r = ref_stack(&g.children, x, y, b);
+ if op >= 1.0 && l.mask.is_none() {
+ return r;
+ }
+ let k = op * ref_mask(l, x, y);
+ let (wa, wb) = (b[4] * (1.0 - k), r[4] * k);
+ let a = wa + wb;
+ if a <= 0.0 {
+ return [0.0; 5];
+ }
+ let mut o = [0.0; 5];
+ for c in 0..4 {
+ o[c] = (b[c] * wa + r[c] * wb) / a;
+ }
+ o[4] = a;
+ return o;
+ }
+ LayerContent::Adjustment(adj) => return ref_adjusted(l, adj, clipped, b, x, y),
+ LayerContent::Group(g) => {
+ let mut c = ref_stack(&g.children, x, y, [0.0; 5]);
+ c[4] *= ref_mask(l, x, y);
+ c
+ }
+ _ => ref_own(l, x, y),
+ };
+ content = ref_clip(clipped, content, x, y);
+ // The special eight below 100% Fill, a layer's own blend and an isolated group's alike.
+ if l.fill_opacity < 1.0 && crate::psblend::fill_is_special(l.blend) {
+ return over_special_fill(l, b, content);
+ }
+ over_layer(l, b, content, op, Some((x, y)))
+}
+
+fn assert_matches_reference(d: &Document) {
+ let rect = Rect::new(-1, -1, d.size.width as i32 + 1, d.size.height as i32 + 1);
+ let Some(got) = render_cmyk(d, rect) else { panic!("supported") };
+ let rgb = crate::render(d, rect);
+ for y in rect.y0..rect.y1 {
+ for x in rect.x0..rect.x1 {
+ let i = ((y - rect.y0) * rect.width() as i32 + (x - rect.x0)) as usize;
+ let (g, want) = (got.px[i], ref_stack(&d.layers, x, y, [0.0; 5]));
+ assert!(g.iter().all(|v| v.is_finite()), "({x},{y}) {g:?}");
+ // Ink only means something where there is coverage.
+ let close = |a: f32, b: f32| (a - b).abs() <= 1e-5;
+ assert!(close(g[4], want[4]), "alpha ({x},{y}): {g:?} vs reference {want:?}");
+ if want[4] > 1e-4 {
+ assert!((0..4).all(|c| close(g[c], want[c])), "ink ({x},{y}): {g:?} vs reference {want:?}");
+ }
+ // Coverage doesn't depend on the colour model: the RGB compositor agrees.
+ assert!((g[4] - rgb.px[i][3]).abs() <= 1e-5, "alpha vs RGB ({x},{y}): {g:?} vs {:?}", rgb.px[i]);
+ }
+ }
+}
+
+// ---- directed tests ---------------------------------------------------------------------------
+
+#[test]
+fn opaque_pixels_keep_their_exact_inks() {
+ let mut d = doc(6, 4);
+ d.layers.push(paper(6, 4, [0.0, 0.0, 0.0, 0.0]));
+ // K-only black "type", a rich four-colour patch, then a half-covered patch on top.
+ d.layers.push(layer(&[(Rect::new(0, 0, 3, 4), [0.0, 0.0, 0.0, 1.0, 1.0])]));
+ d.layers.push(layer(&[(Rect::new(3, 0, 6, 2), [0.2, 0.4, 0.6, 0.1, 1.0])]));
+ let got = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported"));
+ let at = |x: i32, y: i32| got.px[(y * 6 + x) as usize];
+ assert_eq!(at(1, 1), [0.0, 0.0, 0.0, 1.0, 1.0], "K stays K-only");
+ assert_eq!(at(4, 1), [q(0.2), q(0.4), q(0.6), q(0.1), 1.0], "every ink kept as stored");
+ assert_eq!(at(4, 3), [0.0, 0.0, 0.0, 0.0, 1.0], "paper: no ink");
+}
+
+#[test]
+fn partial_coverage_mixes_ink_values() {
+ let mut d = doc(2, 1);
+ d.layers.push(paper(2, 1, [0.0, 0.0, 0.0, 0.0]));
+ let mut l = layer(&[(Rect::new(0, 0, 2, 1), [0.0, 0.0, 0.0, 1.0, 1.0])]);
+ l.opacity = 0.5;
+ l.fill_opacity = 0.5;
+ d.layers.push(l);
+ let got = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported"));
+ // 25% coverage of K100 over paper: K25 and no other ink.
+ assert!((got.px[0][3] - 0.25).abs() < 1e-6 && got.px[0][..3] == [0.0; 3], "{:?}", got.px[0]);
+}
+
+#[test]
+fn masks_groups_and_clipping_match_the_reference() {
+ let mut d = doc(8, 6);
+ d.layers.push(paper(8, 6, [0.1, 0.0, 0.0, 0.0]));
+ let mut base = layer(&[(Rect::new(1, 1, 7, 5), [0.0, 0.5, 0.0, 0.0, 0.8])]);
+ base.mask = Some(mask(&[(Rect::new(0, 0, 4, 6), 0.0)], 1.0, 0.75, true));
+ let mut clip = layer(&[(Rect::new(0, 0, 8, 3), [0.0, 0.0, 1.0, 0.2, 1.0])]);
+ clip.clipped = true;
+ clip.opacity = 0.6;
+ let mut iso = Layer::group("iso", vec![layer(&[(Rect::new(2, 0, 5, 6), [0.3, 0.3, 0.3, 0.3, 0.5])])]);
+ iso.blend = BlendMode::Normal;
+ iso.opacity = 0.7;
+ iso.mask = Some(mask(&[(Rect::new(0, 3, 8, 6), 0.25)], 1.0, 1.0, true));
+ let mut pass = Layer::group("pass", vec![layer(&[(Rect::new(5, 2, 8, 6), [1.0, 0.0, 0.0, 0.0, 1.0])])]);
+ pass.opacity = 0.5;
+ pass.mask = Some(mask(&[(Rect::new(6, 0, 8, 6), 0.0)], 1.0, 1.0, true));
+ d.layers.extend([base, clip, iso, pass]);
+ assert_matches_reference(&d);
+}
+
+/// An isolated group in one of the special eight below 100% Fill blends with Fill apart from
+/// opacity, as the compositor blends it (the split route runs the compositor on stand-ins).
+#[test]
+fn isolated_groups_keep_the_special_fill_rule() {
+ for mode in [BlendMode::Difference, BlendMode::LinearBurn, BlendMode::LinearDodge, BlendMode::LinearLight, BlendMode::ColorDodge] {
+ assert!(crate::psblend::fill_is_special(mode), "{mode:?}");
+ let mut d = doc(4, 2);
+ d.layers.push(paper(4, 2, [0.2, 0.5, 0.1, 0.1]));
+ let mut g = Layer::group("iso", vec![layer(&[(Rect::new(0, 0, 3, 2), [0.6, 0.1, 0.4, 0.2, 0.8])])]);
+ g.blend = mode;
+ g.opacity = 0.9;
+ g.fill_opacity = 0.4;
+ d.layers.push(g);
+ assert_matches_reference(&d);
+ assert_routes_agree(&d);
+ }
+}
+
+#[test]
+fn unsupported_documents_fall_back() {
+ let simple = || {
+ let mut d = doc(2, 2);
+ d.layers.push(layer(&[(Rect::new(0, 0, 2, 2), [0.0, 0.0, 0.0, 1.0, 1.0])]));
+ d
+ };
+ assert!(supports(&simple()));
+ let check = |what: &str, f: &dyn Fn(&mut Layer)| {
+ let mut d = simple();
+ let mut l = layer(&[(Rect::new(0, 0, 1, 1), [0.5; 5])]);
+ f(&mut l);
+ d.layers.push(l);
+ assert!(!supports(&d), "{what}");
+ assert!(render_cmyk(&d, d.bounds()).is_none(), "{what}");
+ // An invisible layer doesn't matter.
+ if let Some(l) = d.layers.last_mut() {
+ l.visible = false;
+ }
+ assert!(supports(&d), "hidden {what}");
+ };
+ check("hue", &|l| l.blend = BlendMode::Hue);
+ check("luminosity", &|l| l.blend = BlendMode::Luminosity);
+ check("lighter colour", &|l| l.blend = BlendMode::LighterColor);
+ check("channels", &|l| l.excluded_channels = 1);
+ check("nan opacity", &|l| l.opacity = f32::NAN);
+ // Adjustments that weigh the channels together, or whose records name RGB channels.
+ check("threshold", &|l| l.content = LayerContent::Adjustment(Adjustment::Threshold { level: 0.5 }));
+ check("rgb levels", &|l| l.content = LayerContent::Adjustment(rgb_levels()));
+ check("invert in colour mode", &|l| {
+ l.content = LayerContent::Adjustment(Adjustment::Invert);
+ l.blend = BlendMode::Color;
+ });
+ check("rgb pixels", &|l| l.content = LayerContent::Raster(Surface::new(PixelFormat::RGBA8)));
+ // Not a CMYK document.
+ let mut rgb = simple();
+ rgb.mode = ColorMode::Rgb;
+ assert!(!supports(&rgb));
+ // Too deep: refused without recursing through every level.
+ let mut deep = layer(&[(Rect::new(0, 0, 1, 1), [0.5; 5])]);
+ for _ in 0..(MAX_DEPTH + 8) {
+ deep = Layer::group("g", vec![deep]);
+ }
+ let mut d = simple();
+ d.layers.push(deep);
+ assert!(!supports(&d) && !renders_inks(&d));
+ // Knockouts take the ink-by-ink route through the RGB compositor instead.
+ let mut d = simple();
+ let mut l = layer(&[(Rect::new(0, 0, 1, 1), [0.5; 5])]);
+ l.advanced.knockout = Knockout::Shallow;
+ d.layers.push(l);
+ assert!(!supports(&d) && split::supports(&d));
+ assert!(render_cmyk(&d, d.bounds()).is_some());
+}
+
+#[test]
+fn non_finite_samples_never_reach_the_output() {
+ let fmt = PixelFormat { mode: ColorMode::Cmyk, sample: SampleType::F32, alpha: true };
+ let mut d = Document::new("f", Size::new(4, 1), ColorMode::Cmyk, SampleType::F32);
+ let mut l = Layer::raster("bad", fmt);
+ if let Some(s) = l.surface_mut() {
+ s.write_region(
+ Rect::new(0, 0, 4, 1),
+ &[
+ f32::NAN,
+ 0.0,
+ 0.0,
+ 0.0,
+ 1.0, //
+ 0.0,
+ f32::INFINITY,
+ 0.0,
+ 0.0,
+ 1.0, //
+ 0.0,
+ 0.0,
+ f32::NEG_INFINITY,
+ 0.0,
+ f32::NAN, //
+ 0.5,
+ 0.5,
+ 0.5,
+ 0.5,
+ 0.5,
+ ],
+ );
+ }
+ d.layers.push(l);
+ let got = render_cmyk(&d, Rect::new(-2, -2, 6, 3)).unwrap_or_else(|| panic!("supported"));
+ assert!(got.px.iter().flatten().all(|v| v.is_finite()), "{:?}", got.px);
+}
+
+#[test]
+fn empty_and_off_canvas_rects() {
+ let mut d = doc(4, 4);
+ d.layers.push(layer(&[(Rect::new(0, 0, 4, 4), [0.0, 0.0, 0.0, 1.0, 1.0])]));
+ assert!(render_cmyk(&d, Rect::new(2, 2, 2, 2)).is_some_and(|b| b.px.is_empty()));
+ let far = render_cmyk(&d, Rect::new(1000, 1000, 1003, 1002)).unwrap_or_else(|| panic!("supported"));
+ assert_eq!(far.px, vec![[0.0; 5]; 6]);
+}
+
+#[test]
+fn bands_equal_the_whole_render() {
+ let mut d = doc(300, 700);
+ d.layers.push(paper(300, 700, [0.0, 0.1, 0.0, 0.0]));
+ d.layers.push(layer(&[(Rect::new(10, 20, 290, 690), [0.4, 0.0, 0.2, 0.9, 0.6])]));
+ let whole = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported"));
+ let mut joined = Vec::new();
+ let r = render_cmyk_bands(&d, d.bounds(), 256, |b: CmykBuffer| -> Result<(), ()> {
+ joined.extend(b.px);
+ Ok(())
+ });
+ assert_eq!(r, Some(Ok(())));
+ assert_eq!(joined, whole.px);
+}
+
+// ---- random documents -------------------------------------------------------------------------
+
+#[derive(Debug, Clone)]
+struct Spec {
+ w: i32,
+ h: i32,
+ layers: Vec<LayerSpec>,
+}
+
+#[derive(Debug, Clone)]
+enum LayerSpec {
+ Pixels { kind: Kind, blend: BlendMode, fills: Vec<(Rect, Cmyka)>, opacity: f32, fill: f32, clipped: bool, visible: bool, mask: Option<MaskSpec> },
+ Group { children: Vec<LayerSpec>, pass_through: bool, blend: BlendMode, opacity: f32, fill: f32, mask: Option<MaskSpec> },
+}
+
+/// What kind of layer a [`LayerSpec::Pixels`] becomes: its pixels as a pixel layer, as a type or
+/// shape layer's rendered pixels, or a solid colour fill in the first fill's colour.
+#[derive(Debug, Clone)]
+enum Kind {
+ Raster,
+ Text,
+ Shape,
+ Solid,
+ /// An adjustment layer (its fills are unused).
+ Adjust(AdjSpec),
+}
+
+/// The adjustments this path applies on ink values; `channel` 0..=3 is C, M, Y, K and 4 the
+/// composite record.
+#[derive(Debug, Clone)]
+enum AdjSpec {
+ Invert,
+ Posterize(u32),
+ Levels { channel: usize, levels: [f32; 5] },
+ Curves { channel: usize, points: Vec<(f32, f32)> },
+}
+
+#[derive(Debug, Clone)]
+struct MaskSpec {
+ rects: Vec<(Rect, f32)>,
+ default: f32,
+ density: f32,
+ enabled: bool,
+}
+
+/// Every blend mode this path composites natively, Normal most often.
+fn blend_mode() -> impl Strategy<Value = BlendMode> {
+ prop_oneof![
+ 6 => Just(BlendMode::Normal),
+ 1 => prop::sample::select(SEPARABLE.to_vec()),
+ ]
+}
+
+fn adj_spec() -> impl Strategy<Value = AdjSpec> {
+ prop_oneof![
+ Just(AdjSpec::Invert),
+ (2u32..9).prop_map(AdjSpec::Posterize),
+ (0usize..5, 0.0f32..0.4, 0.6f32..=1.0, 0.3f32..3.0, 0.0f32..0.3, 0.7f32..=1.0)
+ .prop_map(|(channel, ib, iw, g, ob, ow)| AdjSpec::Levels { channel, levels: [ib, iw, g, ob, ow] }),
+ (0usize..5, prop::collection::vec((unit(), unit()), 2..5)).prop_map(|(channel, mut points)| {
+ points.sort_by(|a, b| a.0.total_cmp(&b.0));
+ points.dedup_by(|a, b| (a.0 - b.0).abs() < 0.02);
+ AdjSpec::Curves { channel, points }
+ }),
+ ]
+}
+
+fn make_adjustment(a: &AdjSpec) -> Adjustment {
+ use photocraft_doc::adjust::{CurvePoint, LevelsChannel, ToneSpace};
+ match a {
+ AdjSpec::Invert => Adjustment::Invert,
+ AdjSpec::Posterize(levels) => Adjustment::Posterize { levels: *levels },
+ AdjSpec::Levels { channel, levels: [in_black, in_white, gamma, out_black, out_white] } => {
+ let rec = LevelsChannel { in_black: *in_black, in_white: *in_white, gamma: *gamma, out_black: *out_black, out_white: *out_white };
+ let pick = |c: usize| if c == *channel { rec.clone() } else { LevelsChannel::default() };
+ Adjustment::Levels { master: pick(4), per_channel: [pick(0), pick(1), pick(2)], space: ToneSpace::Cmyk, black: pick(3) }
+ }
+ AdjSpec::Curves { channel, points } => {
+ let curve: Vec<CurvePoint> = points.iter().map(|(input, output)| CurvePoint { input: *input, output: *output }).collect();
+ let pick = |c: usize| if c == *channel { curve.clone() } else { Vec::new() };
+ Adjustment::Curves { master: pick(4), per_channel: [pick(0), pick(1), pick(2)], space: ToneSpace::Cmyk, black: pick(3), pencil: false }
+ }
+ }
+}
+
+fn unit() -> impl Strategy<Value = f32> {
+ prop_oneof![Just(0.0f32), Just(1.0f32), 0.0f32..=1.0]
+}
+
+fn rect(w: i32, h: i32) -> impl Strategy<Value = Rect> {
+ (-1..w, -1..h, 1..w + 2, 1..h + 2).prop_map(|(x, y, rw, rh)| Rect::new(x, y, x + rw, y + rh))
+}
+
+fn mask_spec(w: i32, h: i32) -> impl Strategy<Value = Option<MaskSpec>> {
+ prop::option::of(
+ (prop::collection::vec((rect(w, h), unit()), 0..3), unit(), unit(), any::<bool>()).prop_map(|(rects, default, density, enabled)| MaskSpec {
+ rects,
+ default,
+ density,
+ enabled,
+ }),
+ )
+}
+
+fn pixels(w: i32, h: i32) -> impl Strategy<Value = LayerSpec> {
+ (
+ prop::collection::vec((rect(w, h), (unit(), unit(), unit(), unit(), unit())), 1..4),
+ unit(),
+ unit(),
+ any::<bool>(),
+ prop::bool::weighted(0.9),
+ mask_spec(w, h),
+ prop_oneof![
+ 3 => prop_oneof![Just(Kind::Raster), Just(Kind::Text), Just(Kind::Shape), Just(Kind::Solid)],
+ 1 => adj_spec().prop_map(Kind::Adjust),
+ ],
+ blend_mode(),
+ )
+ .prop_map(|(fills, opacity, fill, clipped, visible, mask, kind, blend)| LayerSpec::Pixels {
+ kind,
+ blend,
+ fills: fills.into_iter().map(|(r, (c, m, y, k, a))| (r, [c, m, y, k, a])).collect(),
+ opacity,
+ fill,
+ clipped,
+ visible,
+ mask,
+ })
+}
+
+fn layer_spec(w: i32, h: i32) -> impl Strategy<Value = LayerSpec> {
+ pixels(w, h).prop_recursive(3, 12, 4, move |inner| {
+ (prop::collection::vec(inner, 1..4), any::<bool>(), unit(), prop_oneof![Just(1.0f32), unit()], mask_spec(w, h), blend_mode())
+ .prop_map(move |(children, pass_through, opacity, fill, mask, blend)| LayerSpec::Group { children, pass_through, blend, opacity, fill, mask })
+ })
+}
+
+fn spec() -> impl Strategy<Value = Spec> {
+ (2i32..9, 2i32..7).prop_flat_map(|(w, h)| prop::collection::vec(layer_spec(w, h), 1..6).prop_map(move |layers| Spec { w, h, layers }))
+}
+
+fn build(s: &LayerSpec) -> Layer {
+ let make_mask = |m: &MaskSpec| mask(&m.rects, m.default, m.density, m.enabled);
+ match s {
+ LayerSpec::Pixels { kind, blend, fills, opacity, fill, clipped, visible, mask } => {
+ let pixels = layer(fills);
+ let mut l = match kind {
+ Kind::Raster => pixels,
+ Kind::Text => Layer::new("t", LayerContent::Text(photocraft_doc::TextLayer { cache: pixels.surface().cloned(), ..Default::default() })),
+ Kind::Shape => Layer::new("s", LayerContent::Shape(photocraft_doc::ShapeLayer { cache: pixels.surface().cloned(), ..Default::default() })),
+ Kind::Solid => {
+ let [c, m, y, k, a] = fills.first().map_or([0.0; 5], |f| f.1);
+ let color = photocraft_color::Color { mode: ColorMode::Cmyk, c: [c, m, y, k], alpha: a };
+ Layer::new("f", LayerContent::Fill(photocraft_doc::Fill::Solid(color)))
+ }
+ Kind::Adjust(a) => Layer::new("a", LayerContent::Adjustment(make_adjustment(a))),
+ };
+ (l.opacity, l.fill_opacity, l.clipped, l.visible) = (*opacity, *fill, *clipped, *visible);
+ l.blend = *blend;
+ l.mask = mask.as_ref().map(make_mask);
+ l
+ }
+ LayerSpec::Group { children, pass_through, blend, opacity, fill, mask } => {
+ let mut g = Layer::group("g", children.iter().map(build).collect());
+ g.blend = if *pass_through { BlendMode::PassThrough } else { *blend };
+ (g.opacity, g.fill_opacity) = (*opacity, *fill);
+ g.mask = mask.as_ref().map(make_mask);
+ g
+ }
+ }
+}
+
+/// Clipped layers onto a pass-through group take the RGB compositor's isolated-rendering path,
+/// which this path leaves alone: such specs are filtered out.
+fn clips_onto_pass_through(layers: &[LayerSpec]) -> bool {
+ layers.windows(2).any(|w| {
+ matches!(w[0], LayerSpec::Group { pass_through: true, fill, .. } if fill >= 1.0)
+ && matches!(w[1], LayerSpec::Pixels { clipped: true, visible: true, .. })
+ }) || layers.iter().any(|l| matches!(l, LayerSpec::Group { children, .. } if clips_onto_pass_through(children)))
+}
+
+proptest! {
+ #![proptest_config(ProptestConfig { cases: 400, ..ProptestConfig::default() })]
+
+ /// Random stacks of pixel layers, masks, isolated and pass-through groups and clipping
+ /// groups: the native composite equals the independent per-pixel reference, and its
+ /// coverage equals the RGB compositor's.
+ #[test]
+ fn random_documents_match_the_reference(s in spec()) {
+ prop_assume!(!clips_onto_pass_through(&s.layers));
+ let mut d = doc(s.w as u32, s.h as u32);
+ d.layers = s.layers.iter().map(build).collect();
+ prop_assume!(supports(&d));
+ assert_matches_reference(&d);
+ }
+
+ /// Tiling never changes the result (tiles render independently, in any order).
+ #[test]
+ fn tiling_is_invisible(s in spec(), tile in 1i32..9) {
+ prop_assume!(!clips_onto_pass_through(&s.layers));
+ let mut d = doc(s.w as u32, s.h as u32);
+ d.layers = s.layers.iter().map(build).collect();
+ prop_assume!(supports(&d));
+ let whole = render_cmyk_tiled(&d, d.bounds(), 1024);
+ prop_assert_eq!(render_cmyk_tiled(&d, d.bounds(), tile), whole);
+ }
+}
+
+/// Where the composite is a single opaque layer's pixel (opaque, full opacity, binary masks),
+/// the native ink, shown through the document's profile, is the colour the RGB compositor shows.
+#[test]
+fn opaque_results_look_the_same_as_the_rgb_compositor() {
+ let mut d = doc(8, 4);
+ d.layers.push(paper(8, 4, [0.0, 0.0, 0.0, 0.0]));
+ d.layers.push(layer(&[(Rect::new(0, 0, 4, 4), [0.0, 0.0, 0.0, 1.0, 1.0]), (Rect::new(4, 0, 8, 2), [0.7, 0.1, 0.0, 0.0, 1.0])]));
+ let mut top = layer(&[(Rect::new(2, 1, 7, 4), [0.0, 0.9, 0.9, 0.0, 1.0])]);
+ top.mask = Some(mask(&[(Rect::new(5, 0, 8, 4), 0.0)], 1.0, 1.0, true));
+ d.layers.push(top);
+ let native = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported"));
+ let rgb = crate::render(&d, d.bounds());
+ let space = crate::cmyk_space(&d);
+ let fmt = PixelFormat { mode: ColorMode::Cmyk, sample: SampleType::F32, alpha: true };
+ photocraft_color::convert::with_cmyk_space(space.as_ref(), || {
+ for (n, r) in native.px.iter().zip(&rgb.px) {
+ let shown = photocraft_raster::to_rgba(&fmt, n);
+ assert!((0..4).all(|c| (shown[c] - r[c]).abs() <= 1e-4), "native {n:?} shows {shown:?}, RGB compositor {r:?}");
+ }
+ });
+}
+
+// ---- stage 2: type, shape, smart object and fill layers ----------------------------------------
+
+fn text_layer(rects: &[(Rect, Cmyka)]) -> Layer {
+ let cache = layer(rects).surface().cloned();
+ Layer::new("t", LayerContent::Text(photocraft_doc::TextLayer { cache, ..Default::default() }))
+}
+
+fn cmyk_color(c: [f32; 4], alpha: f32) -> photocraft_color::Color {
+ photocraft_color::Color { mode: ColorMode::Cmyk, c, alpha }
+}
+
+/// K-only type keeps K-only glyphs: fully covered pixels are exactly K100, and anti-aliased edges
+/// mix on brightness in the type gamma, adding no cyan, magenta or yellow.
+#[test]
+fn type_interiors_are_exact_and_edges_add_no_other_ink() {
+ let mut d = doc(3, 1);
+ d.layers.push(paper(3, 1, [0.0; 4]));
+ d.layers.push(text_layer(&[(Rect::new(0, 0, 1, 1), [0.0, 0.0, 0.0, 1.0, 1.0]), (Rect::new(1, 0, 2, 1), [0.0, 0.0, 0.0, 1.0, 0.5])]));
+ let got = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported"));
+ assert_eq!(got.px[0], [0.0, 0.0, 0.0, 1.0, 1.0], "glyph interior");
+ let edge = got.px[1];
+ assert_eq!(edge[..3], [0.0; 3], "an edge adds no CMY: {edge:?}");
+ let want = over_text([0.0, 0.0, 0.0, 0.0, 1.0], [0.0, 0.0, 0.0, 1.0, q(0.5)], 1.0);
+ assert!((edge[3] - want[3]).abs() < 1e-6, "{edge:?} vs {want:?}");
+ // The gamma lightens dark edges compared with plain mixing.
+ assert!(edge[3] < q(0.5), "{edge:?}");
+ assert_eq!(got.px[2], [0.0, 0.0, 0.0, 0.0, 1.0], "paper");
+}
+
+#[test]
+fn solid_and_rendered_fills_keep_their_inks() {
+ let mut d = doc(4, 1);
+ d.layers.push(paper(4, 1, [0.0; 4]));
+ let mut solid = Layer::new("f", LayerContent::Fill(photocraft_doc::Fill::Solid(cmyk_color([0.1, 0.2, 0.3, 0.4], 1.0))));
+ solid.mask = Some(mask(&[(Rect::new(2, 0, 4, 1), 0.0)], 1.0, 1.0, true));
+ d.layers.push(solid);
+ // A gradient fill carrying the pixels it was rendered to (as a PSD supplies them).
+ let gradient = photocraft_doc::Fill::gradient(
+ vec![(0.0, cmyk_color([1.0, 0.0, 0.0, 0.0], 1.0)), (1.0, cmyk_color([0.0, 0.0, 0.0, 1.0], 1.0))],
+ 0.0,
+ 1.0,
+ Default::default(),
+ false,
+ );
+ let rendered = layer(&[(Rect::new(3, 0, 4, 1), [0.9, 0.0, 0.5, 0.0, 1.0])]);
+ let mut cached = Layer::new("g", LayerContent::Fill(gradient.clone()));
+ cached.fill_cache = rendered.surface().map(|s| photocraft_doc::FillCache { fill: gradient, surface: s.clone() });
+ d.layers.push(cached);
+ let got = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported"));
+ assert_eq!(got.px[0], [q(0.1), q(0.2), q(0.3), q(0.4), 1.0], "the colour's own inks, at the document's levels");
+ assert_eq!(got.px[2], [0.0, 0.0, 0.0, 0.0, 1.0], "masked out: paper");
+ assert_eq!(got.px[3], [q(0.9), 0.0, q(0.5), 0.0, 1.0], "the fill's rendered pixels");
+ assert_matches_reference(&d);
+}
+
+#[test]
+fn stage_two_layers_that_stay_on_the_rgb_compositor() {
+ let base = || {
+ let mut d = doc(2, 2);
+ d.layers.push(paper(2, 2, [0.0; 4]));
+ d
+ };
+ // A pattern fill without rendered pixels.
+ let mut d = base();
+ let p = photocraft_doc::Fill::Pattern { name: "p".into(), scale: 1.0, id: "p".into(), angle: 0.0, link: true, phase: (0.0, 0.0) };
+ d.layers.push(Layer::new("p", LayerContent::Fill(p)));
+ assert!(!supports(&d), "uncached pattern fill");
+ // Type rendered in RGB (not the document's model).
+ let mut d = base();
+ let mut rgb = Layer::raster("x", PixelFormat::RGBA8);
+ if let Some(s) = rgb.surface_mut() {
+ s.fill_rect(Rect::new(0, 0, 1, 1), &[0.0, 0.0, 0.0, 1.0]);
+ }
+ d.layers.push(Layer::new("t", LayerContent::Text(photocraft_doc::TextLayer { cache: rgb.surface().cloned(), ..Default::default() })));
+ assert!(!supports(&d), "RGB type pixels");
+ // A stroked shape with a clipped layer (its stroke goes above the clipped layers).
+ let mut d = base();
+ let shape = photocraft_doc::ShapeLayer { stroke: Some(Default::default()), cache: layer(&[]).surface().cloned(), ..Default::default() };
+ d.layers.push(Layer::new("s", LayerContent::Shape(shape)));
+ let mut clip = layer(&[(Rect::new(0, 0, 2, 2), [0.5; 5])]);
+ clip.clipped = true;
+ d.layers.push(clip);
+ assert!(!supports(&d), "stroked shape with clipped layers");
+ if let Some(c) = d.layers.last_mut() {
+ c.visible = false;
+ }
+ assert!(supports(&d), "without a visible clipped layer the stroked shape is plain pixels");
+}
+
+/// A gradient fill without rendered pixels is the compositor's own CMYK ramp: between cyan and
+/// black it holds only those two inks, pixel for pixel as the compositor renders it.
+#[test]
+fn uncached_gradient_fills_are_cmyk_ramps() {
+ let mut d = doc(8, 2);
+ let g = photocraft_doc::Fill::gradient(
+ vec![(0.0, cmyk_color([1.0, 0.0, 0.0, 0.0], 1.0)), (1.0, cmyk_color([0.0, 0.0, 0.0, 1.0], 1.0))],
+ 0.0,
+ 1.0,
+ Default::default(),
+ false,
+ );
+ d.layers.push(Layer::new("g", LayerContent::Fill(g.clone())));
+ assert!(supports(&d));
+ let got = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported"));
+ let frame = crate::fill_frame(&d.layers[0], d.bounds());
+ let want = crate::gradient_fill::render_cmyk_fill(&g, d.bounds(), frame, SampleType::U8).unwrap_or_else(|| panic!("ramp"));
+ for (i, p) in got.px.iter().enumerate() {
+ let (x, y) = ((i % 8) as i32, (i / 8) as i32);
+ assert_eq!(p[1..3], [0.0, 0.0], "only cyan and black: {p:?}");
+ assert_eq!(p.to_vec(), want.pixel(x, y), "({x},{y})");
+ }
+ assert!(got.px[0][0] > got.px[7][0] && got.px[0][3] < got.px[7][3], "cyan to black");
+}
+
+// ---- stage 3: blend modes on ink values --------------------------------------------------------
+
+const ALL_MODES: [BlendMode; 34] = [
+ BlendMode::PassThrough,
+ BlendMode::Normal,
+ BlendMode::Dissolve,
+ BlendMode::Darken,
+ BlendMode::Multiply,
+ BlendMode::ColorBurn,
+ BlendMode::LinearBurn,
+ BlendMode::DarkerColor,
+ BlendMode::Lighten,
+ BlendMode::Screen,
+ BlendMode::ColorDodge,
+ BlendMode::LinearDodge,
+ BlendMode::LighterColor,
+ BlendMode::Overlay,
+ BlendMode::SoftLight,
+ BlendMode::HardLight,
+ BlendMode::VividLight,
+ BlendMode::LinearLight,
+ BlendMode::PinLight,
+ BlendMode::HardMix,
+ BlendMode::Difference,
+ BlendMode::Exclusion,
+ BlendMode::Subtract,
+ BlendMode::Divide,
+ BlendMode::Hue,
+ BlendMode::Saturation,
+ BlendMode::Color,
+ BlendMode::Luminosity,
+ BlendMode::Reflect,
+ BlendMode::Glow,
+ BlendMode::Negation,
+ BlendMode::Xor,
+ BlendMode::PaintNetColorBurn,
+ BlendMode::PaintNetColorDodge,
+];
+
+/// The modes [`separable`] accepts, besides Normal.
+const SEPARABLE: [BlendMode; 27] = [
+ BlendMode::Dissolve,
+ BlendMode::Darken,
+ BlendMode::Multiply,
+ BlendMode::ColorBurn,
+ BlendMode::LinearBurn,
+ BlendMode::Lighten,
+ BlendMode::Screen,
+ BlendMode::ColorDodge,
+ BlendMode::LinearDodge,
+ BlendMode::Overlay,
+ BlendMode::SoftLight,
+ BlendMode::HardLight,
+ BlendMode::VividLight,
+ BlendMode::LinearLight,
+ BlendMode::PinLight,
+ BlendMode::HardMix,
+ BlendMode::Difference,
+ BlendMode::Exclusion,
+ BlendMode::Subtract,
+ BlendMode::Divide,
+ BlendMode::Reflect,
+ BlendMode::Glow,
+ BlendMode::Negation,
+ BlendMode::Xor,
+ BlendMode::PaintNetColorBurn,
+ BlendMode::PaintNetColorDodge,
+ BlendMode::Normal,
+];
+
+/// Every mode treated as per-channel really is: a channel's result depends only on that
+/// channel's values (checked on many inputs), so applying it to each ink is exact. The modes left
+/// to the RGB compositor really do mix channels.
+#[test]
+fn separable_modes_are_channel_by_channel() {
+ let mut seed = 0x2545_f491_4f6c_dd1du64;
+ let mut r = || {
+ seed ^= seed << 13;
+ seed ^= seed >> 7;
+ seed ^= seed << 17;
+ (seed >> 40) as f32 / (1u64 << 24) as f32
+ };
+ for mode in ALL_MODES {
+ let mut mixes = false;
+ for _ in 0..2000 {
+ let (b, s) = ([r(), r(), r()], [r(), r(), r()]);
+ let (b2, s2) = ([b[0], r(), r()], [s[0], r(), r()]);
+ let (x, y) = (crate::psblend::blend_rgb(mode, b, s)[0], crate::psblend::blend_rgb(mode, b2, s2)[0]);
+ mixes |= (x - y).abs() > 1e-6 || x.is_nan() != y.is_nan();
+ }
+ // Pass Through is a group behaviour (its pixel formula is Normal's); it's checked apart.
+ if mode != BlendMode::PassThrough {
+ assert_eq!(separable(mode), !mixes, "{mode:?}");
+ }
+ assert_eq!(SEPARABLE.contains(&mode), separable(mode), "{mode:?} list");
+ }
+}
+
+/// Opaque layers over opaque paper in common modes give the inks worked out by hand.
+#[test]
+fn blend_modes_give_the_expected_inks() {
+ type Ink = fn(f32, f32) -> f32;
+ let cases: [(BlendMode, Ink); 7] = [
+ (BlendMode::Multiply, |b, s| b + s - b * s), // darker: inks add up
+ (BlendMode::Screen, |b, s| b * s), // lighter: inks thin out
+ (BlendMode::Darken, f32::max),
+ (BlendMode::Lighten, f32::min),
+ (BlendMode::Difference, |b, s| 1.0 - (b - s).abs()),
+ (BlendMode::LinearBurn, |b, s| (b + s).min(1.0)),
+ (BlendMode::LinearDodge, |b, s| (b + s - 1.0).max(0.0)),
+ ];
+ let inks = [0.0, 0.2, 0.5, 0.8, 1.0];
+ for (mode, want) in cases {
+ for (bi, si) in inks.iter().flat_map(|b| inks.iter().map(move |s| (*b, *s))) {
+ let mut d = doc(1, 1);
+ d.layers.push(paper(1, 1, [bi, 0.0, bi, si]));
+ let mut l = layer(&[(Rect::new(0, 0, 1, 1), [si, si, 0.0, bi, 1.0])]);
+ l.blend = mode;
+ d.layers.push(l);
+ let got = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported"))[0];
+ let (b, s) = (q(bi), q(si));
+ let exp = [want(b, s), want(0.0, s), want(b, 0.0), want(s, b), 1.0];
+ assert!(got.iter().zip(exp).all(|(g, e)| (g - e).abs() < 1e-5), "{mode:?} b={b} s={s}: {got:?} vs {exp:?}");
+ }
+ }
+}
+
+impl std::ops::Index<usize> for CmykBuffer {
+ type Output = Cmyka;
+ fn index(&self, i: usize) -> &Cmyka {
+ &self.px[i]
+ }
+}
+
+/// Dissolve shows a pixel fully or not at all, with the RGB compositor's noise: coverage is
+/// either the layer's full ink or untouched paper, and agrees pixel for pixel with the RGB one.
+#[test]
+fn dissolve_matches_the_rgb_compositors_pixels() {
+ let mut d = doc(16, 16);
+ d.layers.push(paper(16, 16, [0.0; 4]));
+ let mut l = layer(&[(Rect::new(0, 0, 16, 16), [0.0, 0.0, 0.0, 1.0, 0.4])]);
+ l.blend = BlendMode::Dissolve;
+ d.layers.push(l);
+ let got = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported"));
+ let rgb = crate::render(&d, d.bounds());
+ let mut shown = 0;
+ for (c, r) in got.px.iter().zip(&rgb.px) {
+ assert!(*c == [0.0, 0.0, 0.0, 1.0, 1.0] || *c == [0.0, 0.0, 0.0, 0.0, 1.0], "{c:?}");
+ // Paper is white on screen; a shown pixel is the K100's dark colour.
+ assert_eq!(c[3] == 1.0, r[0] < 0.5, "{c:?} vs {r:?}");
+ shown += usize::from(c[3] == 1.0);
+ }
+ assert!((60..150).contains(&shown), "about 40% of 256 shown: {shown}");
+}
+
+/// Photoshop's special eight: Fill below 100% is part of the blend, not coverage. Difference at
+/// 50% Fill subtracts half the source's brightness, where 50% coverage would mix the full
+/// difference in by half (the RGB compositor does the same per channel). An ink neither side
+/// has comes out at 50%: the half-pulled source differs from the paper by half.
+#[test]
+fn fill_is_part_of_the_blend_for_the_special_eight() {
+ let mut d = doc(1, 1);
+ d.layers.push(paper(1, 1, [0.7, 0.0, 0.0, 0.0]));
+ let mut l = layer(&[(Rect::new(0, 0, 1, 1), [0.1, 0.0, 0.0, 0.0, 1.0])]);
+ l.blend = BlendMode::Difference;
+ l.fill_opacity = 0.5;
+ d.layers.push(l);
+ let got = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported"))[0];
+ let inside = |bi: f32, si: f32| 1.0 - ((1.0 - bi) - 0.5 * (1.0 - si)).abs();
+ let want = [inside(q(0.7), q(0.1)), inside(0.0, 0.0), inside(0.0, 0.0), inside(0.0, 0.0), 1.0];
+ assert!(got.iter().zip(want).all(|(g, w)| (g - w).abs() < 1e-5), "{got:?} vs {want:?}");
+ let (b, s) = (1.0 - q(0.7), 1.0 - q(0.1));
+ let as_coverage = 1.0 - (0.5 * b + 0.5 * (b - s).abs());
+ assert!((want[0] - as_coverage).abs() > 0.2, "the two readings differ");
+}
+
+// ---- stage 4: adjustment layers on ink values --------------------------------------------------
+
+fn rgb_levels() -> Adjustment {
+ use photocraft_doc::adjust::{LevelsChannel, ToneSpace};
+ let d = LevelsChannel::default;
+ Adjustment::Levels { master: LevelsChannel { in_white: 0.5, ..d() }, per_channel: [d(), d(), d()], space: ToneSpace::Rgb, black: d() }
+}
+
+fn cmyk_levels(master: photocraft_doc::adjust::LevelsChannel, black: photocraft_doc::adjust::LevelsChannel) -> Adjustment {
+ use photocraft_doc::adjust::{LevelsChannel, ToneSpace};
+ let d = LevelsChannel::default;
+ Adjustment::Levels { master, per_channel: [d(), d(), d()], space: ToneSpace::Cmyk, black }
+}
+
+fn adjustment(a: Adjustment) -> Layer {
+ Layer::new("a", LayerContent::Adjustment(a))
+}
+
+fn render1(d: &Document, x: i32, y: i32) -> Cmyka {
+ let got = render_cmyk(d, d.bounds()).unwrap_or_else(|| panic!("supported"));
+ got.px[(y * d.size.width as i32 + x) as usize]
+}
+
+fn near(a: Cmyka, b: Cmyka, tol: f32) -> bool {
+ a.iter().zip(b).all(|(x, y)| (x - y).abs() <= tol)
+}
+
+/// Invert turns every ink into its opposite, black included (blank paper becomes four-colour
+/// black); Posterize steps each ink on its own.
+#[test]
+fn invert_and_posterize_work_ink_by_ink() {
+ let mut d = doc(2, 1);
+ d.layers.push(paper(2, 1, [0.0; 4]));
+ d.layers.push(layer(&[(Rect::new(1, 0, 2, 1), [0.0, 0.0, 0.0, 1.0, 1.0])]));
+ d.layers.push(adjustment(Adjustment::Invert));
+ assert_eq!(render1(&d, 0, 0), [1.0, 1.0, 1.0, 1.0, 1.0], "paper");
+ assert_eq!(render1(&d, 1, 0), [1.0, 1.0, 1.0, 0.0, 1.0], "K-only black");
+ let mut d = doc(1, 1);
+ d.layers.push(paper(1, 1, [0.2, 0.45, 0.7, 0.9]));
+ d.layers.push(adjustment(Adjustment::Posterize { levels: 2 }));
+ // Two levels: brightness below half goes dark (full ink), above half light (no ink).
+ assert_eq!(render1(&d, 0, 0), [0.0, 0.0, 1.0, 1.0, 1.0]);
+}
+
+/// Levels' composite record changes every ink, the black record only K; channels a record
+/// leaves alone keep their exact inks.
+#[test]
+fn levels_records_address_their_inks() {
+ use photocraft_doc::adjust::LevelsChannel;
+ let d0 = LevelsChannel::default;
+ // Composite: input white at 50% doubles each ink's brightness.
+ let mut d = doc(1, 1);
+ d.layers.push(paper(1, 1, [0.2, 0.4, 0.6, 0.1]));
+ d.layers.push(adjustment(cmyk_levels(LevelsChannel { in_white: 0.5, ..d0() }, d0())));
+ assert!(near(render1(&d, 0, 0), [0.0, 0.0, 0.2, 0.0, 1.0], 1.0 / 255.0), "{:?}", render1(&d, 0, 0));
+ // Black: output white at 50% leaves at least half K, and no other ink.
+ let mut d = doc(2, 1);
+ d.layers.push(paper(2, 1, [0.0; 4]));
+ d.layers.push(layer(&[(Rect::new(1, 0, 2, 1), [0.4, 0.0, 0.0, 0.0, 1.0])]));
+ d.layers.push(adjustment(cmyk_levels(d0(), LevelsChannel { out_white: 0.5, ..d0() })));
+ let (blank, cyan) = (render1(&d, 0, 0), render1(&d, 1, 0));
+ assert_eq!(&blank[..3], &[0.0; 3], "{blank:?}");
+ assert!((blank[3] - 0.5).abs() <= 1.0 / 255.0, "{blank:?}");
+ assert_eq!(cyan[0], q(0.4), "cyan untouched: {cyan:?}");
+}
+
+/// Opacity, masks, blend modes, clipping onto adjustments and adjustments clipped onto a layer,
+/// inside isolated and pass-through groups, against the reference.
+#[test]
+fn adjustment_stacks_match_the_reference() {
+ use photocraft_doc::adjust::LevelsChannel;
+ let d0 = LevelsChannel::default;
+ let mut d = doc(8, 6);
+ d.layers.push(paper(8, 6, [0.05, 0.1, 0.0, 0.0]));
+ d.layers.push(layer(&[(Rect::new(0, 0, 5, 6), [0.0, 0.0, 0.0, 1.0, 1.0]), (Rect::new(5, 0, 8, 3), [0.6, 0.2, 0.1, 0.3, 0.7])]));
+ let mut inv = adjustment(Adjustment::Invert);
+ inv.opacity = 0.4;
+ inv.mask = Some(mask(&[(Rect::new(0, 0, 3, 6), 0.0)], 1.0, 0.8, true));
+ let mut onto = layer(&[(Rect::new(2, 2, 8, 6), [0.0, 0.7, 0.0, 0.0, 1.0])]);
+ onto.clipped = true;
+ onto.blend = BlendMode::Multiply;
+ let mut base = layer(&[(Rect::new(1, 1, 7, 5), [0.1, 0.1, 0.5, 0.0, 0.9])]);
+ base.blend = BlendMode::Screen;
+ let mut lv = adjustment(cmyk_levels(LevelsChannel { gamma: 1.8, ..d0() }, LevelsChannel { in_black: 0.2, ..d0() }));
+ lv.clipped = true;
+ lv.blend = BlendMode::Overlay;
+ let mut pass = Layer::group("pass", vec![adjustment(Adjustment::Posterize { levels: 4 })]);
+ pass.opacity = 0.6;
+ let mut iso = Layer::group("iso", vec![layer(&[(Rect::new(0, 3, 8, 6), [0.5, 0.0, 0.5, 0.0, 0.5])]), adjustment(Adjustment::Invert)]);
+ iso.blend = BlendMode::Normal;
+ d.layers.extend([inv, onto, base, lv, pass, iso]);
+ assert_matches_reference(&d);
+ // The black record and the rest go the same way through the stand-ins.
+ assert_routes_agree(&d);
+}
+
+/// In a 32-bit document (no rounding to levels), inks an adjustment leaves alone come out
+/// bit for bit, at full strength and through blend modes that pick an input.
+#[test]
+fn untouched_inks_stay_bit_exact() {
+ use photocraft_doc::adjust::LevelsChannel;
+ let d0 = LevelsChannel::default;
+ let fmt = PixelFormat { mode: ColorMode::Cmyk, sample: SampleType::F32, alpha: false };
+ let inks = [0.123_456_7, 0.456_789_1, 0.789_123_4, 0.0];
+ for blend in [BlendMode::Normal, BlendMode::Darken, BlendMode::Lighten] {
+ let mut d = Document::new("f", Size::new(1, 1), ColorMode::Cmyk, SampleType::F32);
+ let mut bg = Layer::raster("bg", fmt);
+ if let Some(s) = bg.surface_mut() {
+ s.fill_rect(Rect::new(0, 0, 1, 1), &inks);
+ }
+ d.layers.push(bg);
+ let mut a = adjustment(cmyk_levels(d0(), LevelsChannel { out_white: 0.5, ..d0() }));
+ a.blend = blend;
+ d.layers.push(a);
+ let got = render1(&d, 0, 0);
+ assert_eq!(&got[..3], &inks[..3], "{blend:?}");
+ let want_k = if blend == BlendMode::Lighten { 0.0 } else { 0.5 };
+ assert!((got[3] - want_k).abs() < 1e-6, "{blend:?}: {got:?}");
+ }
+}
+
+// ---- stage 4: layer effects, ink by ink through the RGB compositor -----------------------------
+
+use photocraft_doc::effects::{
+ Bevel, BevelStyle, BevelTechnique, Contour, Effect, FxCommon, FxPaint, Glow, GlowSource, GlowTechnique, Gradient, Satin, Shadow, StrokeFx, StrokePosition,
+};
+
+fn ink_color(c: [f32; 4]) -> photocraft_color::Color {
+ photocraft_color::Color { mode: ColorMode::Cmyk, c, alpha: 1.0 }
+}
+
+/// `d` over its canvas grown by a pixel, through the split route in 3-pixel tiles.
+fn split_render(d: &Document) -> CmykBuffer {
+ let rect = Rect::new(-1, -1, d.size.width as i32 + 1, d.size.height as i32 + 1);
+ let mut out = CmykBuffer::transparent(rect);
+ let r = split::render_bands(d, rect, 0, 3, |b| {
+ super::place(&mut out, &b);
+ Ok::<(), ()>(())
+ });
+ assert!(r.is_ok());
+ out
+}
+
+#[derive(Debug, Clone)]
+enum FxSpec {
+ Shadow { inner: bool, color: [f32; 4], blend: BlendMode, opacity: f32, distance: f32, size: f32, spread: f32, knocks_out: bool },
+ Glow { inner: bool, color: [f32; 4], gradient: Option<[f32; 4]>, blend: BlendMode, opacity: f32, size: f32 },
+ Stroke { color: [f32; 4], gradient: Option<[f32; 4]>, position: u8, size: f32, blend: BlendMode, opacity: f32 },
+ Overlay { color: [f32; 4], blend: BlendMode, opacity: f32 },
+ GradientOverlay { from: [f32; 4], to: [f32; 4], blend: BlendMode, opacity: f32 },
+ Satin { color: [f32; 4], blend: BlendMode, opacity: f32, invert: bool },
+ Bevel { style: u8, size: f32, up: bool, highlight: [f32; 4], shadow: [f32; 4] },
+}
+
+fn inks4() -> impl Strategy<Value = [f32; 4]> {
+ (unit(), unit(), unit(), unit()).prop_map(|(c, m, y, k)| [c, m, y, k])
+}
+
+fn fx_spec() -> impl Strategy<Value = FxSpec> {
+ prop_oneof![
+ (any::<bool>(), inks4(), blend_mode(), unit(), 0.0f32..3.0, 0.0f32..3.0, unit(), any::<bool>()).prop_map(
+ |(inner, color, blend, opacity, distance, size, spread, knocks_out)| FxSpec::Shadow {
+ inner,
+ color,
+ blend,
+ opacity,
+ distance,
+ size,
+ spread,
+ knocks_out
+ }
+ ),
+ (any::<bool>(), inks4(), prop::option::of(inks4()), blend_mode(), unit(), 0.0f32..3.0)
+ .prop_map(|(inner, color, gradient, blend, opacity, size)| FxSpec::Glow { inner, color, gradient, blend, opacity, size }),
+ (inks4(), prop::option::of(inks4()), 0u8..3, 1.0f32..3.0, blend_mode(), unit())
+ .prop_map(|(color, gradient, position, size, blend, opacity)| FxSpec::Stroke { color, gradient, position, size, blend, opacity }),
+ (inks4(), blend_mode(), unit()).prop_map(|(color, blend, opacity)| FxSpec::Overlay { color, blend, opacity }),
+ (inks4(), inks4(), blend_mode(), unit()).prop_map(|(from, to, blend, opacity)| FxSpec::GradientOverlay { from, to, blend, opacity }),
+ (inks4(), blend_mode(), unit(), any::<bool>()).prop_map(|(color, blend, opacity, invert)| FxSpec::Satin { color, blend, opacity, invert }),
+ (0u8..5, 1.0f32..3.0, any::<bool>(), inks4(), inks4()).prop_map(|(style, size, up, highlight, shadow)| FxSpec::Bevel {
+ style,
+ size,
+ up,
+ highlight,
+ shadow
+ }),
+ ]
+}
+
+fn make_effect(f: &FxSpec) -> Effect {
+ let paint = |c: &[f32; 4], g: &Option<[f32; 4]>| match g {
+ Some(to) => FxPaint::Gradient(Gradient { stops: vec![(0.0, ink_color(*c)), (1.0, ink_color(*to))], ..Default::default() }),
+ None => FxPaint::Color(ink_color(*c)),
+ };
+ match f {
+ FxSpec::Shadow { inner, color, blend, opacity, distance, size, spread, knocks_out } => {
+ let s = Shadow {
+ common: FxCommon::new(*blend, *opacity),
+ color: ink_color(*color),
+ angle: 120.0,
+ use_global_light: false,
+ distance: *distance,
+ spread: *spread,
+ size: *size,
+ contour: Contour::Linear,
+ anti_alias: false,
+ noise: 0.0,
+ knocks_out: *knocks_out,
+ };
+ if *inner { Effect::InnerShadow(s) } else { Effect::DropShadow(s) }
+ }
+ FxSpec::Glow { inner, color, gradient, blend, opacity, size } => {
+ let g = Glow {
+ common: FxCommon::new(*blend, *opacity),
+ paint: paint(color, gradient),
+ technique: GlowTechnique::Softer,
+ spread: 0.0,
+ size: *size,
+ contour: Contour::Linear,
+ anti_alias: false,
+ range: 0.5,
+ jitter: 0.0,
+ noise: 0.0,
+ source: GlowSource::Edge,
+ };
+ if *inner { Effect::InnerGlow(g) } else { Effect::OuterGlow(g) }
+ }
+ FxSpec::Stroke { color, gradient, position, size, blend, opacity } => Effect::Stroke(StrokeFx {
+ common: FxCommon::new(*blend, *opacity),
+ size: *size,
+ position: [StrokePosition::Outside, StrokePosition::Inside, StrokePosition::Center][usize::from(*position) % 3],
+ paint: paint(color, gradient),
++ overprint: false,
+ }),
+ FxSpec::Overlay { color, blend, opacity } => Effect::ColorOverlay { common: FxCommon::new(*blend, *opacity), color: ink_color(*color) },
+ FxSpec::GradientOverlay { from, to, blend, opacity } => Effect::GradientOverlay {
+ common: FxCommon::new(*blend, *opacity),
+ gradient: Gradient { stops: vec![(0.0, ink_color(*from)), (1.0, ink_color(*to))], ..Default::default() },
+ dither: false,
+ },
+ FxSpec::Satin { color, blend, opacity, invert } => Effect::Satin(Satin {
+ common: FxCommon::new(*blend, *opacity),
+ color: ink_color(*color),
+ angle: 19.0,
+ distance: 2.0,
+ size: 2.0,
+ contour: Contour::Linear,
+ anti_alias: false,
+ invert: *invert,
+ }),
+ FxSpec::Bevel { style, size, up, highlight, shadow } => Effect::BevelEmboss(Bevel {
+ enabled: true,
+ style: [BevelStyle::OuterBevel, BevelStyle::InnerBevel, BevelStyle::Emboss, BevelStyle::PillowEmboss, BevelStyle::StrokeEmboss]
+ [usize::from(*style) % 5],
+ technique: BevelTechnique::Smooth,
+ depth: 1.0,
+ up: *up,
+ size: *size,
+ soften: 0.0,
+ angle: 120.0,
+ altitude: 30.0,
+ use_global_light: false,
+ gloss_contour: Contour::Linear,
++ gloss_anti_alias: false,
+ highlight: FxCommon::new(BlendMode::Screen, 0.75),
+ highlight_color: ink_color(*highlight),
+ shadow: FxCommon::new(BlendMode::Multiply, 0.75),
+ shadow_color: ink_color(*shadow),
+ contour: None,
+ texture: None,
+ }),
+ }
+}
+
+/// A random document with effects on some of its layers (and a knockout now and then).
+fn with_effects(s: &Spec, fx: &[(usize, FxSpec)], knockout: Option<usize>) -> Document {
+ let mut d = doc(s.w as u32, s.h as u32);
+ d.layers = s.layers.iter().map(build).collect();
+ let n = d.layers.len().max(1);
+ for (i, f) in fx {
+ // Adjustment layers don't carry effects (see `split::supports`).
+ if let Some(l) = d.layers.get_mut(i % n).filter(|l| !matches!(l.content, LayerContent::Adjustment(_))) {
+ l.effects.enabled = true;
+ l.effects.items.push(make_effect(f));
+ }
+ }
+ if let Some(l) = knockout.and_then(|i| d.layers.get_mut(i % n)) {
+ l.advanced.knockout = Knockout::Shallow;
+ }
+ d
+}
+
+proptest! {
+ #![proptest_config(ProptestConfig { cases: 120, ..ProptestConfig::default() })]
+
+ /// On every stack the exact path handles, the split route gives the same inks.
+ #[test]
+ fn the_split_route_agrees_with_the_exact_path(s in spec()) {
+ prop_assume!(!clips_onto_pass_through(&s.layers));
+ let mut d = doc(s.w as u32, s.h as u32);
+ d.layers = s.layers.iter().map(build).collect();
+ prop_assume!(supports(&d) && split::supports(&d));
+ // Both are exact up to float rounding, which a mode that jumps can magnify (see [`jumps`]).
+ prop_assume!(!any_layer(&d.layers, &|l| jumps(l.blend)));
+ let via = split_render(&d);
+ let exact = render_cmyk(&d, via.rect).unwrap_or_else(|| panic!("supported"));
+ for (i, (g, w)) in via.px.iter().zip(&exact.px).enumerate() {
+ prop_assert!((g[4] - w[4]).abs() <= 1e-5, "alpha {i}: {g:?} vs {w:?}");
+ if w[4] > 1e-4 {
+ prop_assert!((0..4).all(|c| (g[c] - w[c]).abs() <= 1e-5), "ink {i}: {g:?} vs {w:?}");
+ }
+ }
+ }
+
+ /// The RGB compositor treats every channel on its own for everything the split route
+ /// allows, effects included: which ink feeds which channel doesn't change any ink's result
+ /// (nor coverage). That is what makes running it on inks' brightness exact.
+ #[test]
+ fn effects_work_channel_by_channel(
+ s in spec(),
+ fx in prop::collection::vec((0usize..8, fx_spec()), 1..4),
+ knockout in prop::option::of(0usize..8),
+ ) {
+ let d = with_effects(&s, &fx, knockout);
+ prop_assume!(split::supports(&d));
+ let rect = Rect::new(-2, -2, s.w + 2, s.h + 2);
+ let cmy = split::render_planes(&d, rect, [0, 1, 2]);
+ let rot = split::render_planes(&d, rect, [1, 2, 0]);
+ let k = split::render_planes(&d, rect, [3, 3, 3]);
+ let mix = split::render_planes(&d, rect, [3, 0, 3]);
+ let same = |a: f32, b: f32| (a - b).abs() <= 1e-6 || (a.is_nan() && b.is_nan());
+ for i in 0..cmy.px.len() {
+ let (p, r, q, m) = (cmy.px[i], rot.px[i], k.px[i], mix.px[i]);
+ prop_assert!(same(p[3], r[3]) && same(p[3], q[3]) && same(p[3], m[3]), "coverage {i}: {p:?} {r:?} {q:?} {m:?}");
+ prop_assert!(same(r[0], p[1]) && same(r[1], p[2]) && same(r[2], p[0]), "rotated {i}: {p:?} vs {r:?}");
+ prop_assert!(same(q[0], q[1]) && same(q[1], q[2]), "black {i}: {q:?}");
+ prop_assert!(same(m[0], q[0]) && same(m[1], p[0]) && same(m[2], q[0]), "mixed {i}: {m:?} vs {p:?} / {q:?}");
+ }
+ }
+
+ /// Effects don't depend on the tiling or banding (beyond the RGB compositor's own float
+ /// rounding, which can differ by an ulp between tilings).
+ #[test]
+ fn split_tiling_is_invisible(s in spec(), fx in prop::collection::vec((0usize..8, fx_spec()), 1..3), tile in 1i32..9) {
+ let d = with_effects(&s, &fx, None);
+ prop_assume!(split::supports(&d));
+ let whole = render_cmyk_tiled(&d, d.bounds(), 1024).unwrap_or_else(|| panic!("supported"));
+ let tiled = render_cmyk_tiled(&d, d.bounds(), tile).unwrap_or_else(|| panic!("supported"));
+ for (p, q) in tiled.px.iter().zip(&whole.px) {
+ prop_assert!(p.iter().zip(q).all(|(a, b)| (a - b).abs() <= 1e-6), "{p:?} vs {q:?}");
+ }
+ }
+}
+
+/// A K-only drop shadow under K-only type on blank paper puts down black ink only.
+#[test]
+fn k_only_shadows_stay_k_only() {
+ let mut d = doc(12, 8);
+ d.layers.push(paper(12, 8, [0.0; 4]));
+ let mut t = layer(&[(Rect::new(2, 2, 6, 5), [0.0, 0.0, 0.0, 1.0, 1.0])]);
+ t.effects.enabled = true;
+ t.effects.items.push(Effect::DropShadow(Shadow {
+ common: FxCommon::new(BlendMode::Multiply, 0.75),
+ color: ink_color([0.0, 0.0, 0.0, 1.0]),
+ angle: 135.0,
+ use_global_light: false,
+ distance: 2.0,
+ spread: 0.0,
+ size: 0.0,
+ contour: Contour::Linear,
+ anti_alias: false,
+ noise: 0.0,
+ knocks_out: true,
+ }));
+ d.layers.push(t);
+ assert!(!supports(&d) && split::supports(&d));
+ let got = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported"));
+ assert!(got.px.iter().all(|p| p[..3].iter().all(|v| *v <= 1e-6)), "no C, M or Y anywhere");
+ // Light from the upper left: the shadow falls a pixel down and to the right of the type.
+ let at = |x: i32, y: i32| got.px[(y * 12 + x) as usize];
+ assert!((at(6, 5)[3] - 0.75).abs() < 1e-5, "shadow: {:?}", at(6, 5));
+ assert!((at(3, 3)[3] - 1.0).abs() < 1e-6, "type: {:?}", at(3, 3));
+ assert!(at(10, 1)[3] <= 1e-6, "paper: {:?}", at(10, 1));
+}
+
+/// A colour overlay paints the layer in exactly its inks; an outside stroke in its own.
+#[test]
+fn overlays_and_strokes_paint_exact_inks() {
+ let mut d = doc(10, 8);
+ d.layers.push(paper(10, 8, [0.0; 4]));
+ let mut l = layer(&[(Rect::new(3, 3, 7, 6), [0.0, 0.0, 0.0, 1.0, 1.0])]);
+ l.effects.enabled = true;
+ l.effects.items.push(Effect::ColorOverlay { common: FxCommon::new(BlendMode::Normal, 1.0), color: ink_color([0.2, 0.4, 0.6, 0.1]) });
+ l.effects.items.push(Effect::Stroke(StrokeFx {
+ common: FxCommon::new(BlendMode::Normal, 1.0),
+ size: 1.0,
+ position: StrokePosition::Outside,
+ paint: FxPaint::Color(ink_color([0.0, 1.0, 0.0, 0.0])),
++ overprint: false,
+ }));
+ d.layers.push(l);
+ let got = render_cmyk(&d, d.bounds()).unwrap_or_else(|| panic!("supported"));
+ let at = |x: i32, y: i32| got.px[(y * 10 + x) as usize];
+ let near = |a: Cmyka, b: Cmyka| a.iter().zip(b).all(|(x, y)| (x - y).abs() <= 1e-6);
+ assert!(near(at(4, 4), [0.2, 0.4, 0.6, 0.1, 1.0]), "overlay: {:?}", at(4, 4));
+ assert!(near(at(2, 4), [0.0, 1.0, 0.0, 0.0, 1.0]), "stroke: {:?}", at(2, 4));
+ assert!(near(at(0, 0), [0.0, 0.0, 0.0, 0.0, 1.0]), "paper: {:?}", at(0, 0));
+}
+
+/// Pattern paints and channel-mixing effect modes stay on the RGB compositor.
+#[test]
+fn effects_that_mix_channels_fall_back() {
+ let with = |e: Effect| {
+ let mut d = doc(2, 2);
+ let mut l = layer(&[(Rect::new(0, 0, 1, 1), [0.5; 5])]);
+ l.effects.enabled = true;
+ l.effects.items.push(e);
+ d.layers.push(l);
+ d
+ };
+ let overlay = |blend| Effect::ColorOverlay { common: FxCommon::new(blend, 1.0), color: ink_color([0.5; 4]) };
+ assert!(split::supports(&with(overlay(BlendMode::Multiply))));
+ assert!(!renders_inks(&with(overlay(BlendMode::Color))));
+ let pattern = Effect::PatternOverlay {
+ common: FxCommon::new(BlendMode::Normal, 1.0),
+ name: "p".into(),
+ id: "p".into(),
+ scale: 1.0,
+ angle: 0.0,
+ link: true,
+ phase: (0.0, 0.0),
+ };
+ assert!(!renders_inks(&with(pattern)));
+ // Effects on an adjustment layer (it has no pixels of its own to shape them).
+ let mut adj = adjustment(Adjustment::Invert);
+ adj.effects.enabled = true;
+ adj.effects.items.push(overlay(BlendMode::Multiply));
+ let mut d = doc(2, 2);
+ d.layers.push(adj);
+ assert!(!split::supports(&d));
+ // 32-bit CMYK documents too.
+ let mut d = with(overlay(BlendMode::Multiply));
+ d.depth = SampleType::F32;
+ assert!(!split::supports(&d));
+}
+
+/// Found by a long random run: Normal mixing onto nothing must give the source's ink exactly. A
+/// rounding error (1 → 0.99999994) is magnified by modes that jump at full ink, here Reflect
+/// turning no ink into full K.
+#[test]
+fn normal_onto_nothing_is_exact() {
+ let shape = LayerSpec::Pixels {
+ kind: Kind::Shape,
+ blend: BlendMode::Normal,
+ fills: vec![(Rect::new(0, 0, 1, 1), [0.0, 0.0, 0.0, 1.0, 1.0])],
+ opacity: 1.0,
+ fill: 1.0,
+ clipped: false,
+ visible: true,
+ mask: Some(MaskSpec { rects: vec![], default: 0.4949783, density: 1.0, enabled: true }),
+ };
+ let inv = LayerSpec::Pixels {
+ kind: Kind::Adjust(AdjSpec::Invert),
+ blend: BlendMode::Reflect,
+ fills: vec![(Rect::new(0, 0, 1, 1), [0.0; 5])],
+ opacity: 1.0,
+ fill: 1.0,
+ clipped: false,
+ visible: true,
+ mask: None,
+ };
+ let mut d = doc(4, 6);
+ d.layers =
+ vec![build(&LayerSpec::Group { children: vec![shape, inv], pass_through: false, blend: BlendMode::Normal, opacity: 1.0, fill: 1.0, mask: None })];
+ assert_matches_reference(&d);
+ assert_eq!(render1(&d, 0, 0)[..4], [0.0; 4]);
+}
+
+/// Found by a long random run: a transparent pixel with ink of its own counts towards the
+/// layer's bounds, which lay out a gradient overlay; the stand-ins keep it counted whichever ink
+/// they carry.
+#[test]
+fn transparent_inked_pixels_keep_their_bounds() {
+ let inner = LayerSpec::Pixels {
+ kind: Kind::Raster,
+ blend: BlendMode::Normal,
+ fills: vec![(Rect::new(0, -1, 1, 1), [0.0, 0.0, 0.0, 0.0, 1.0]), (Rect::new(0, 1, 1, 2), [0.0, 0.0, 1.0, 0.0, 0.0])],
+ opacity: 1.0,
+ fill: 1.0,
+ clipped: false,
+ visible: true,
+ mask: None,
+ };
+ let g = |children: Vec<LayerSpec>, pass_through: bool| LayerSpec::Group {
+ children,
+ pass_through,
+ blend: BlendMode::Normal,
+ opacity: 1.0,
+ fill: 1.0,
+ mask: None,
+ };
+ let s = Spec { w: 2, h: 2, layers: vec![g(vec![g(vec![g(vec![inner], false)], false)], true)] };
+ let fx = [(0usize, FxSpec::GradientOverlay { from: [1.0, 0.0, 0.0, 0.0], to: [0.0; 4], blend: BlendMode::Normal, opacity: 1.0 })];
+ let d = with_effects(&s, &fx, None);
+ let rect = Rect::new(-2, -2, 4, 4);
+ let cmy = split::render_planes(&d, rect, [0, 1, 2]);
+ for planes in [[3, 0, 3], [0, 0, 0], [0, 3, 3]] {
+ let other = split::render_planes(&d, rect, planes);
+ let at = planes.iter().position(|p| *p == 0).unwrap_or(0);
+ for (p, o) in cmy.px.iter().zip(&other.px) {
+ assert!((p[0] - o[at]).abs() <= 1e-6 && (p[3] - o[3]).abs() <= 1e-6, "{planes:?}: {p:?} vs {o:?}");
+ }
+ }
+}
+
+/// Blend modes that jump (at no ink or full ink): a rounding difference between two exact
+/// computations can land on either side of the jump.
+fn jumps(mode: BlendMode) -> bool {
+ use BlendMode as B;
+ matches!(mode, B::ColorBurn | B::ColorDodge | B::VividLight | B::HardMix | B::Divide | B::Reflect | B::Glow | B::PaintNetColorBurn | B::PaintNetColorDodge)
+}
+
+fn any_layer(layers: &[Layer], f: &dyn Fn(&Layer) -> bool) -> bool {
+ layers.iter().any(|l| f(l) || matches!(&l.content, LayerContent::Group(g) if any_layer(&g.children, f)))
+}
+
+/// The display form of the ink composite: where a single opaque layer's pixel shows, it is the
+/// colour the RGB compositor shows (both read the inks through the document's profile).
+#[test]
+fn display_shows_the_inks_through_the_profile() {
+ let mut d = doc(8, 4);
+ d.layers.push(paper(8, 4, [0.0; 4]));
+ d.layers.push(layer(&[(Rect::new(0, 0, 4, 4), [0.0, 0.0, 0.0, 1.0, 1.0]), (Rect::new(4, 0, 8, 2), [0.7, 0.1, 0.0, 0.3, 1.0])]));
+ let shown = render_display(&d, d.bounds()).unwrap_or_else(|| panic!("supported"));
+ let rgb = crate::render(&d, d.bounds());
+ for (s, r) in shown.px.iter().zip(&rgb.px) {
+ assert!(s.iter().zip(r).all(|(a, b)| (a - b).abs() <= 1e-4), "{s:?} vs {r:?}");
+ }
+ // Unsupported documents have no ink composite to show.
+ let mut lum = layer(&[(Rect::new(0, 0, 1, 1), [0.5; 5])]);
+ lum.blend = BlendMode::Luminosity;
+ d.layers.push(lum);
+ assert!(render_display(&d, d.bounds()).is_none());
+}
+
+/// The split route gives the exact path's inks on `d` (which both handle).
+fn assert_routes_agree(d: &Document) {
+ assert!(supports(d) && split::supports(d));
+ let via = split_render(d);
+ let exact = render_cmyk(d, via.rect).unwrap_or_else(|| panic!("supported"));
+ for (g, w) in via.px.iter().zip(&exact.px) {
+ assert!((g[4] - w[4]).abs() <= 1e-5 && (w[4] <= 1e-4 || (0..4).all(|c| (g[c] - w[c]).abs() <= 1e-5)), "{g:?} vs {w:?}");
+ }
+}
+
+/// Black-only Levels and Curves through the stand-ins: K changes, nothing else does.
+#[test]
+fn black_records_reach_k_through_the_stand_ins() {
+ use photocraft_doc::adjust::{CurvePoint, LevelsChannel, ToneSpace};
+ let d0 = LevelsChannel::default;
+ for adj in [
+ cmyk_levels(d0(), LevelsChannel { out_white: 0.5, ..d0() }),
+ Adjustment::Curves {
+ master: Vec::new(),
+ per_channel: [Vec::new(), Vec::new(), Vec::new()],
+ space: ToneSpace::Cmyk,
+ black: vec![CurvePoint { input: 0.0, output: 0.0 }, CurvePoint { input: 1.0, output: 0.6 }],
+ pencil: false,
+ },
+ ] {
+ let mut d = doc(3, 1);
+ d.layers.push(paper(3, 1, [0.1, 0.2, 0.3, 0.0]));
+ d.layers.push(adjustment(adj));
+ assert_routes_agree(&d);
+ assert!(split_render(&d).px.iter().filter(|p| p[4] > 0.0).all(|p| p[3] > 0.3), "K added");
+ }
+}
+
+/// Effects are laid out over the layer's bounds, which on a layer without transparency the
+/// stand-ins can't keep (its pixels that differ only in other inks would match the default):
+/// such a layer stays on the RGB compositor.
+#[test]
+fn effects_on_opaque_layers_fall_back() {
+ let mut d = doc(4, 4);
+ let mut bg = paper(4, 4, [0.0; 4]);
+ bg.effects.enabled = true;
+ bg.effects.items.push(Effect::ColorOverlay { common: FxCommon::new(BlendMode::Multiply, 0.5), color: ink_color([0.0, 0.0, 0.0, 1.0]) });
+ d.layers.push(bg);
+ assert!(!split::supports(&d) && !renders_inks(&d));
+}
+
+/// Solid and gradient fills without rendered pixels give the same inks on both routes (both
+/// stored at the document's levels, as the compositor renders CMYK fills).
+#[test]
+fn fills_agree_on_both_routes() {
+ let g = photocraft_doc::Fill::gradient(
+ vec![(0.0, cmyk_color([1.0, 0.2, 0.0, 0.0], 1.0)), (1.0, cmyk_color([0.0, 0.0, 0.7, 1.0], 0.6))],
+ 30.0,
+ 1.0,
+ Default::default(),
+ false,
+ );
+ for fill in [g, photocraft_doc::Fill::Solid(cmyk_color([0.13, 0.0, 0.9375, 0.0], 0.55))] {
+ let mut d = doc(9, 5);
+ d.layers.push(paper(9, 5, [0.0, 0.1, 0.0, 0.0]));
+ d.layers.push(Layer::new("f", LayerContent::Fill(fill)));
+ assert_routes_agree(&d);
+ }
+}
+
+/// Flatten Image, Stamp Visible and Copy Merged (all [`crate::flatten_to_surface`]) keep a CMYK
+/// document's inks: K-only black stays K-only instead of turning four-colour.
+#[test]
+fn flattening_keeps_exact_inks() {
+ let mut d = doc(3, 1);
+ d.layers.push(layer(&[
+ (Rect::new(0, 0, 1, 1), [0.0, 0.0, 0.0, 1.0, 1.0]),
+ (Rect::new(1, 0, 2, 1), [0.2, 0.4, 0.6, 0.1, 1.0]),
+ (Rect::new(2, 0, 3, 1), [0.0, 0.0, 0.0, 1.0, 0.4]),
+ ]));
+ // Over white paper (Flatten Image) and kept transparent (Stamp Visible).
+ let flat = crate::flatten_to_surface(&d, CMYK8, Some([1.0; 3]));
+ assert_eq!(flat.pixel(0, 0), vec![0.0, 0.0, 0.0, 1.0]);
+ assert_eq!(flat.pixel(1, 0), vec![q(0.2), q(0.4), q(0.6), q(0.1)]);
+ assert_eq!(flat.pixel(2, 0), vec![0.0, 0.0, 0.0, q(0.4)], "40% K over paper");
+ let stamp = crate::flatten_to_surface(&d, CMYKA8, None);
+ assert_eq!(stamp.pixel(2, 0), vec![0.0, 0.0, 0.0, 1.0, q(0.4)]);
+}
diff --cc crates/engine/src/warp_cmds.rs
index 2a89ce5d5,57d6081c6..2726b26b4
--- a/crates/engine/src/warp_cmds.rs
+++ b/crates/engine/src/warp_cmds.rs
@@@ -124,50 -110,26 +124,67 @@@ pub fn warp_from_params(cmd: &str, p: &
Ok(w)
}
+const CYLINDER_VALUES: &str =
+ "a cylinder needs `values`: seven numbers [left, bottom, right, top, top depth, bottom depth, wrap 0..1], the right silhouette right of the left one";
+const CYLINDER_SHAPE: &str = "a cylinder is horizontal, with no hDistort or vDistort";
+
+/// A document-space cylinder `w` stored on a smart object, whose placement's inverse is `inv` and
+/// whose warp box `w.bounds` lands on `sb` in source space. A placement that only scales and
+/// moves keeps it a cylinder (written to PSD as one): the silhouettes and edges map, and the
+/// ellipses' depth, in units of the half axis, follows the change of aspect. Otherwise (rotated,
+/// skewed, flipped, in perspective) it becomes its mesh, a custom warp.
+fn cylinder_in_source(w: &Warp, inv: &Homography, sb: [f64; 4]) -> Option<Warp> {
+ let m = inv.0;
+ let axis_aligned = m[8] != 0.0 && m[1] == 0.0 && m[3] == 0.0 && m[6] == 0.0 && m[7] == 0.0;
+ let (sx, sy) = (m[0] / m[8], m[4] / m[8]);
+ if axis_aligned && sx > 0.0 && sy > 0.0 && w.values.len() == 7 {
+ let v = &w.values;
+ let (x, y) = (|v: f64| sx * v + m[2] / m[8], |v: f64| sy * v + m[5] / m[8]);
+ let k = sy / sx;
+ if let Some(c) = Warp::cylinder(&[x(v[0]), y(v[1]), x(v[2]), y(v[3]), v[4] * k, v[5] * k, v[6]], sb) {
+ return Some(c);
+ }
+ }
+ let mesh = w.to_mesh(1, 1).map_points(|p| hom_apply(inv, p));
+ Some(Warp::custom(mesh, sb))
+}
+
+/// Whether the custom warp `w` is exactly what Warp mode shows for `layer`'s stored cylinder
+/// ([`smart_warp_doc_space`]: its mesh over the same box), so committing it untouched changes
+/// nothing. Stored as a custom warp instead, the cylinder would be lost, as a PSD keeps it only
+/// as `warpCylinder` (#4112).
+fn is_stored_cylinder(layer: &Layer, w: &Warp) -> bool {
+ let LayerContent::Smart(sm) = &layer.content else { return false };
+ if w.style != WarpStyle::Custom || sm.warp.as_ref().is_none_or(|s| s.style != WarpStyle::Cylinder) {
+ return false;
+ }
+ let (Some(shown), Some(m)) = (smart_warp_doc_space(layer), w.mesh.as_ref()) else { return false };
+ let Some(o) = shown.mesh.as_ref() else { return false };
+ let tol = 1e-6 * (1.0 + o.points.iter().flatten().chain(&shown.bounds).fold(0.0f64, |a, v| a.max(v.abs())));
+ let near = |a: &[f64], b: &[f64]| a.len() == b.len() && a.iter().zip(b).all(|(x, y)| (x - y).abs() <= tol);
+ o.us == m.us && o.vs == m.vs && near(&shown.bounds, &w.bounds) && near(o.points.as_flattened(), m.points.as_flattened())
+}
+
/// A Background is turned into a normal layer by the caller first
/// ([`crate::extra_cmds::background_to_layer`]).
- fn warp_layer(doc_sel: Option<&Surface>, group: Locks, l: &mut Layer, w: &Warp, rect: Rect, interp: Interp, frames: Option<&Frames>) -> Result<()> {
+ /// `Err(Cancelled)` once `ctl` is cancelled: between the steps of a warp that don't check it.
+ fn cancelled(ctl: &Interrupt) -> Result<()> {
+ if ctl.cancelled() { Err(EngineError::Cancelled) } else { Ok(()) }
+ }
+
+ /// `ctl` reports progress and cancels (`Err(Cancelled)`, the layer left half-done for the caller
+ /// to discard).
+ #[allow(clippy::too_many_arguments)]
+ fn warp_layer(
+ doc_sel: Option<&Surface>,
+ group: Locks,
+ l: &mut Layer,
+ w: &Warp,
+ rect: Rect,
+ interp: Interp,
+ frames: Option<&Frames>,
+ ctl: &Interrupt,
+ ) -> Result<()> {
let locks = l.locks.union(group);
if locks.position || locks.all {
return Err(EngineError::Other(format!("layer \"{}\" is locked", l.name)));
@@@ -405,36 -379,41 +436,45 @@@ fn apply(s: &mut Session, p: &Value, cm
if w.is_identity() && !is_smart {
return Ok(json!({"layer": id.0, "changed": false}));
}
+ // An untouched cylinder (Warp mode, then Enter) stays as it is, with no history step.
+ if p.get("mesh").is_none() && s.active().and_then(|d| d.doc.layer(id)).is_some_and(|l| is_stored_cylinder(l, &w)) {
+ return Ok(json!({"layer": id.0, "changed": false}));
+ }
let interp = Interp::parse(p.get("interpolation").and_then(Value::as_str).unwrap_or("bicubic"));
let content_knots = p.get("mesh").is_some() && p.get("warp").is_none();
- s.edit("Warp", |doc, _| {
- let sel = doc.selection.clone();
- let frames = content_knots.then(|| {
- let mut f = Frames::new();
- if let Some(l) = doc.layer(id) {
- source_frames(doc, l, &mut f);
- }
- f
- });
- let is_group = doc.layer(id).is_some_and(Layer::is_group);
- let group = crate::transform_cmds::group_locks(doc, id);
- crate::extra_cmds::background_to_layer(doc, id);
- let l = doc.layer_mut(id).ok_or(EngineError::NoLayer(id))?;
- warp_layer(if is_group { None } else { sel.as_ref() }, group, l, &w, rect, interp, frames.as_ref())?;
- let snapshot = doc.clone();
- if let Some(l) = doc.layer_mut(id) {
- crate::transform_cmds::refresh_text(&snapshot, l);
- }
- if let Some(sel) = &doc.selection {
- doc.selection = Some(warp_mesh_gray(sel, &|x, y| w.map(x, y), Interp::Bilinear)).filter(|s| !s.content_bounds().is_empty());
+ // A background job when started with `Session::start` (as Free Transform, #4218): the warp of
+ // a large layer runs on a worker with progress, and can be cancelled.
+ crate::jobs::edit_job(
+ s,
+ "Warp",
+ move |doc, _, ctx| ctx.stage(0.0, 1.0, "Warping", |ctl| warp_doc(doc, id, &w, rect, interp, content_knots, ctl)),
+ move |()| json!({"layer": id.0, "changed": true, "rect": [rect.x0, rect.y0, rect.x1, rect.y1]}),
+ )
+ }
+
+ /// The edit of [`apply`]: the layer and the selection outline.
+ fn warp_doc(doc: &mut Document, id: LayerId, w: &Warp, rect: Rect, interp: Interp, content_knots: bool, ctl: &Interrupt) -> Result<()> {
+ let sel = doc.selection.clone();
+ let frames = content_knots.then(|| {
+ let mut f = Frames::new();
+ if let Some(l) = doc.layer(id) {
+ source_frames(doc, l, &mut f);
}
- Ok(())
- })?;
- Ok(json!({"layer": id.0, "changed": true, "rect": [rect.x0, rect.y0, rect.x1, rect.y1]}))
+ f
+ });
+ let is_group = doc.layer(id).is_some_and(Layer::is_group);
+ let group = crate::transform_cmds::group_locks(doc, id);
+ crate::extra_cmds::background_to_layer(doc, id);
+ let l = doc.layer_mut(id).ok_or(EngineError::NoLayer(id))?;
+ warp_layer(if is_group { None } else { sel.as_ref() }, group, l, w, rect, interp, frames.as_ref(), ctl)?;
+ let snapshot = doc.clone();
+ if let Some(l) = doc.layer_mut(id) {
+ crate::transform_cmds::refresh_text(&snapshot, l);
+ }
+ if let Some(sel) = &doc.selection {
+ doc.selection = Some(warp_mesh_gray(sel, &|x, y| w.map(x, y), Interp::Bilinear)).filter(|s| !s.content_bounds().is_empty());
+ }
+ Ok(())
}
#[derive(Clone, Copy)]
diff --cc crates/io/src/smart_map.rs
index 9dfeec858,78b2d7920..b2efd6fbf
--- a/crates/io/src/smart_map.rs
+++ b/crates/io/src/smart_map.rs
@@@ -151,7 -150,7 +151,7 @@@ const fn code(c: &[u8; 4]) -> i32
i32::from_be_bytes(*c)
}
- const KNOWN: [Known; 49] = [
-const KNOWN: [Known; 45] = [
++const KNOWN: [Known; 53] = [
Known { class: "GsnB", filter_id: code(b"GsnB"), name: "Gaussian Blur...", command: "filter.blur.gaussianBlur" },
Known { class: "boxblur", filter_id: 840, name: "Box Blur...", command: "filter.blur.boxBlur" },
Known { class: "MtnB", filter_id: code(b"MtnB"), name: "Motion Blur...", command: "filter.blur.motionBlur" },
@@@ -199,19 -198,17 +199,28 @@@
// Smart Sharpen has a numeric filterID and a stringID class, like Box Blur.
Known { class: SMART_SHARPEN, filter_id: 1131, name: "Smart Sharpen...", command: "filter.sharpen.smartSharpen" },
Known { class: "DstS", filter_id: code(b"DstS"), name: "Dust & Scratches...", command: "filter.noise.dustAndScratches" },
+ // Distort (Photoshop 27, `corpus`-style check: one smart object per filter saved from Photoshop
+ // and read back). Shear isn't mapped yet: its curve lives on Photoshop's own grid.
+ Known { class: "Pnch", filter_id: code(b"Pnch"), name: "Pinch...", command: "filter.distort.pinch" },
+ Known { class: "Plr ", filter_id: code(b"Plr "), name: "Polar Coordinates...", command: "filter.distort.polarCoordinates" },
+ Known { class: "Rple", filter_id: code(b"Rple"), name: "Ripple...", command: "filter.distort.ripple" },
+ Known { class: "Sphr", filter_id: code(b"Sphr"), name: "Spherize...", command: "filter.distort.spherize" },
+ Known { class: "Twrl", filter_id: code(b"Twrl"), name: "Twirl...", command: "filter.distort.twirl" },
+ Known { class: "Wave", filter_id: code(b"Wave"), name: "Wave...", command: "filter.distort.wave" },
+ Known { class: "ZgZg", filter_id: code(b"ZgZg"), name: "ZigZag...", command: "filter.distort.zigZag" },
+ // Image › Adjustments › Invert on a smart object: no settings, so no `Fltr` (`hasoptions` false).
+ Known { class: "Invr", filter_id: code(b"Invr"), name: "Invert", command: "image.adjustments.invert" },
+ Known { class: "LnsF", filter_id: code(b"LnsF"), name: "Lens Flare...", command: "filter.render.lensFlare" },
+ // These three also read the item's foreground and background colours (`coloured_params`).
+ Known { class: "Fbrs", filter_id: code(b"Fbrs"), name: "Fibers...", command: "filter.render.fibers" },
+ Known { class: "Clds", filter_id: code(b"Clds"), name: "Clouds", command: "filter.render.clouds" },
+ Known { class: "DfrC", filter_id: code(b"DfrC"), name: "Difference Clouds", command: "filter.render.differenceClouds" },
];
+ /// Lens Flare's `Lns ` enum and our `lens` values. Photoshop's codes keep the old lens names:
+ /// Nikon 35 mm and 105 mm primes, a Panavision movie prime.
+ const LENSES: [(&[u8; 4], &str); 4] = [(b"Zm ", "zoom"), (b"Nkn ", "prime35"), (b"Nkn1", "prime105"), (b"PnVs", "moviePrime")];
+
/// Classes of the filters that have no options: Photoshop stores them without a `Fltr`.
const NO_OPTIONS: [&str; 11] = ["Blr ", "BlrM", "Avrg", "Dspc", "FndE", "Fct ", "Frgm", "Shrp", "ShrM", "ShrE", "Slrz"];
@@@ -524,36 -553,9 +576,36 @@@ fn custom_params(f: &Descriptor) -> Opt
fn known_params(class: &str, f: Option<&Descriptor>, item: &Descriptor) -> Option<(&'static str, J)> {
let k = KNOWN.iter().find(|k| k.class == class)?;
let params = match (class, f) {
- ("adaptCorrect", None) => json!({}),
+ ("adaptCorrect" | "Invr", None) => json!({}),
(c, None) if NO_OPTIONS.contains(&c) => json!({}),
(_, None) => return None,
+ ("Pnch", Some(f)) => json!({"amount": int(f, "Amnt")?}),
+ ("Twrl", Some(f)) => json!({"angle": int(f, "Angl")?}),
- ("Rple", Some(f)) => json!({"amount": int(f, "Amnt")?, "size": enum_name(f, "RplS", &RIPPLE_SIZE)?}),
- ("Sphr", Some(f)) => json!({"amount": int(f, "Amnt")?, "mode": enum_name(f, "SphM", &SPHERIZE_MODE)?}),
- ("Plr ", Some(f)) => json!({"mode": enum_name(f, "Cnvr", &POLAR_MODE)?}),
- ("ZgZg", Some(f)) => json!({"amount": int(f, "Amnt")?, "ridges": int(f, "NmbR")?, "style": enum_name(f, "ZZTy", &ZIGZAG_STYLE)?}),
++ ("Rple", Some(f)) => json!({"amount": int(f, "Amnt")?, "size": enum_name(f, "RplS", "RplS", &RIPPLE_SIZE)?}),
++ ("Sphr", Some(f)) => json!({"amount": int(f, "Amnt")?, "mode": enum_name(f, "SphM", "SphM", &SPHERIZE_MODE)?}),
++ ("Plr ", Some(f)) => json!({"mode": enum_name(f, "Cnvr", "Cnvr", &POLAR_MODE)?}),
++ ("ZgZg", Some(f)) => json!({"amount": int(f, "Amnt")?, "ridges": int(f, "NmbR")?, "style": enum_name(f, "ZZTy", "ZZTy", &ZIGZAG_STYLE)?}),
+ ("Wave", Some(f)) => {
+ // PhotoCraft's Wave has no Scale: a scaled wave stays verbatim rather than lose it. The
+ // same for more generators than the renderer models, which would draw fewer than
+ // Photoshop did (and than the file asks for, once its cached pixels are re-rendered).
+ let generators = int(f, "NmbG")?;
+ let modelled = u32::try_from(generators).is_ok_and(|g| (1..=photocraft_algo::MAX_WAVE_GENERATORS).contains(&g));
+ if int(f, "SclH")? != 100 || int(f, "SclV")? != 100 || !modelled {
+ return None;
+ }
+ json!({
- "type": enum_name(f, "Wvtp", &WAVE_TYPE)?,
++ "type": enum_name(f, "Wvtp", "Wvtp", &WAVE_TYPE)?,
+ "generators": generators,
+ "wavelengthMin": int(f, "WLMn")?,
+ "wavelengthMax": int(f, "WLMx")?,
+ "amplitudeMin": int(f, "AmMn")?,
+ "amplitudeMax": int(f, "AmMx")?,
- "undefinedAreas": enum_name(f, "UndA", &UNDEFINED_AREAS)?,
++ "undefinedAreas": enum_name(f, "UndA", "UndA", &UNDEFINED_AREAS)?,
+ // `RndS` is a signed long; the seed is its bit pattern.
+ "seed": (int(f, "RndS")? as u32),
+ })
+ }
("GsnB" | "boxblur" | "Mdn " | "HghP" | "Mxm " | "Mnm ", Some(f)) => json!({"radius": px(f, "Rds ")?}),
("MtnB", Some(f)) => json!({"angle": int(f, "Angl")?, "distance": px(f, "Dstn")?}),
("UnsM", Some(f)) => json!({"amount": px(f, "Amnt")?, "radius": px(f, "Rds ")?, "threshold": int(f, "Thsh")?}),
diff --cc crates/psd/src/lib.rs
index 3fbde1ee5,6fb47cbdb..5248456d5
--- a/crates/psd/src/lib.rs
+++ b/crates/psd/src/lib.rs
@@@ -42,8 -42,8 +42,9 @@@
pub mod abr;
pub mod aco;
+ pub mod act;
pub mod ase;
+pub mod asl;
pub mod atn;
pub mod blend;
pub mod builder;
diff --cc crates/ui-egui/src/i18n/cs.tsv
index 97f7caf10,7b45ef741..417e8e082
--- a/crates/ui-egui/src/i18n/cs.tsv
+++ b/crates/ui-egui/src/i18n/cs.tsv
@@@ -3885,13 -3913,9 +3913,17 @@@ navigator Zoom Zvětšen�
DDS Options Možnosti DDS
Generate Mipmaps Generovat mipmapy
+ # Color Table (.act) dialog
+ There is no color table to save. Neexistuje žádná tabulka barev k uložení.
+ @plural Saved {n} color to {file}|Saved {n} colors to {file} Uložena {n} barva do {file}|Uloženy {n} barvy do {file}|Uloženo {n} barev do {file}
+
# Graphics Adapter preference (#1885)
GPU adapter Adaptér GPU
+
+# Styles panel: Import / Export Styles (.asl)
+ Import Styles… Importovat styly…
+ Export Selected Styles… Exportovat vybrané styly…
+ Export Styles… Exportovat styly…
+ {file} is not a style library (.asl) {file} není knihovna stylů (.asl)
+@plural Imported {n} style from {file}|Imported {n} styles from {file} Importován {n} styl ze souboru {file}|Importovány {n} styly ze souboru {file}|Importováno {n} stylů ze souboru {file}
+@plural Exported {n} style to {file}|Exported {n} styles to {file} Exportován {n} styl do souboru {file}|Exportovány {n} styly do souboru {file}|Exportováno {n} stylů do souboru {file}
diff --cc crates/ui-egui/src/i18n/de.tsv
index 8afe19529,ff08cf29a..4784a54f1
--- a/crates/ui-egui/src/i18n/de.tsv
+++ b/crates/ui-egui/src/i18n/de.tsv
@@@ -3281,13 -3311,9 +3311,17 @@@ curves Smooth Glätte
Compression Komprimierung
Generate Mipmaps Mipmaps erzeugen
+ # Color Table (.act) dialog
+ There is no color table to save. Es gibt keine Farbtabelle zum Speichern.
+ @plural Saved {n} color to {file}|Saved {n} colors to {file} {n} Farbe in {file} gespeichert|{n} Farben in {file} gespeichert
+
# Graphics Adapter preference (#1885)
GPU adapter GPU-Adapter
+
+# Styles panel: Import / Export Styles (.asl)
+ Import Styles… Stile importieren…
+ Export Selected Styles… Ausgewählte Stile exportieren…
+ Export Styles… Stile exportieren…
+ {file} is not a style library (.asl) {file} ist keine Stilbibliothek (.asl)
+@plural Imported {n} style from {file}|Imported {n} styles from {file} {n} Stil aus {file} importiert|{n} Stile aus {file} importiert
+@plural Exported {n} style to {file}|Exported {n} styles to {file} {n} Stil nach {file} exportiert|{n} Stile nach {file} exportiert
diff --cc crates/ui-egui/src/i18n/el.tsv
index 2da034c5d,1bee40c34..980d207f7
--- a/crates/ui-egui/src/i18n/el.tsv
+++ b/crates/ui-egui/src/i18n/el.tsv
@@@ -3975,13 -4002,9 +4002,17 @@@ curves Smooth Εξομάλυνσ�
DDS Options Επιλογές DDS
Generate Mipmaps Δημιουργία mipmap
+ # Color Table (.act) dialog
+ There is no color table to save. Δεν υπάρχει πίνακας χρωμάτων για αποθήκευση.
+ @plural Saved {n} color to {file}|Saved {n} colors to {file} Αποθηκεύτηκε {n} χρώμα στο {file}|Αποθηκεύτηκαν {n} χρώματα στο {file}
+
# Graphics Adapter preference (#1885)
GPU adapter Προσαρμογέας GPU
+
+# Styles panel: Import / Export Styles (.asl)
+ Import Styles… Εισαγωγή στιλ…
+ Export Selected Styles… Εξαγωγή επιλεγμένων στιλ…
+ Export Styles… Εξαγωγή στιλ…
+ {file} is not a style library (.asl) Το {file} δεν είναι βιβλιοθήκη στιλ (.asl)
+@plural Imported {n} style from {file}|Imported {n} styles from {file} Εισήχθη {n} στιλ από το {file}|Εισήχθησαν {n} στιλ από το {file}
+@plural Exported {n} style to {file}|Exported {n} styles to {file} Εξήχθη {n} στιλ στο {file}|Εξήχθησαν {n} στιλ στο {file}
diff --cc crates/ui-egui/src/i18n/es.tsv
index 0e8892775,09a1a8da0..c922fa3cb
--- a/crates/ui-egui/src/i18n/es.tsv
+++ b/crates/ui-egui/src/i18n/es.tsv
@@@ -4237,13 -4264,9 +4264,17 @@@ navigator Zoom Zoo
DDS Options Opciones de DDS
Generate Mipmaps Generar mipmaps
+ # Color Table (.act) dialog
+ There is no color table to save. No hay ninguna tabla de colores para guardar.
+ @plural Saved {n} color to {file}|Saved {n} colors to {file} Se guardó {n} color en {file}|Se guardaron {n} colores en {file}
+
# Graphics Adapter preference (#1885)
GPU adapter Adaptador de GPU
+
+# Styles panel: Import / Export Styles (.asl)
+ Import Styles… Importar estilos…
+ Export Selected Styles… Exportar estilos seleccionados…
+ Export Styles… Exportar estilos…
+ {file} is not a style library (.asl) {file} no es una biblioteca de estilos (.asl)
+@plural Imported {n} style from {file}|Imported {n} styles from {file} Se importó {n} estilo de {file}|Se importaron {n} estilos de {file}
+@plural Exported {n} style to {file}|Exported {n} styles to {file} Se exportó {n} estilo a {file}|Se exportaron {n} estilos a {file}
diff --cc crates/ui-egui/src/i18n/fr.tsv
index 795349576,6ba33f3b5..ef98c2f03
--- a/crates/ui-egui/src/i18n/fr.tsv
+++ b/crates/ui-egui/src/i18n/fr.tsv
@@@ -3285,13 -3313,9 +3313,17 @@@ curves Smooth Lisse
Compression Compression
Generate Mipmaps Générer les mipmaps
+ # Color Table (.act) dialog
+ There is no color table to save. Il n’y a aucune table de couleurs à enregistrer.
+ @plural Saved {n} color to {file}|Saved {n} colors to {file} {n} couleur enregistrée dans {file}|{n} couleurs enregistrées dans {file}
+
# Graphics Adapter preference (#1885)
GPU adapter Adaptateur GPU
+
+# Styles panel: Import / Export Styles (.asl)
+ Import Styles… Importer des styles…
+ Export Selected Styles… Exporter les styles sélectionnés…
+ Export Styles… Exporter les styles…
+ {file} is not a style library (.asl) {file} n’est pas une bibliothèque de styles (.asl)
+@plural Imported {n} style from {file}|Imported {n} styles from {file} {n} style importé depuis {file}|{n} styles importés depuis {file}
+@plural Exported {n} style to {file}|Exported {n} styles to {file} {n} style exporté vers {file}|{n} styles exportés vers {file}
diff --cc crates/ui-egui/src/i18n/hu.tsv
index 0c83e8638,f68635d4c..c3daaf8b8
--- a/crates/ui-egui/src/i18n/hu.tsv
+++ b/crates/ui-egui/src/i18n/hu.tsv
@@@ -4193,11 -4218,9 +4220,15 @@@ cameraRaw Yellow Sárg
DDS Options DDS-beállítások
Generate Mipmaps Mipmapek létrehozása
+ # Color Table (.act) dialog
+ There is no color table to save. Nincs menthető színtábla.
+ @plural Saved {n} color to {file}|Saved {n} colors to {file} {n} szín mentve ide: {file}
+
# Graphics Adapter preference (#1885)
GPU adapter GPU-adapter
+
+# Styles panel: Import / Export Styles (.asl)
+ Import Styles… Stílusok importálása…
+ Export Selected Styles… Kijelölt stílusok exportálása…
+ Export Styles… Stílusok exportálása…
+ {file} is not a style library (.asl) {file} nem stíluskönyvtár (.asl)
diff --cc crates/ui-egui/src/i18n/id.tsv
index a42c91d8b,4919f8944..d61b9649c
--- a/crates/ui-egui/src/i18n/id.tsv
+++ b/crates/ui-egui/src/i18n/id.tsv
@@@ -3272,13 -3300,9 +3300,17 @@@ curves Smooth Haluska
Compression Kompresi
Generate Mipmaps Buat mipmap
+ # Color Table (.act) dialog
+ There is no color table to save. Tidak ada tabel warna untuk disimpan.
+ @plural Saved {n} color to {file}|Saved {n} colors to {file} {n} warna disimpan ke {file}
+
# Graphics Adapter preference (#1885)
GPU adapter Adaptor GPU
+
+# Styles panel: Import / Export Styles (.asl)
+ Import Styles… Impor Gaya…
+ Export Selected Styles… Ekspor Gaya Terpilih…
+ Export Styles… Ekspor Gaya…
+ {file} is not a style library (.asl) {file} bukan pustaka gaya (.asl)
+@plural Imported {n} style from {file}|Imported {n} styles from {file} {n} gaya diimpor dari {file}
+@plural Exported {n} style to {file}|Exported {n} styles to {file} {n} gaya diekspor ke {file}
diff --cc crates/ui-egui/src/i18n/it.tsv
index 0500f613d,33c2c48ab..de40745c3
--- a/crates/ui-egui/src/i18n/it.tsv
+++ b/crates/ui-egui/src/i18n/it.tsv
@@@ -4392,13 -4419,9 +4419,17 @@@ shape Appearance Aspett
DDS Options Opzioni DDS
Generate Mipmaps Genera mipmap
+ # Color Table (.act) dialog
+ There is no color table to save. Non c'è alcuna tabella colori da salvare.
+ @plural Saved {n} color to {file}|Saved {n} colors to {file} Salvato {n} colore in {file}|Salvati {n} colori in {file}
+
# Graphics Adapter preference (#1885)
GPU adapter Adattatore GPU
+
+# Styles panel: Import / Export Styles (.asl)
+ Import Styles… Importa stili…
+ Export Selected Styles… Esporta stili selezionati…
+ Export Styles… Esporta stili…
+ {file} is not a style library (.asl) {file} non è una libreria di stili (.asl)
+@plural Imported {n} style from {file}|Imported {n} styles from {file} {n} stile importato da {file}|{n} stili importati da {file}
+@plural Exported {n} style to {file}|Exported {n} styles to {file} {n} stile esportato in {file}|{n} stili esportati in {file}
diff --cc crates/ui-egui/src/i18n/ja.tsv
index e847d4b03,74cef1350..667ae2534
--- a/crates/ui-egui/src/i18n/ja.tsv
+++ b/crates/ui-egui/src/i18n/ja.tsv
@@@ -3953,13 -3980,9 +3980,17 @@@ curves Smooth スムー�
Compression 圧縮
Generate Mipmaps ミップマップを生成
+ # Color Table (.act) dialog
+ There is no color table to save. 保存するカラーテーブルがありません。
+ @plural Saved {n} color to {file}|Saved {n} colors to {file} {file} に {n} 色を保存しました
+
# Graphics Adapter preference (#1885)
GPU adapter GPU アダプター
+
+# Styles panel: Import / Export Styles (.asl)
+ Import Styles… スタイルを読み込み…
+ Export Selected Styles… 選択したスタイルを書き出し…
+ Export Styles… スタイルを書き出し…
+ {file} is not a style library (.asl) {file} はスタイルライブラリ (.asl) ではありません
+@plural Imported {n} style from {file}|Imported {n} styles from {file} {file} からスタイル {n} 個を読み込みました
+@plural Exported {n} style to {file}|Exported {n} styles to {file} {file} にスタイル {n} 個を書き出しました
diff --cc crates/ui-egui/src/i18n/ko.tsv
index 7b718c2b7,bb214d35e..6b009a2b6
--- a/crates/ui-egui/src/i18n/ko.tsv
+++ b/crates/ui-egui/src/i18n/ko.tsv
@@@ -3462,13 -3492,9 +3492,17 @@@ curves Smooth 매끄럽�
Compression 압축
Generate Mipmaps 밉맵 생성
+ # Color Table (.act) dialog
+ There is no color table to save. 저장할 색상표가 없습니다.
+ @plural Saved {n} color to {file}|Saved {n} colors to {file} {file}에 색상 {n}개 저장
+
# Graphics Adapter preference (#1885)
GPU adapter GPU 어댑터
+
+# Styles panel: Import / Export Styles (.asl)
+ Import Styles… 스타일 가져오기…
+ Export Selected Styles… 선택한 스타일 내보내기…
+ Export Styles… 스타일 내보내기…
+ {file} is not a style library (.asl) {file}은(는) 스타일 라이브러리(.asl)가 아닙니다
+@plural Imported {n} style from {file}|Imported {n} styles from {file} {file}에서 스타일 {n}개를 가져왔습니다
+@plural Exported {n} style to {file}|Exported {n} styles to {file} 스타일 {n}개를 {file}(으)로 내보냈습니다
diff --cc crates/ui-egui/src/i18n/nl.tsv
index 1633be51f,64e987d4a..a7c29f472
--- a/crates/ui-egui/src/i18n/nl.tsv
+++ b/crates/ui-egui/src/i18n/nl.tsv
@@@ -4035,13 -4062,9 +4062,17 @@@ curves Smooth Vloeiend make
DDS Options DDS-opties
Generate Mipmaps Mipmaps genereren
+ # Color Table (.act) dialog
+ There is no color table to save. Er is geen kleurtabel om op te slaan.
+ @plural Saved {n} color to {file}|Saved {n} colors to {file} {n} kleur opgeslagen in {file}|{n} kleuren opgeslagen in {file}
+
# Graphics Adapter preference (#1885)
GPU adapter GPU-adapter
+
+# Styles panel: Import / Export Styles (.asl)
+ Import Styles… Stijlen importeren…
+ Export Selected Styles… Geselecteerde stijlen exporteren…
+ Export Styles… Stijlen exporteren…
+ {file} is not a style library (.asl) {file} is geen stijlbibliotheek (.asl)
+@plural Imported {n} style from {file}|Imported {n} styles from {file} {n} stijl geïmporteerd uit {file}|{n} stijlen geïmporteerd uit {file}
+@plural Exported {n} style to {file}|Exported {n} styles to {file} {n} stijl geëxporteerd naar {file}|{n} stijlen geëxporteerd naar {file}
diff --cc crates/ui-egui/src/i18n/pl.tsv
index dc6872d56,20f4b569a..d746367d2
--- a/crates/ui-egui/src/i18n/pl.tsv
+++ b/crates/ui-egui/src/i18n/pl.tsv
@@@ -3875,13 -3902,9 +3902,17 @@@ curves Smooth Wygład�
Compression Kompresja
Generate Mipmaps Generuj mipmapy
+ # Color Table (.act) dialog
+ There is no color table to save. Brak tabeli kolorów do zapisania.
+ @plural Saved {n} color to {file}|Saved {n} colors to {file} Zapisano {n} kolor do {file}|Zapisano {n} kolory do {file}|Zapisano {n} kolorów do {file}
+
# Graphics Adapter preference (#1885)
GPU adapter Karta GPU
+
+# Styles panel: Import / Export Styles (.asl)
+ Import Styles… Importuj style…
+ Export Selected Styles… Eksportuj zaznaczone style…
+ Export Styles… Eksportuj style…
+ {file} is not a style library (.asl) {file} nie jest biblioteką stylów (.asl)
+@plural Imported {n} style from {file}|Imported {n} styles from {file} Zaimportowano {n} styl z {file}|Zaimportowano {n} style z {file}|Zaimportowano {n} stylów z {file}
+@plural Exported {n} style to {file}|Exported {n} styles to {file} Wyeksportowano {n} styl do {file}|Wyeksportowano {n} style do {file}|Wyeksportowano {n} stylów do {file}
diff --cc crates/ui-egui/src/i18n/pt-br.tsv
index f7b602fb1,178fa87df..aa9686322
--- a/crates/ui-egui/src/i18n/pt-br.tsv
+++ b/crates/ui-egui/src/i18n/pt-br.tsv
@@@ -4065,13 -4092,9 +4092,17 @@@ layerLabel No Color Sem co
DDS Options Opções de DDS
Generate Mipmaps Gerar mipmaps
+ # Color Table (.act) dialog
+ There is no color table to save. Não há tabela de cores para salvar.
+ @plural Saved {n} color to {file}|Saved {n} colors to {file} {n} cor salva em {file}|{n} cores salvas em {file}
+
# Graphics Adapter preference (#1885)
GPU adapter Adaptador de GPU
+
+# Styles panel: Import / Export Styles (.asl)
+ Import Styles… Importar estilos…
+ Export Selected Styles… Exportar estilos selecionados…
+ Export Styles… Exportar estilos…
+ {file} is not a style library (.asl) {file} não é uma biblioteca de estilos (.asl)
+@plural Imported {n} style from {file}|Imported {n} styles from {file} {n} estilo importado de {file}|{n} estilos importados de {file}
+@plural Exported {n} style to {file}|Exported {n} styles to {file} {n} estilo exportado para {file}|{n} estilos exportados para {file}
diff --cc crates/ui-egui/src/i18n/ru.tsv
index 8750fec81,2d5247707..fee36b5c5
--- a/crates/ui-egui/src/i18n/ru.tsv
+++ b/crates/ui-egui/src/i18n/ru.tsv
@@@ -3252,13 -3280,9 +3280,17 @@@ curves Smooth Сгладит�
Compression Сжатие
Generate Mipmaps Создать MIP-карты
+ # Color Table (.act) dialog
+ There is no color table to save. Нет таблицы цветов для сохранения.
+ @plural Saved {n} color to {file}|Saved {n} colors to {file} Сохранён {n} цвет в {file}|Сохранены {n} цвета в {file}|Сохранено {n} цветов в {file}
+
# Graphics Adapter preference (#1885)
GPU adapter Адаптер GPU
+
+# Styles panel: Import / Export Styles (.asl)
+ Import Styles… Импортировать стили…
+ Export Selected Styles… Экспортировать выбранные стили…
+ Export Styles… Экспортировать стили…
+ {file} is not a style library (.asl) {file} не является библиотекой стилей (.asl)
+@plural Imported {n} style from {file}|Imported {n} styles from {file} Импортирован {n} стиль из {file}|Импортировано {n} стиля из {file}|Импортировано {n} стилей из {file}
+@plural Exported {n} style to {file}|Exported {n} styles to {file} Экспортирован {n} стиль в {file}|Экспортировано {n} стиля в {file}|Экспортировано {n} стилей в {file}
diff --cc crates/ui-egui/src/i18n/sr.tsv
index e51dd3b27,bc972a208..339777597
--- a/crates/ui-egui/src/i18n/sr.tsv
+++ b/crates/ui-egui/src/i18n/sr.tsv
@@@ -4345,13 -4373,9 +4373,17 @@@ shape Appearance Izgle
DDS Options DDS opcije
Generate Mipmaps Generiši mipmape
+ # Color Table (.act) dialog
+ There is no color table to save. Нема табеле боја за чување.
+ @plural Saved {n} color to {file}|Saved {n} colors to {file} Сачувана је {n} боја у {file}|Сачуване су {n} боје у {file}|Сачувано је {n} боја у {file}
+
# Graphics Adapter preference (#1885)
GPU adapter GPU adapter
+
+# Styles panel: Import / Export Styles (.asl)
+ Import Styles… Uvezi stilove…
+ Export Selected Styles… Izvezi izabrane stilove…
+ Export Styles… Izvezi stilove…
+ {file} is not a style library (.asl) {file} nije biblioteka stilova (.asl)
+@plural Imported {n} style from {file}|Imported {n} styles from {file} Uvezen je {n} stil iz {file}|Uvezena su {n} stila iz {file}|Uvezeno je {n} stilova iz {file}
+@plural Exported {n} style to {file}|Exported {n} styles to {file} Izvezen je {n} stil u {file}|Izvezena su {n} stila u {file}|Izvezeno je {n} stilova u {file}
diff --cc crates/ui-egui/src/i18n/tr.tsv
index c63aa6c60,b8421180e..648fd4266
--- a/crates/ui-egui/src/i18n/tr.tsv
+++ b/crates/ui-egui/src/i18n/tr.tsv
@@@ -4002,13 -4029,9 +4029,17 @@@ cameraData Lens Len
DDS Options DDS Seçenekleri
Generate Mipmaps Mipmap oluştur
+ # Color Table (.act) dialog
+ There is no color table to save. Kaydedilecek renk tablosu yok.
+ @plural Saved {n} color to {file}|Saved {n} colors to {file} {n} renk {file} konumuna kaydedildi
+
# Graphics Adapter preference (#1885)
GPU adapter GPU bağdaştırıcısı
+
+# Styles panel: Import / Export Styles (.asl)
+@plural Imported {n} style from {file}|Imported {n} styles from {file} {file} dosyasından {n} stil içe aktarıldı
+@plural Exported {n} style to {file}|Exported {n} styles to {file} {n} stil {file} dosyasına dışa aktarıldı
+ Import Styles… Stilleri İçe Aktar…
+ Export Selected Styles… Seçili Stilleri Dışa Aktar…
+ Export Styles… Stilleri Dışa Aktar…
+ {file} is not a style library (.asl) {file} bir stil kitaplığı değil (.asl)
diff --cc crates/ui-egui/src/i18n/uk.tsv
index da27436ca,b766c477f..50be43637
--- a/crates/ui-egui/src/i18n/uk.tsv
+++ b/crates/ui-egui/src/i18n/uk.tsv
@@@ -3984,13 -4011,9 +4011,17 @@@ curves Smooth Згладит�
Compression Стиснення
Generate Mipmaps Створити MIP-карти
+ # Color Table (.act) dialog
+ There is no color table to save. Немає таблиці кольорів для збереження.
+ @plural Saved {n} color to {file}|Saved {n} colors to {file} Збережено {n} колір у {file}|Збережено {n} кольори у {file}|Збережено {n} кольорів у {file}
+
# Graphics Adapter preference (#1885)
GPU adapter Адаптер GPU
+
+# Styles panel: Import / Export Styles (.asl)
+ Import Styles… Імпортувати стилі…
+ Export Selected Styles… Експортувати вибрані стилі…
+ Export Styles… Експортувати стилі…
+ {file} is not a style library (.asl) {file} не є бібліотекою стилів (.asl)
+@plural Imported {n} style from {file}|Imported {n} styles from {file} Імпортовано {n} стиль з {file}|Імпортовано {n} стилі з {file}|Імпортовано {n} стилів з {file}
+@plural Exported {n} style to {file}|Exported {n} styles to {file} Експортовано {n} стиль до {file}|Експортовано {n} стилі до {file}|Експортовано {n} стилів до {file}
diff --cc crates/ui-egui/src/i18n/vi.tsv
index 5a58ba7b0,e9dd23a61..ef54c2d56
--- a/crates/ui-egui/src/i18n/vi.tsv
+++ b/crates/ui-egui/src/i18n/vi.tsv
@@@ -3764,13 -3792,9 +3792,17 @@@ curves Smooth Làm mượ
Compression Nén
Generate Mipmaps Tạo mipmap
+ # Color Table (.act) dialog
+ There is no color table to save. Không có bảng màu nào để lưu.
+ @plural Saved {n} color to {file}|Saved {n} colors to {file} Đã lưu {n} màu vào {file}
+
# Graphics Adapter preference (#1885)
GPU adapter Bộ điều hợp GPU
+
+# Styles panel: Import / Export Styles (.asl)
+ Import Styles… Nhập kiểu…
+ Export Selected Styles… Xuất các kiểu đã chọn…
+ Export Styles… Xuất kiểu…
+ {file} is not a style library (.asl) {file} không phải là thư viện kiểu (.asl)
+@plural Imported {n} style from {file}|Imported {n} styles from {file} Đã nhập {n} kiểu từ {file}
+@plural Exported {n} style to {file}|Exported {n} styles to {file} Đã xuất {n} kiểu sang {file}
diff --cc crates/ui-egui/src/i18n/zh-hans.tsv
index 96dca13ac,2e028d564..a201f604a
--- a/crates/ui-egui/src/i18n/zh-hans.tsv
+++ b/crates/ui-egui/src/i18n/zh-hans.tsv
@@@ -2906,13 -2937,9 +2937,17 @@@ curves Smooth 平�
Compression 压缩
Generate Mipmaps 生成 Mipmap
+ # Color Table (.act) dialog
+ There is no color table to save. 没有可保存的色表。
+ @plural Saved {n} color to {file}|Saved {n} colors to {file} 已将 {n} 种颜色保存到 {file}
+
# Graphics Adapter preference (#1885)
GPU adapter GPU 适配器
+
+# Styles panel: Import / Export Styles (.asl)
+ Import Styles… 导入样式…
+ Export Selected Styles… 导出所选样式…
+ Export Styles… 导出样式…
+ {file} is not a style library (.asl) {file} 不是样式库 (.asl)
+@plural Imported {n} style from {file}|Imported {n} styles from {file} 已从 {file} 导入 {n} 个样式
+@plural Exported {n} style to {file}|Exported {n} styles to {file} 已将 {n} 个样式导出到 {file}
diff --cc crates/ui-egui/src/i18n/zh-hant.tsv
index 64d652877,1f1341fa2..161c1fd6d
--- a/crates/ui-egui/src/i18n/zh-hant.tsv
+++ b/crates/ui-egui/src/i18n/zh-hant.tsv
@@@ -2891,13 -2922,9 +2922,17 @@@ curves Smooth 平�
Compression 壓縮
Generate Mipmaps 產生 Mipmap
+ # Color Table (.act) dialog
+ There is no color table to save. 沒有可儲存的色表。
+ @plural Saved {n} color to {file}|Saved {n} colors to {file} 已將 {n} 種顏色儲存至 {file}
+
# Graphics Adapter preference (#1885)
GPU adapter GPU 介面卡
+
+# Styles panel: Import / Export Styles (.asl)
+ Import Styles… 匯入樣式…
+ Export Selected Styles… 匯出所選樣式…
+ Export Styles… 匯出樣式…
+ {file} is not a style library (.asl) {file} 不是樣式庫 (.asl)
+@plural Imported {n} style from {file}|Imported {n} styles from {file} 已從 {file} 匯入 {n} 個樣式
+@plural Exported {n} style to {file}|Exported {n} styles to {file} 已將 {n} 個樣式匯出至 {file}
diff --cc crates/ui-egui/src/panels.rs
index 453bd63a4,65efb1c13..8fa0563e8
--- a/crates/ui-egui/src/panels.rs
+++ b/crates/ui-egui/src/panels.rs
@@@ -2389,11 -2490,36 +2490,37 @@@ fn hsb_sliders(app: &mut PhotocraftApp
if changed {
app.session.tools.foreground = hsva_srgb(hsva);
ui.data_mut(|d| d.insert_temp(key, hsva));
- crate::type_tool::foreground_changed(app);
+ crate::apply_color::foreground_changed(app, crate::apply_color::gesture(ui.ctx()));
}
+ crate::apply_color::track_focus(ui.ctx());
}
+ /// Red, Green and Blue sliders (0–255) for the colour the panel is editing (#7172).
+ fn rgb_sliders(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
+ let bg = app.ui.color_panel.background;
+ let mut c = if bg { app.session.tools.background } else { app.session.tools.foreground };
+ let mut rgb = srgb_bytes(c).map(f32::from);
+ let dynamic = app.session.prefs().interface.dynamic_color_sliders;
+ let mut changed = false;
+ let [r0, g0, b0] = rgb.map(|v| v.round() as u8);
+ let r_stops = [Color32::from_rgb(0, g0, b0), Color32::from_rgb(255, g0, b0)];
+ changed |= widgets::slider_row(ui, tl!("Red"), &mut rgb[0], 0.0..=255.0, "", dynamic.then_some(&r_stops)).changed();
+ let g_stops = [Color32::from_rgb(r0, 0, b0), Color32::from_rgb(r0, 255, b0)];
+ changed |= widgets::slider_row(ui, tl!("Green"), &mut rgb[1], 0.0..=255.0, "", dynamic.then_some(&g_stops)).changed();
+ let b_stops = [Color32::from_rgb(r0, g0, 0), Color32::from_rgb(r0, g0, 255)];
+ changed |= widgets::slider_row(ui, tl!("Blue"), &mut rgb[2], 0.0..=255.0, "", dynamic.then_some(&b_stops)).changed();
+ if changed {
+ let q = |v: f32| (v.clamp(0.0, 255.0).round() / 255.0).clamp(0.0, 1.0);
+ c = [q(rgb[0]), q(rgb[1]), q(rgb[2]), 1.0];
+ if bg {
+ app.session.tools.background = c;
+ } else {
+ app.session.tools.foreground = c;
+ crate::type_tool::foreground_changed(app);
+ }
+ }
+ }
+
// ----------------------------------------------------------------------------- layers
/// The simple themes' single lock button. On the Background it converts the layer to a normal
diff --cc crates/ui-egui/src/preset_files_ui.rs
index a35452f7d,85a2a0865..74be08360
--- a/crates/ui-egui/src/preset_files_ui.rs
+++ b/crates/ui-egui/src/preset_files_ui.rs
@@@ -1,8 -1,7 +1,8 @@@
//! Preset files opened like documents (File › Open, drag-and-drop, the Brushes panel's
//! Import Brushes…, the Preset Manager's Load…): Photoshop brushes (`.abr`) go to the brush
//! library through `brush.presets.importAbr`, gradients (`.grd`) to the Gradients panel through
-//! `gradient.presets.importGrd`, swatches (`.aco`, `.act`, `.ase`) to the Swatches panel through
+//! `gradient.presets.importGrd`, layer styles (`.asl`) to the Styles panel through
- //! `style.presets.importAsl`, swatches (`.aco`, `.ase`) to the Swatches panel through
++//! `style.presets.importAsl`, swatches (`.aco`, `.act`, `.ase`) to the Swatches panel through
//! `swatches.import`, patterns (`.pat`) to the Patterns panel through `pattern.import`, keyboard
//! shortcut sets (`.kys`) to Edit › Keyboard Shortcuts through
//! [`crate::kys_import`], instead of opening as documents. Import Brushes… also takes an image
@@@ -16,7 -15,7 +16,7 @@@ use crate::PhotocraftApp
/// the Swatches panel through [`crate::swatches_ui::import_bytes`]).
/// `.psp` is Photoshop's live `Keyboard Shortcuts.psp` (the same XML as a `.kys`); other `.psp`
/// settings files are refused with a clear message.
- pub const PRESET_EXTS: &[&str] = &["abr", "grd", "asl", "pat", "aco", "ase", "kys", "psp"];
-pub const PRESET_EXTS: &[&str] = &["abr", "grd", "pat", "aco", "act", "ase", "kys", "psp"];
++pub const PRESET_EXTS: &[&str] = &["abr", "grd", "asl", "pat", "aco", "act", "ase", "kys", "psp"];
fn ext(name: &str) -> String {
std::path::Path::new(name).extension().map(|e| e.to_string_lossy().to_ascii_lowercase()).unwrap_or_default()
@@@ -89,9 -88,8 +89,9 @@@ pub fn open(app: &mut PhotocraftApp, na
let (cmd, what) = match ext(name).as_str() {
"abr" => ("brush.presets.importAbr", "brushes"),
"grd" => ("gradient.presets.importGrd", "gradients"),
+ "asl" => ("style.presets.importAsl", "styles"),
"pat" => ("pattern.import", "patterns"),
- "aco" | "ase" => return Some(crate::swatches_ui::import_bytes(app, name, bytes, false).map(|_| ())),
+ "aco" | "act" | "ase" => return Some(crate::swatches_ui::import_bytes(app, name, bytes, false).map(|_| ())),
"kys" | "psp" => return Some(crate::kys_import::open_bytes(app, name, bytes).map(|_| ())),
_ => return None,
};
diff --cc docs/file-format-parity.md
index 442a4bf10,8cccdd1be..162518e8c
--- a/docs/file-format-parity.md
+++ b/docs/file-format-parity.md
@@@ -1,6 -1,6 +1,6 @@@
# File-format parity
- > **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-20 · **Change:** minor (`.asl` layer style libraries read and written, #1051; DDS textures save: uncompressed or BC1–BC3, optional mip chain, DDS Options in Save As (#1327); PSD smart filters: 49 filters (35 more: Pinch, Polar Coordinates, Ripple, Spherize, Twirl, Wave, ZigZag, Invert, Blur, Surface Blur, Smart Sharpen, Diffuse, Wind, Offset, Mezzotint and others) plus Hue/Saturation and Perspective Warp mapped both ways, #6296, #6298, #6300, #6302, #6304, #6314, #6316, #6267, #6268, FILE-215-2; large-file fixtures: a 20 MP layered PSD, a 150-layer layout, a 2 GB PSD and a 4.4 GB PSB generated at test time and round-tripped, FILE-216-2 done, #5107; earlier: smart objects keep Photoshop's Cylinder warp through re-renders and saves, #4112; PNG `sTER` stereo pairing kept on save, #6063; PDF write one flattened page via Save As / Save a Copy / CLI, #3401; CMYK Invert, Posterize and Threshold on the inks; smart filter masks on PSD open and save; Photoshop-oracle floor 188/258; lossy DNG, compression 34892, decodes with its levels and LinearizationTable applied to the stored 8-bit samples, FILE-215-11; CMYK Hue/Saturation and Color Balance keep the black ink; CMYK Posterize on the stored values, psd-tools oracle floor 242/309; CMYK adjustment layers composite on the document's inks; Photoshop-oracle floor 165/258; CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; modern Brightness/Contrast's brightness curve; Photoshop-oracle floor 151/258; Lab documents composite on their stored L, a, b; Photoshop-oracle floor 152/258; Levels on whole levels at every step with Photoshop's shadow toe; Photoshop-oracle floor 146/258, psd-tools 238/309; 32-bit adjustments unclipped; Photoshop-oracle floor 149/258; mask feathers blur with their exact variance; Threshold splits on Photoshop's luminosity; a pass-through clipping base with an adjustment renders isolated; psd-tools oracle floor 240/309; 16-bit Posterize as Photoshop bins it; psd-tools oracle floor 241/309; Gradient Map luminosity; Photoshop-oracle floor 147/258; PSD: `Mt16`/`Mt32` merged transparency read; palette PNGs open in Indexed Color mode, #4804; earlier: CMYK Invert, Posterize and Threshold on the inks; 16-bit Lab Invert; Photoshop-oracle floor 145/258; `.atn` import maps 112 events; DDS textures open, #1327; DPX read and write, #1049; #2465 fixed: CS2 placed layers with only a `PlLd` block open their contents; Photoshop Actions `.atn` read and write; `.shc` contour files read and write; earlier the same day: indexed BMP palette mode; Save keeps a JPEG's quality and a WebP's encoding) · **Target:** Adobe Photoshop 2026
-> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-15 · **Change:** minor (Photoshop mixed-order TIFF type geometry, #4758; DDS textures save: uncompressed or BC1–BC3, optional mip chain, DDS Options in Save As (#1327); PSD smart filters: 45 filters (31 more: Blur, Surface Blur, Smart Sharpen, Diffuse, Wind, Offset, Mezzotint, Clouds, Difference Clouds, Fibers, Lens Flare and others) plus Hue/Saturation and Perspective Warp mapped both ways, #6296, #6298, #6300, #6302, #6304, #6314, #6316, #6267, #6268, FILE-215-2; large-file fixtures: a 20 MP layered PSD, a 150-layer layout, a 2 GB PSD and a 4.4 GB PSB generated at test time and round-tripped, FILE-216-2 done, #5107; earlier: PNG `sTER` stereo pairing kept on save, #6063; PDF write one flattened page via Save As / Save a Copy / CLI, #3401; CMYK Invert, Posterize and Threshold on the inks; smart filter masks on PSD open and save; Photoshop-oracle floor 188/258; lossy DNG, compression 34892, decodes with its levels and LinearizationTable applied to the stored 8-bit samples, FILE-215-11; CMYK Hue/Saturation and Color Balance keep the black ink; CMYK Posterize on the stored values, psd-tools oracle floor 242/309; CMYK adjustment layers composite on the document's inks; Photoshop-oracle floor 165/258; CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; modern Brightness/Contrast's brightness curve; Photoshop-oracle floor 151/258; Lab documents composite on their stored L, a, b; Photoshop-oracle floor 152/258; Levels on whole levels at every step with Photoshop's shadow toe; Photoshop-oracle floor 146/258, psd-tools 238/309; 32-bit adjustments unclipped; Photoshop-oracle floor 149/258; mask feathers blur with their exact variance; Threshold splits on Photoshop's luminosity; a pass-through clipping base with an adjustment renders isolated; psd-tools oracle floor 240/309; 16-bit Posterize as Photoshop bins it; psd-tools oracle floor 241/309; Gradient Map luminosity; Photoshop-oracle floor 147/258; PSD: `Mt16`/`Mt32` merged transparency read; palette PNGs open in Indexed Color mode, #4804; earlier: CMYK Invert, Posterize and Threshold on the inks; 16-bit Lab Invert; Photoshop-oracle floor 145/258; `.atn` import maps 112 events; DDS textures open, #1327; DPX read and write, #1049; #2465 fixed: CS2 placed layers with only a `PlLd` block open their contents; Photoshop Actions `.atn` read and write; `.shc` contour files read and write; earlier the same day: indexed BMP palette mode; Save keeps a JPEG's quality and a WebP's encoding) · **Target:** Adobe Photoshop 2026
++> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-22 · **Change:** minor (`.asl` layer style libraries read and written, #1051; Photoshop mixed-order TIFF type geometry, #4758; DDS textures save: uncompressed or BC1–BC3, optional mip chain, DDS Options in Save As (#1327); PSD smart filters: 53 filters (39 more: Pinch, Polar Coordinates, Ripple, Spherize, Twirl, Wave, ZigZag, Invert, Blur, Surface Blur, Smart Sharpen, Diffuse, Wind, Offset, Mezzotint, Clouds, Difference Clouds, Fibers, Lens Flare and others) plus Hue/Saturation and Perspective Warp mapped both ways, #6296, #6298, #6300, #6302, #6304, #6314, #6316, #6267, #6268, FILE-215-2; large-file fixtures: a 20 MP layered PSD, a 150-layer layout, a 2 GB PSD and a 4.4 GB PSB generated at test time and round-tripped, FILE-216-2 done, #5107; earlier: smart objects keep Photoshop's Cylinder warp through re-renders and saves, #4112; PNG `sTER` stereo pairing kept on save, #6063; PDF write one flattened page via Save As / Save a Copy / CLI, #3401; CMYK Invert, Posterize and Threshold on the inks; smart filter masks on PSD open and save; Photoshop-oracle floor 188/258; lossy DNG, compression 34892, decodes with its levels and LinearizationTable applied to the stored 8-bit samples, FILE-215-11; CMYK Hue/Saturation and Color Balance keep the black ink; CMYK Posterize on the stored values, psd-tools oracle floor 242/309; CMYK adjustment layers composite on the document's inks; Photoshop-oracle floor 165/258; CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; modern Brightness/Contrast's brightness curve; Photoshop-oracle floor 151/258; Lab documents composite on their stored L, a, b; Photoshop-oracle floor 152/258; Levels on whole levels at every step with Photoshop's shadow toe; Photoshop-oracle floor 146/258, psd-tools 238/309; 32-bit adjustments unclipped; Photoshop-oracle floor 149/258; mask feathers blur with their exact variance; Threshold splits on Photoshop's luminosity; a pass-through clipping base with an adjustment renders isolated; psd-tools oracle floor 240/309; 16-bit Posterize as Photoshop bins it; psd-tools oracle floor 241/309; Gradient Map luminosity; Photoshop-oracle floor 147/258; PSD: `Mt16`/`Mt32` merged transparency read; palette PNGs open in Indexed Color mode, #4804; earlier: CMYK Invert, Posterize and Threshold on the inks; 16-bit Lab Invert; Photoshop-oracle floor 145/258; `.atn` import maps 112 events; DDS textures open, #1327; DPX read and write, #1049; #2465 fixed: CS2 placed layers with only a `PlLd` block open their contents; Photoshop Actions `.atn` read and write; `.shc` contour files read and write; earlier the same day: indexed BMP palette mode; Save keeps a JPEG's quality and a WebP's encoding) · **Target:** Adobe Photoshop 2026
Every format Photoshop 2026 (27.11.0) reads or writes, with PhotoCraft's support, fidelity and
tests. Photoshop's list comes from its `Info.plist` `CFBundleDocumentTypes`, the PiPL read/write
@@@ -21,10 -21,10 +21,10 @@@ XL are missing (gap G10). Remaining: 30
| Format | Photoshop | PhotoCraft read | PhotoCraft write | Fidelity and tests |
|---|---|---|---|---|
- | PSD | R/W | yes | yes | 1/8/16/32-bit; Bitmap, Gray, Indexed, RGB, CMYK, Multichannel, Lab, Duotone; layers, groups, masks, vector masks, adjustment and fill layers, effects, text, shapes, smart objects (SoLd/lnk2 with their warp: the bend presets, a custom mesh and, since #4112, Cylinder; CS2 PlLd/lnkD read with their warp, kept as is or re-saved as SoLd once edited), smart filters (49 mapped, among them Invert and the Distort filters but Shear, plus Hue/Saturation, Perspective Warp, Filter Gallery with Chrome and a Camera Raw subset, rest verbatim), slices, comps, Advanced Blending. Oracle floors: Photoshop-authored 188/258, io 148/170, psd-tools 249/309; round trip ≥ 169/170, 308/309, 258/256. Known failures: #1281, #2469 (#2374, text layers, closed 2026-10-10; #2465, CS2 `PlLd`-only smart objects, fixed 2026-10-12) |
-| PSD | R/W | yes | yes | 1/8/16/32-bit; Bitmap, Gray, Indexed, RGB, CMYK, Multichannel, Lab, Duotone; layers, groups, masks, vector masks, adjustment and fill layers, effects, text, shapes, smart objects (SoLd/lnk2; CS2 PlLd/lnkD read with their warp, kept as is or re-saved as SoLd once edited), smart filters (45 mapped, among them Clouds, Difference Clouds, Fibers and Lens Flare, plus Hue/Saturation, Perspective Warp, Filter Gallery with Chrome and a Camera Raw subset, rest verbatim), slices, comps, Advanced Blending. Oracle floors: Photoshop-authored 188/258, io 148/170, psd-tools 249/309; round trip ≥ 169/170, 308/309, 258/256. Known failures: #1281, #2469 (#2374, text layers, closed 2026-10-10; #2465, CS2 `PlLd`-only smart objects, fixed 2026-10-12) |
++| PSD | R/W | yes | yes | 1/8/16/32-bit; Bitmap, Gray, Indexed, RGB, CMYK, Multichannel, Lab, Duotone; layers, groups, masks, vector masks, adjustment and fill layers, effects, text, shapes, smart objects (SoLd/lnk2 with their warp: the bend presets, a custom mesh and, since #4112, Cylinder; CS2 PlLd/lnkD read with their warp, kept as is or re-saved as SoLd once edited), smart filters (53 mapped, among them Invert, the Distort filters but Shear, Clouds, Difference Clouds, Fibers and Lens Flare, plus Hue/Saturation, Perspective Warp, Filter Gallery with Chrome and a Camera Raw subset, rest verbatim), slices, comps, Advanced Blending. Oracle floors: Photoshop-authored 188/258, io 148/170, psd-tools 249/309; round trip ≥ 169/170, 308/309, 258/256. Known failures: #1281, #2469 (#2374, text layers, closed 2026-10-10; #2465, CS2 `PlLd`-only smart objects, fixed 2026-10-12) |
| PSB | R/W | yes | yes | Auto-switches above 2 GB (REL-212-2); generated 20 MP, 150-layer, 2 GB PSD and 4.4 GB PSB fixtures opened, saved and re-opened by io tests/large_files.rs (FILE-216-2, 2026-10-13; the 4.4 GB PSB opens on Windows); > 4 GB from the app's File › Open on Windows: #375 |
| Cloud PSD (.psdc) | R/W | no | no | Out of scope (Adobe cloud) |
- | TIFF | R/W | yes | yes | 8/16/32f, Gray/RGB/CMYK, BigTIFF, every IFD, banded parallel decode; layered TIFF both byte orders (FILE-215-7: extra alpha channels not written) |
+ | TIFF | R/W | yes | yes | 8/16/32f, Gray/RGB/CMYK, BigTIFF, every IFD, banded parallel decode; layered TIFF both byte orders, including Photoshop mixed-order type blocks (#4758); undecodable type keeps saved pixels (FILE-215-7: extra alpha channels not written) |
| JPEG | R/W | yes | yes | 8-bit Gray/RGB/CMYK, ICC/EXIF/XMP; Save keeps the opened file's quality (estimated from its quantisation tables, #2399); no JPEG Options dialog (quality 0–12, baseline/progressive) (FILE-215-19) |
| PNG | R/W | yes | yes | 8/16-bit, ICC/text; APNG first frame only; alpha channels on open (#2225); palette PNGs open in Indexed Color mode with their transparent entry (#4804); Save keeps a stereo PNG's `sTER` pairing (#6063) |
| GIF | R/W | yes | yes | File › Open keeps the first frame; New Video Layer from File and Video Frames to Layers take every frame, with the timeline rate from the delays (#572). Per-frame delays and keeping the frames in `.pcraft` are not done |
@@@ -153,8 -154,10 +154,11 @@@ remaining gaps in #1606 stay tracked wi
| 2026-10-15 | minor | PSD smart filters: Offset (`Ofst`: `Hrzn`/`Vrtc` long, `Fl ` `FlMd` Wrap/Background/Repeat) and Custom (`Cstm`: `Scl `, `Ofst` long, 25-long `Mtrx`) map both ways in `filterFX`, matching descriptors measured in Photoshop (FILE-215-2, #6304) |
| 2026-10-15 | minor | PSD smart filters: Mezzotint (`Mztn`, `MztT` enum, all 10 types) and Color Halftone (`ClrH`, `Rds `/`Ang1`–`Ang4` longs) open as editable filters and save in Photoshop's shape, measured in Photoshop (FILE-215-2); Mezzotint's PhotoCraft-only seed is not saved |
| 2026-10-15 | minor | PNG: a stereo PNG's `sTER` pairing (PNG Extensions 1.4.0 §3.6) is read on open and written back on save, so the file still says it is a stereo pair (#6063) |
+ | 2026-10-15 | minor | Indexed Color documents save as 8-bit palette BMPs with their colour table instead of 24-bit RGB; a palette BMP opens with its declared number of colours, not 256 |
| 2026-10-15 | minor | PSD guides: image resource 1092 (guides v2) gives guides their own colours on import; 1092 and 1097 (guide GUIDs) are written back only while they still describe the document's guides, so an edit no longer leaves Photoshop a stale second guide list (#5966) |
+| 2026-10-14 | minor | PSD smart objects warped with Transform Warp's Cylinder (`warpCylinder`, seven `warpValues`) are read and written: Replace Contents, Relink and Edit Contents re-render them wrapped instead of flat, and a regenerated `SoLd` no longer drops the warp (#4112). Vertical cylinders and ones with perspective are still unread |
+ | 2026-10-15 | minor | Bevel & Emboss Gloss Contour › Anti-aliased (`antialiasGloss`) is read and written, set by `glossAntiAlias` and shown in the Layer Style dialog; a PSD whose bevel is edited no longer loses it. Rendering still ignores contour anti-aliasing, as for the other effects' contours |
+ | 2026-10-15 | minor | Stroke › Overprint (`overprint`) is read and written, set by the stroke command's `overprint` and shown in the Layer Style dialog; an edited stroke no longer drops it. Rendering ignores it for now |
| 2026-10-14 | minor | PSD smart filter masks: Photoshop stores a smart object's filtered pixels without its filter mask and mixes the unfiltered ones (`FEid`) back in; import now mixes them and export writes them that way, so sf-filter-mask-hard, -gradient and sf-stack-blend-and-mask pass; Photoshop-oracle floor 185 → 188 of 258 |
| 2026-10-13 | minor | Lossy DNG (compression 34892) decodes: 8-bit baseline JPEG tiles and strips, CFA and LinearRaw, partial edge tiles; the stored values take the normal levels and LinearizationTable (FILE-215-11, lossy DNG part) |
| 2026-10-14 | minor | Corpus floors raised to the measured results of the CMYK, Lab, 32-bit, Levels, Threshold, Posterize, feather and pass-through fixes landed together: Photoshop-authored 165 → 185 of 258, io 146 → 148 of 170, psd-tools 242 → 249 of 309 |
diff --cc docs/gaps.md
index 426331153,9b281d678..93c085688
--- 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-20 · **Change:** minor (G10: `.asl` style libraries landed, #1051; G8: area type (TYPE-218-10); G1: smart objects keep Photoshop's Cylinder warp, #4112; G9: Preferences › File Handling › Save in Background takes effect, #6207, 24 of 169 preferences do nothing; G7: Content-Aware Move previews every selection the command takes, coarse then exact, TOOL-213-4 done, #6680; G4: Pattern Stamp and Background Eraser draw live, TOOL-213-7; G9: Animated Zoom pref read: holding the Zoom tool zooms continuously, #6210, prefs that do nothing 25 of 166; G2: a cancelled 24 MP Gaussian Blur job stops in at most 44 ms, P25 under its 200 ms budget, #6205; G1: generated large-file fixtures, a 4.38 GB PSB opens on Windows through io, FILE-216-2 done, #5107; G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; G7: Field Blur's on-canvas pins, #3373; G4: Hue Jitter amount track, #3825 partial; 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; stale missing-tool rows corrected: Color Replacement, Red Eye and Add/Delete Anchor Point are live tools, so only Art History Brush is missing; no estimate changed) · **Target:** Adobe Photoshop 2026
-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-18 · **Change:** minor (G9: Preferences › File Handling › Save in Background takes effect, #6207, 24 of 169 preferences do nothing; G7: Content-Aware Move previews every selection the command takes, coarse then exact, TOOL-213-4 done, #6680; G4: Pattern Stamp and Background Eraser draw live, TOOL-213-7; G9: Animated Zoom pref read: holding the Zoom tool zooms continuously, #6210, prefs that do nothing 25 of 166; G2: a cancelled 24 MP Gaussian Blur job stops in at most 44 ms, P25 under its 200 ms budget in local runs, baseline not re-run, #6205; G1: generated large-file fixtures, a 4.38 GB PSB opens on Windows through io, FILE-216-2 done, #5107; G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; G7: Field Blur's on-canvas pins, #3373; G4: Hue Jitter amount track, #3825 partial; 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; stale missing-tool rows corrected: Color Replacement, Red Eye and Add/Delete Anchor Point are live tools, so only Art History Brush is missing; no estimate changed) · **Target:** Adobe Photoshop 2026
++> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-22 · **Change:** minor (G10: `.asl` style libraries landed, #1051; G8: area type (TYPE-218-10); G1: smart objects keep Photoshop's Cylinder warp, #4112; G9: Preferences › File Handling › Save in Background takes effect, #6207, 24 of 169 preferences do nothing; G7: Content-Aware Move previews every selection the command takes, coarse then exact, TOOL-213-4 done, #6680; G4: Pattern Stamp and Background Eraser draw live, TOOL-213-7; G9: Animated Zoom pref read: holding the Zoom tool zooms continuously, #6210, prefs that do nothing 25 of 166; G2: a cancelled 24 MP Gaussian Blur job stops in at most 44 ms, P25 under its 200 ms budget in local runs, baseline not re-run, #6205; G1: generated large-file fixtures, a 4.38 GB PSB opens on Windows through io, FILE-216-2 done, #5107; G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; G7: Field Blur's on-canvas pins, #3373; G4: Hue Jitter amount track, #3825 partial; 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; stale missing-tool rows corrected: Color Replacement, Red Eye and Add/Delete Anchor Point are live tools, so only Art History Brush is missing; no estimate changed) · **Target:** Adobe Photoshop 2026
Every known shortfall against Photoshop 2026 (27.11.0), one entry each, ranked by user impact
on the way to beta. This is the work list agents pick from: take the highest-ranked entry that
@@@ -291,9 -291,8 +294,9 @@@ what an agent can't finish alone
| Date | Change | Summary |
|---|---|---|
| 2026-10-15 | minor | G1 / #5972 A1: render only provably constant-RGB `GdFl` noise fills; variable noise synthesis remains open |
+| 2026-10-20 | minor | G10: `.asl` layer style library import and export landed (#1051) |
| 2026-10-18 | minor | G9: with no selection, Copy takes fill and adjustment layers whole and Paste recreates them (#2344); UI-217-23 stays partial (a single pixel layer copies its pixels only); estimate unchanged |
- | 2026-10-15 | minor | G2: a cancelled 24 MP Gaussian Blur job stops within 44 ms max (P25, budget 200 ms; was about 400 ms), the uncancelled job about 40% faster; #6205 |
+ | 2026-10-15 | minor | G2: a cancelled 24 MP Gaussian Blur job stops within 44 ms max (P25, budget 200 ms; was about 400 ms; local runs, baseline not re-run), the uncancelled job on a locked-transparency layer about 40% faster; #6205 |
| 2026-10-15 | minor | G9: Animated Zoom preference takes effect (hold the Zoom tool to zoom continuously, #6210); prefs that do nothing 25 of 166; no estimate changed |
| 2026-10-16 | minor | G7: Content-Aware Move's live preview covers every selection the command takes (over 256 × 256: a coarse result solved scaled down, then the exact one); TOOL-213-4 done (#6680) |
| 2026-10-15 | minor | G9: Save in Background off saves in the foreground under a modal progress dialog (#6207); preferences that do nothing 25 → 24 of 169 |
diff --cc docs/scorecard.md
index f4580ec08,9fd35b7e2..af32a6209
--- a/docs/scorecard.md
+++ b/docs/scorecard.md
@@@ -9,8 -9,8 +9,8 @@@ Generated by `cargo xtask scorecard` fr
| [Performance](#performance) | 3 | 22 | 26 | 60 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 22 not run, 4 not measurable yet (baseline 2026-10-05) |
| [File compatibility](#file-compatibility) | 9 | 12 | 6 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 188/256, round trip ≥ 258/256 |
| [Tools](#tools) | 36 | 8 | 0 | |
- | [Workspace and UI](#workspace-and-ui) | 13 | 7 | 3 | settings that do nothing: 24 of 171 (target 0) |
+ | [Workspace and UI](#workspace-and-ui) | 14 | 6 | 3 | settings that do nothing: 24 of 171 (target 0) |
-| [Type](#type) | 5 | 3 | 1 | |
+| [Type](#type) | 5 | 4 | 1 | |
| [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) |
| [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 30 of 30 crates; panic_hunt present |
| [Distribution](#distribution) | 5 | 4 | 2 | |
@@@ -221,10 -221,9 +221,10 @@@ Unread: `general.color_picker`, `genera
| TYPE-218-4 | Variable font axis sliders from the font's axes; opsz follows the point size | done | [#218](https://github.com/storytold/photocraft/issues/218) | One slider per axis of the style's font in the Character section (Properties and Window > Character), setting type.setStyle variations; opsz follows the type size unless set (layout.rs variation_list); a style or weight resets the wght axis (#2985). PSD does not round-trip axis values yet |
| TYPE-218-5 | OpenType UI: Character panel buttons, Numerals and Stylistic Sets submenus | partial | [#218](https://github.com/storytold/photocraft/issues/218) | Type > OpenType toggles (type_extra_cmds.rs:512). Character panel (and the Properties Character section) has Photoshop's eight OpenType buttons: Standard Ligatures, Contextual Alternates, Discretionary Ligatures, Swash, Stylistic Alternates, Titling Alternates, Ordinals, Fractions, pressed while the feature is on at the selection and dispatching the type.openType.* commands (type_tool.rs opentype_row; character_panel_opentype_buttons_toggle_and_show_the_feature, #3752). Still missing: the Numerals and Stylistic Sets submenus, and greying out features the font lacks |
| TYPE-218-6 | Manual pair kerning (Alt+arrows), optical kerning rendered, both round-trip PSD (#206) | done | [#218](https://github.com/storytold/photocraft/issues/218) | Alt+Left/Right at a collapsed caret kerns the pair (type_tool.rs kern_pair, 20 per step and 100 with Cmd; type_tool_alt_arrows_kern_the_pair). Optical kerning is computed from the glyph outlines in text/src/optical.rs and applied by layout.rs when the run's mode is Optical (optical_matches_photoshop, optical_kerning_tightens_open_pairs). Both modes and manual values round-trip through PSD (io/tests/psd_kerning.rs; the optical mode travels in Txt2, txt2_carries_optical_kerning) |
- | TYPE-218-7 | Warp Text dialog previews live and opens with the layer's current warp | done | [#218](https://github.com/storytold/photocraft/issues/218) | Type > Warp Text opens with the shown layer's warp, or None, never remembered values (filter_dialog.rs warp_defaults; warp_text_dialog_tests.rs warp_text_opens_with_the_type_layers_current_warp, warp_text_opens_at_none_for_a_layer_without_warp, remembered_warp_values_never_override_the_layers_warp). The dialog previews live without editing the document, Cancel leaves no step and OK is one undoable step (warp_text_dialog_previews_the_warp_without_editing_the_document, cancelling_warp_text_leaves_the_document_and_history_untouched, confirming_warp_text_is_one_undoable_step); the reduced-proxy preview matches the full-size result (filter_dialog.rs warp_text_preview_matches_the_full_size_result_on_a_reduced_proxy) |
+ | TYPE-218-7 | Warp Text dialog previews live and opens with the layer's current warp | done | [#218](https://github.com/storytold/photocraft/issues/218) | Type > Warp Text opens with the shown layer's warp, or None, never remembered values (filter_dialog.rs:503 warp_defaults; warp_text_dialog_tests.rs:80 warp_text_opens_with_the_type_layers_current_warp, :99 warp_text_opens_at_none_for_a_layer_without_warp, :108 remembered_warp_values_never_override_the_layers_warp). The dialog previews live without editing the document, Cancel leaves no step and OK is one undoable step (:138 warp_text_dialog_previews_the_warp_without_editing_the_document, :160 cancelling_warp_text_leaves_the_document_and_history_untouched, :179 confirming_warp_text_is_one_undoable_step); the reduced-proxy preview matches the full-size result (filter_dialog.rs:2150 warp_text_preview_matches_the_full_size_result_on_a_reduced_proxy) |
| TYPE-218-8 | Text editing: select all, double/triple/quadruple-click selection, paste, with tests | done | [#218](https://github.com/storytold/photocraft/issues/218) | Like Photoshop, 2 clicks select the word, 3 the laid-out line (a column in vertical type), 4 the paragraph up to the hard return, 5 all text, and the next quick click starts over (#3493; type_tool.rs next_click_count, click_selection, multi_click). Tested through real canvas clicks in point, paragraph and vertical type, with paste replacing the selection and Cmd+A selecting all (type_tool_tests.rs multi_click_selects_word_line_paragraph_and_all_in_point_text, multi_click_separates_wrapped_lines_from_paragraphs, click_counts_cycle_and_restart, click_selection_without_layout_and_on_hostile_input, multi_click_without_a_session_does_nothing) |
| TYPE-218-9 | Distort/Perspective/Warp on live type as in Photoshop (was: offer 'Rasterize and continue?'; Photoshop doesn't prompt) | done | [#218](https://github.com/storytold/photocraft/issues/218) | Photoshop 2026 prompts for none of these: Edit › Transform › Warp on live type stays enabled with no rasterize prompt and offers only the warp styles (the mesh can't be dragged), so the type stays editable; Distort, Perspective and the split warps are greyed. PhotoCraft does the same: Warp on type commits the layer's Warp Text in one step (transform_tool.rs enter_type_warp, warp_cmds.rs warp_type_layer, #3004; warp_on_type_takes_a_style_and_keeps_the_type_editable), Distort/Perspective greyed (enable_rules.rs, #2701) |
+| TYPE-218-10 | Area type: Type tool click inside a closed path or shape wraps text inside it, holes and dents included, PSD round trip | partial | [#218](https://github.com/storytold/photocraft/issues/218) | TextShape::Area (doc text.rs) laid out line by line into the spans the path leaves (text area.rs, layout.rs break_area), type.fillPath (engine type_area_cmds.rs), released to box text by type.detachFromPath, area/path cursors and click-to-place (ui-egui type_tool.rs path_target), .pcraft round trip. Missing: PSD area type (saves as paragraph text over the path's bounds, with an export warning); mixed type sizes in one area paragraph space at its largest line; area type takes paths of at most 4096 anchors: beyond that a Type tool click makes point text (the pointer shows the plain I-beam), and type.fillPath refuses the path with "the path has too many anchor points" (type.attachToPath still takes a subpath of up to 100,000 anchors); a word too wide for every span in the shape overflows its span (box text breaks it at the edge, #6694); the first line starts about 0.24 em lower than in a text box of the same size; Photoshop area type in a PSD opens as box text; the area path has no handles to edit it after the type is placed |
## Automation
diff --cc docs/ui-parity.md
index e1e30399e,59d05d1e4..e8cae0ce2
--- a/docs/ui-parity.md
+++ b/docs/ui-parity.md
@@@ -1,6 -1,6 +1,6 @@@
# UI parity: tools, handles, modifiers and feel
- > **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-15 · **Change:** minor (a picked colour recolours the selected type and shapes; Animated Zoom: holding the Zoom tool zooms continuously, #6210; shape Density and Feather, TOOL-214-12, #5846; Pen Auto Add/Delete on the path being drawn, #6140; Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed; selection-modifier and ⌥-wheel rows match their tests) · **Target:** Adobe Photoshop 2026
-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-21 · **Change:** minor (Animated Zoom: holding the Zoom tool zooms continuously, #6210; shape Density and Feather, TOOL-214-12, #5846; Pen Auto Add/Delete on the path being drawn, #6140; Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed; selection-modifier and ⌥-wheel rows match their tests) · **Target:** Adobe Photoshop 2026
++> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-22 · **Change:** minor (a picked colour recolours the selected type and shapes; Animated Zoom: holding the Zoom tool zooms continuously, #6210; shape Density and Feather, TOOL-214-12, #5846; Pen Auto Add/Delete on the path being drawn, #6140; Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed; selection-modifier and ⌥-wheel rows match their tests) · **Target:** Adobe Photoshop 2026
How PhotoCraft's direct manipulation compares with Photoshop 2026 (27.11.0): the toolbox, the
handles and modifier keys of each gesture, nudging, snapping, numeric precision, navigation,