mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-25 04:33:43 +00:00
Images: Overprint Fill makes a colorized image's color overprint
A grayscale or 1-bit image colorized with a fill color had no way to
overprint: object.setOverprint {fill: true} changed nothing, since an
image has no fill row. The color now carries its own overprint flag
(colorize_overprint in native files).
- object.setOverprint (fill, without item) and attributes.info set and
read it; Overprint Black and Print Ink Fixes' Remove White Overprint
treat the color as the image's fill.
- Overprint Preview, Separations Preview and printed separations show
the inks below the image where its color has none; on a plate the
color puts no ink on, the image is left out.
- PDF export draws the image in an overprinting graphics state, a
process color as an image of only the process inks it puts down.
- EPS export turns overprinting on for it, and now leaves white fills,
strokes and colorized images knocking out with Discard White
Overprint, as PDF export does.
- A legacy .ai file writes it as the image mask's fill overprint and
reads it back. Warped pieces, geometry-effect copies and flattening
keep or drop it as they do for fills.
- A white spot color is an ink: with Discard White Overprint it keeps
overprinting in PDF and EPS export and in both previews.
Docs: docs/mcp.md (Overprint, Print Ink Fixes), docs/target-app-parity.md.
This commit is contained in:
@@ -34,7 +34,7 @@ pub use vectorcraft_color::cms::{Intent, ProofSetup, ProofTarget};
|
||||
use vectorcraft_color::{Color, Paint, Swatch, SwatchGroup};
|
||||
pub use vectorcraft_doc::inks::{Inks, Link, Plate, inks, map_document_colors, map_node_colors, plates, spot_color};
|
||||
use vectorcraft_doc::inks::{StopPlates, map_node_inks, stop_inks};
|
||||
use vectorcraft_doc::overprint::darken_overprints;
|
||||
use vectorcraft_doc::overprint::{DiscardWhite, darken_overprints};
|
||||
use vectorcraft_doc::{AppearanceItem, Document, ImageBlob, Node, NodeId, Shared};
|
||||
use vello_cpu::Pixmap;
|
||||
use vello_cpu::color::PremulRgba8;
|
||||
@@ -398,7 +398,7 @@ pub(crate) struct Prepared {
|
||||
/// What [`prepare`] reads besides the art.
|
||||
#[derive(PartialEq)]
|
||||
struct Inputs {
|
||||
discard_white: bool,
|
||||
discard_white: DiscardWhite,
|
||||
plates: Option<Plates>,
|
||||
}
|
||||
|
||||
@@ -429,21 +429,21 @@ impl PartialEq for Plates {
|
||||
/// print it ([`plate_color`]).
|
||||
struct How<'a> {
|
||||
doc: &'a Document,
|
||||
discard_white: bool,
|
||||
discard_white: DiscardWhite,
|
||||
/// Separations Preview: the color settings, the proof setup and the visible plates.
|
||||
plates: Option<(&'a Cms, &'a ProofSetup, &'a [String])>,
|
||||
}
|
||||
|
||||
impl How<'_> {
|
||||
/// Whether [`Self::apply`] can change `n`: with Separations Preview any node, else a node with
|
||||
/// an overprinting fill or stroke.
|
||||
/// an overprinting fill or stroke, or a colorized image whose color overprints.
|
||||
fn changes(&self, n: &Node) -> bool {
|
||||
self.plates.is_some() || n.appearance.items.iter().any(|i| i.overprint())
|
||||
self.plates.is_some() || n.appearance.items.iter().any(|i| i.overprint()) || n.colorize_overprints()
|
||||
}
|
||||
|
||||
/// Change the fills, strokes and other colors of node `a`, which holds no members.
|
||||
fn apply(&self, a: &mut Arc<Node>) {
|
||||
darken_overprints(a, self.discard_white);
|
||||
darken_overprints(a, &self.discard_white);
|
||||
if let Some((c, proof, visible)) = self.plates {
|
||||
map_node_inks(Arc::make_mut(a), &mut |col, sw, plates| plate_color(self.doc, c, proof, visible, col, sw, plates));
|
||||
}
|
||||
@@ -462,7 +462,7 @@ pub(crate) fn prepare<'a>(doc: &'a Document, opts: &RenderOptions, kept: &mut Op
|
||||
let seps = opts.proof.as_ref().and_then(|p| p.separations.as_ref().map(|s| (p, s)));
|
||||
let c = cms::active();
|
||||
let inputs = Inputs {
|
||||
discard_white: doc.setup.discard_white_overprint,
|
||||
discard_white: DiscardWhite::of(doc),
|
||||
plates: seps.map(|(proof, _)| Plates {
|
||||
proof: proof.clone(),
|
||||
swatches: doc.swatches.clone(),
|
||||
@@ -473,7 +473,7 @@ pub(crate) fn prepare<'a>(doc: &'a Document, opts: &RenderOptions, kept: &mut Op
|
||||
}),
|
||||
};
|
||||
let earlier = kept.take().filter(|k| k.inputs == inputs);
|
||||
let how = How { doc, discard_white: inputs.discard_white, plates: seps.map(|(proof, visible)| (&*c, proof, visible.as_slice())) };
|
||||
let how = How { doc, discard_white: inputs.discard_white.clone(), plates: seps.map(|(proof, visible)| (&*c, proof, visible.as_slice())) };
|
||||
let none = (vec![], vec![]);
|
||||
let (layers, art) = earlier.as_ref().map_or((&none, &none), |k| (&k.layers, &k.art));
|
||||
let made_layers = prepare_list(&doc.layers, &layers.0, &layers.1, &how);
|
||||
|
||||
@@ -318,6 +318,46 @@ fn separations_preview_shows_the_image_on_its_spot_plate() {
|
||||
assert!(off[..3].iter().all(|v| *v >= 250), "the process plates show paper, got {off:?}");
|
||||
}
|
||||
|
||||
/// A spot-colorized image over a cyan square knocks the cyan out where it is dark, unless its
|
||||
/// color overprints: then Separations Preview's Cyan plate keeps the square under it, its Ink
|
||||
/// plate still shows the image, and Overprint Preview darkens the two together.
|
||||
#[test]
|
||||
fn an_overprinting_colorized_image_keeps_the_ink_below_in_the_previews() {
|
||||
let ink = Color::cmyk(0.0, 1.0, 1.0, 0.0);
|
||||
let shown = |overprint: bool, plates: Option<&[&str]>| {
|
||||
let mut d = Document::new_with_mode(40.0, 20.0, vectorcraft_doc::ColorMode::Cmyk);
|
||||
d.swatches.push(vectorcraft_color::Swatch { name: "Ink".into(), paint: Paint::solid(ink), global: true, spot: true });
|
||||
let square = Node::path(
|
||||
d.alloc_id(),
|
||||
shapes::rectangle(Rect::new(0.0, 0.0, 40.0, 20.0)),
|
||||
Appearance::basic(Paint::solid(Color::cmyk(1.0, 0.0, 0.0, 0.0)), Paint::None, 0.0),
|
||||
);
|
||||
d.insert(Some(d.layers[0].id), 0, square).unwrap();
|
||||
d.images.insert("pic".into(), ImageBlob::new("image/png", gray_png()));
|
||||
let im =
|
||||
ImageObject { key: "pic".into(), width: 2, height: 1, xf: Affine::scale(20.0), link: None, placement: Default::default(), pixels: None };
|
||||
let mut n = Node::new(d.alloc_id(), NodeKind::Image(Box::new(im)));
|
||||
n.extras_mut().colorize = Some(Box::new(Paint::Solid { color: ink, swatch: Some("Ink".into()), tint: 1.0 }));
|
||||
n.extras_mut().colorize_overprint = overprint;
|
||||
d.insert(Some(d.layers[0].id), 1, n).unwrap();
|
||||
let opts = match plates {
|
||||
Some(plates) => separations(plates),
|
||||
None => RenderOptions { overprint_preview: true, smooth_images: false, ..Default::default() },
|
||||
};
|
||||
Renderer::new().render(&d, 40, 20, Affine::IDENTITY, &opts).pixel(10, 10)
|
||||
};
|
||||
let knocked = shown(false, Some(&["Cyan"]));
|
||||
assert!(knocked[..3].iter().all(|v| *v >= 250), "knocking out, the Cyan plate is paper under the image, got {knocked:?}");
|
||||
let kept = shown(true, Some(&["Cyan"]));
|
||||
assert!(kept[..3].iter().all(|v| *v < 128), "overprinting, the Cyan plate keeps the square, got {kept:?}");
|
||||
let on = shown(true, Some(&["Ink"]));
|
||||
assert!(on[..3].iter().all(|v| *v < 128), "the Ink plate shows the image, got {on:?}");
|
||||
// Overprint Preview alone: the red ink over cyan darkens to near black where it knocked out
|
||||
// to red.
|
||||
let (red, dark) = (shown(false, None), shown(true, None));
|
||||
assert!(red[0] > 128 && dark[0] < 128, "knocking out {red:?}, overprinting {dark:?}");
|
||||
}
|
||||
|
||||
/// Separations Preview shows an image placed from a DCS file through its own plates: its spot
|
||||
/// plate on that ink's plate only, its cyan plate on the cyan plate only. Without the preview it
|
||||
/// shows its composite, the spot ink mixed in.
|
||||
|
||||
Reference in New Issue
Block a user