mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-30 12:47:13 -06:00
Part of #3235: PDF import keeps the spot swatch of an ink a shading paints only between its stops
An axial or radial shading's stops are the samples that linear interpolation does not reproduce. An ink that changes nothing in RGB, such as a varnish, could paint at dropped samples only, and its spot swatch was then missing. Every sample now marks the inks it paints with as used; the stops are unchanged.
This commit is contained in:
@@ -187,6 +187,25 @@ fn a_spot_ink_mixed_with_a_process_plate_keeps_its_swatch() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_spot_ink_only_between_a_shadings_stops_keeps_its_swatch() {
|
||||
// Varnish and Cyan → CMYK (cyan, 0, 0, 0): Varnish draws nothing, so the shading's RGB is one
|
||||
// colour and only its ends (Varnish 0) become stops; Varnish rises to 1 at the middle.
|
||||
let space = format!("[/DeviceN [/Varnish /Cyan] /DeviceCMYK {} 0 R]", first_extra(1));
|
||||
let func = "<< /FunctionType 4 /Domain [0 1 0 1] /Range [0 1 0 1 0 1 0 1] /Length 18 >>\nstream\n{ exch pop 0 0 0 }\nendstream";
|
||||
let half = |a: u8, b: u8| format!("<< /FunctionType 2 /Domain [0 1] /C0 [{a} 0.3] /C1 [{b} 0.3] /N 1 >>");
|
||||
let shading = format!(
|
||||
"<< /ShadingType 2 /ColorSpace {space} /Coords [0 0 50 0] /Function << /FunctionType 3 /Domain [0 1] /Functions [{} {}] /Bounds [0.5] /Encode [0 1 0 1] >> /Extend [true true] >>",
|
||||
half(0, 1),
|
||||
half(1, 0)
|
||||
);
|
||||
let page = PdfPage { resources: format!("/Shading << /Sh0 {shading} >>"), ..PdfPage::new(100.0, 50.0, "q 0 0 50 50 re W n /Sh0 sh Q") };
|
||||
let r = import_with_report(&pdf_with(&[page], &[func], None), &ImportOptions::default()).unwrap();
|
||||
let d = &r.document;
|
||||
let varnish = d.swatch("Varnish").unwrap_or_else(|| panic!("no Varnish swatch: {:?}", d.swatches));
|
||||
assert!(varnish.spot && varnish.global, "{varnish:?}");
|
||||
}
|
||||
|
||||
/// The spaces `/CS1` and `/CS2` of two inks (`[/{kind} {a} …]`, `[/{kind} {b} …]`) with the same
|
||||
/// alternate and tint transform, blue at 100 %: they look the same to the interpreter.
|
||||
fn blues(kind: &str, a: &str, b: &str) -> String {
|
||||
|
||||
Reference in New Issue
Block a user