diff --git a/crates/render/src/brush_fx.rs b/crates/render/src/brush_fx.rs index 64de9e4d3e..1660ae6caa 100644 --- a/crates/render/src/brush_fx.rs +++ b/crates/render/src/brush_fx.rs @@ -348,6 +348,37 @@ mod tests { } } + /// A proof that preserves the colors' numbers keeps the channels a CMYK document's filters run + /// on: an art brush's Color Halftone screens ink channels with the proof on, as with it off. + #[test] + fn a_proof_that_preserves_numbers_keeps_cmyk_filter_channels() { + use vectorcraft_brush::{ArtBrush, ArtScale, Brush, BrushKind, Colorization}; + use vectorcraft_color::cms; + + let mut d = doc_with_line(Some("Halftone art"), 40.0); + d.color_mode = vectorcraft_doc::ColorMode::Cmyk; + let grey = Color::cmyk(0.3, 0.3, 0.3, 0.2); + let mut art = + Node::path(d.alloc_id(), shapes::rectangle(Rect::new(0.0, -10.0, 10.0, 10.0)), Appearance::basic(Paint::solid(grey), Paint::None, 0.0)); + art.appearance.effects = + vec![vectorcraft_doc::Effect { id: "pixelate.colorHalftone".into(), params: serde_json::json!({"maxRadius": 4}), visible: true }]; + let brush = Brush { + name: "Halftone art".into(), + kind: BrushKind::Art(ArtBrush { art, scale: ArtScale::Stretch, colorization: Colorization::None, ..Default::default() }), + }; + vectorcraft_brush::store(&mut d, &[brush]); + let shown = |proof: Option| { + let opts = RenderOptions { proof, background: Some([255, 255, 255, 255]), ..Default::default() }; + Renderer::new().render(&d, 200, 100, Affine::IDENTITY, &opts).pixels + }; + let plain = shown(None); + assert!(plain.chunks(4).any(|p| p[..3] != [255, 255, 255]), "the brush draws"); + // The working CMYK space proofed from its own numbers shows the colors as they are shown. + let proofed = shown(Some(cms::ProofSetup { target: cms::ProofTarget::WorkingCmyk, preserve_numbers: true, ..Default::default() })); + let differ = plain.chunks(4).zip(proofed.chunks(4)).filter(|(a, b)| a.iter().zip(b.iter()).any(|(x, y)| x.abs_diff(*y) > 8)).count(); + assert!(differ * 100 < plain.len() / 4, "{differ} of {} pixels differ", plain.len() / 4); + } + /// Object opacity fades a brushed stroke's art as a whole, with or without a dash and a fill: /// the same as the object at full opacity inside a group at that opacity. #[test] diff --git a/crates/render/src/fx/pixels.rs b/crates/render/src/fx/pixels.rs index f4a441f3cb..f100478138 100644 --- a/crates/render/src/fx/pixels.rs +++ b/crates/render/src/fx/pixels.rs @@ -122,7 +122,7 @@ impl Renderer { let channels = match f.ink.base() { Ink::Cmy => effects::pixel::Channels::CmyPlane, Ink::K => effects::pixel::Channels::KPlane, - Ink::Display | Ink::RichBlack if f.doc.color_mode == vectorcraft_doc::ColorMode::Cmyk => effects::pixel::Channels::Cmyk, + Ink::Display | Ink::RichBlack | Ink::Proofed(_) if f.doc.color_mode == vectorcraft_doc::ColorMode::Cmyk => effects::pixel::Channels::Cmyk, _ => effects::pixel::Channels::Rgb, }; // What the content reads (as the raster kept for it found it, else found now), with the