mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-24 23:50:13 +00:00
Proof Setup: filters in a CMYK document keep their ink channels
With a proof that preserves the colors' numbers, art drawn in screen colors in a CMYK document (an art brush's art) ran its filters on RGB channels, so Color Halftone screened lights instead of inks while the proof was on. The proofed screen ink now selects the same CMYK channels as the unproofed one.
This commit is contained in:
@@ -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<cms::ProofSetup>| {
|
||||
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]
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user