From ec816d76a59c6ad8b8c280eed98c19c156908111 Mon Sep 17 00:00:00 2001 From: Don Omondi <282319807+mockydevs@users.noreply.github.com> Date: Fri, 6 Nov 2026 21:30:40 -0500 Subject: [PATCH 1/3] EPS import: weigh an RGB document's layers blended as its CMYK page was An RGB Illustrator document saved as EPS with CMYK PostScript has its page in CMYK, its transparency flattened in the document's blending space (Edit > Transparency Blend Space), which the editing data doesn't name. Blended in CMYK, Color, Screen and other blend modes mix the inks, not the screen colours. The check of the layers against the page drew the RGB layers in screen colours only, so a user's file of balloons with Color and Screen blends differed from its page where nothing in the art does, and opened as its page with empty layers. The check now draws an RGB document with transparency both ways when its page is CMYK, and weighs it the way that draws it closer to the page. The document itself stays RGB. --- crates/eps/src/import/native/compare.rs | 138 ++++++++++++++++++++---- docs/file-format-parity.md | 3 +- 2 files changed, 122 insertions(+), 19 deletions(-) diff --git a/crates/eps/src/import/native/compare.rs b/crates/eps/src/import/native/compare.rs index 044dbd2401..0e3f389aed 100644 --- a/crates/eps/src/import/native/compare.rs +++ b/crates/eps/src/import/native/compare.rs @@ -1,9 +1,11 @@ use super::build::Frame; use super::slots::OUTLINE_REACH; use super::{Arc, Document, Node, NodeKind, Rect}; +use vectorcraft_doc::ColorMode; -/// `doc` with its layers that don't print hidden, when it has any. -fn as_printed(doc: &Document) -> Option { +/// `doc` as the page prints it, when that isn't `doc` as it is: its layers that don't print hidden, +/// and, with `cmyk`, in CMYK when it is an RGB document (see [`blends_in_cmyk`]). +fn as_printed(doc: &Document, cmyk: bool) -> Option { fn hide(nodes: &mut [Arc]) -> bool { let mut any = false; for n in nodes { @@ -19,7 +21,24 @@ fn as_printed(doc: &Document) -> Option { any } let mut d = doc.clone(); - hide(&mut d.layers).then_some(d) + let mut changed = hide(&mut d.layers); + if cmyk && d.color_mode == ColorMode::Rgb { + d.color_mode = ColorMode::Cmyk; + changed = true; + } + changed.then_some(d) +} + +/// Whether the layers of `doc` may print differently from the CMYK page `page` (`page_cmyk`) by +/// where their transparency was blended. An RGB document written as CMYK PostScript (the EPS option +/// that converts its colours for output, +/// https://helpx.adobe.com/illustrator/using/saving-artwork.html) has its page in the colours' CMYK +/// equivalents, its transparency flattened in the document's blending space (Edit › Transparency +/// Blend Space: Document RGB or Document CMYK), which the editing data doesn't name: blend modes +/// such as Color or Screen mix the inks in CMYK, not the screen colours. Art without transparency +/// prints alike either way. +fn blends_in_cmyk(page_cmyk: bool, doc: &Document) -> bool { + page_cmyk && doc.color_mode == ColorMode::Rgb && doc.layers.iter().any(|l| l.shows_transparency()) } /// A premultiplied pixel seen on white. @@ -326,6 +345,12 @@ pub(super) struct PageView { boards: Vec, sheets: Vec, samples: u32, + /// Whether the page is printed in CMYK ([`blends_in_cmyk`]). + cmyk: bool, + /// Whether the layers are drawn in CMYK to weigh them against the page: decided by the first + /// RGB document with transparency weighed, as the blending space that draws it closer to the + /// page. + in_cmyk: Option, layers: vectorcraft_render::Renderer, /// The drawings of the last [`KEPT_DOCUMENTS`] documents weighed, the last one weighed last (the /// import weighs two readings of a file back and forth). @@ -373,7 +398,19 @@ impl PageView { Page::on(frame.page, comparison_render(&mut renderer, frame.page, ra, scale, samples), ra, region, scale, moved) }) .collect(); - Self { pages, boards, sheets, samples, layers: vectorcraft_render::Renderer::new(), drawn: vec![], without: vec![], draws: 0 } + let cmyk = frame.page.color_mode == ColorMode::Cmyk; + Self { + pages, + boards, + sheets, + samples, + cmyk, + in_cmyk: None, + layers: vectorcraft_render::Renderer::new(), + drawn: vec![], + without: vec![], + draws: 0, + } } /// The areas in the layers' document that the pages are compared on: `rb` for the first page, @@ -453,8 +490,23 @@ impl PageView { return; } // The page doesn't print what isn't printed. - let printed = as_printed(b); - for (i, pixels) in self.draw(printed.as_ref().unwrap_or(b), &missing) { + let drawn = if self.in_cmyk.is_none() && blends_in_cmyk(self.cmyk, b) { + // Drawn both ways, the closer to the page decides. + let both = [false, true].map(|cmyk| { + let printed = as_printed(b, cmyk); + let drawn = self.draw(printed.as_ref().unwrap_or(b), &missing); + let off: f64 = drawn.iter().filter_map(|(i, d)| Some(compared(&self.pages.get(*i)?.drawn, d, &[], &[]).any)).sum(); + (off, cmyk, drawn) + }); + let [rgb, cmyk] = both; + let (_, chosen, drawn) = if cmyk.0 < rgb.0 { cmyk } else { rgb }; + self.in_cmyk = Some(chosen); + drawn + } else { + let printed = as_printed(b, self.in_cmyk == Some(true)); + self.draw(printed.as_ref().unwrap_or(b), &missing) + }; + for (i, pixels) in drawn { if let Some(slot) = self.drawn.last_mut().and_then(|d| d.pages.get_mut(i)) { *slot = Some(Layered { pixels, laid: None, reflowed: None, colour: None }); } @@ -466,7 +518,7 @@ impl PageView { pub(super) fn differences(&mut self, b: &Document, rb: Rect, reflow: bool) -> Vec { let all: Vec = (0..self.pages.len()).collect(); self.layered(b, &all); - let printed = as_printed(b); + let printed = as_printed(b, self.in_cmyk == Some(true)); let printed = printed.as_ref().unwrap_or(b); let mut out = vec![]; for i in all { @@ -506,7 +558,7 @@ impl PageView { pub(super) fn solid_regions_on_every_page(&mut self, b: &Document, reflow: bool) -> Option<(Difference, Vec)> { let all: Vec = (0..self.pages.len()).collect(); self.layered(b, &all); - let printed = as_printed(b); + let printed = as_printed(b, self.in_cmyk == Some(true)); let b = printed.as_ref().unwrap_or(b); let (mut diff, mut regions) = (Difference { any: 0.0, art: 0.0, solid: 0.0, typed: 0.0 }, vec![]); for (page, layered) in self.pages.iter().zip(&self.drawn.last()?.pages) { @@ -531,7 +583,7 @@ impl PageView { /// for [`Self::adopt`]. pub(super) fn weigh_without(&mut self, doc: &Document, without: &Document, on: &[usize]) -> Vec<(usize, f64, f64)> { self.layered(doc, on); - let printed = as_printed(without); + let printed = as_printed(without, self.in_cmyk == Some(true)); let drawn = self.draw(printed.as_ref().unwrap_or(without), on); let mut shares = vec![]; self.without.clear(); @@ -647,19 +699,27 @@ fn colour_share(x: &vectorcraft_render::Rendered, y: &vectorcraft_render::Render } /// How `a` on `ra` and `b` on `rb` (rectangles of the same size) draw differently ([`compared`]), -/// for a region other than the page's ([`PageView`] draws that one once). +/// for a region other than the page's ([`PageView`] draws that one once): `b` blended the way that +/// draws it closer to `a` ([`blends_in_cmyk`]). pub(super) fn difference(a: &Document, ra: Rect, b: &Document, rb: Rect) -> Difference { - let printed = as_printed(b); - let b = printed.as_ref().unwrap_or(b); let scale = compare_scale(ra); // A renderer each: the two documents' images can share their keys and not their pixels. let samples = comparison_samples(a); let x = comparison_render(&mut vectorcraft_render::Renderer::new(), a, ra, scale, samples); - let y = comparison_render(&mut vectorcraft_render::Renderer::new(), b, rb, scale, samples); - let mut areas = vec![]; - type_areas(&a.layers, ra, scale, &mut areas); - type_areas(&b.layers, rb, scale, &mut areas); - compared(&x, &y, &areas, &[]) + let ways: &[bool] = if blends_in_cmyk(a.color_mode == ColorMode::Cmyk, b) { &[false, true] } else { &[false] }; + // The way of blending that draws `b` closer to the page. + ways.iter() + .map(|cmyk| { + let printed = as_printed(b, *cmyk); + let b = printed.as_ref().unwrap_or(b); + let y = comparison_render(&mut vectorcraft_render::Renderer::new(), b, rb, scale, samples); + let mut areas = vec![]; + type_areas(&a.layers, ra, scale, &mut areas); + type_areas(&b.layers, rb, scale, &mut areas); + compared(&x, &y, &areas, &[]) + }) + .min_by(|p, q| p.any.total_cmp(&q.any)) + .unwrap_or(Difference::ALL) } /// How two drawings of the same size differ, each drawn on nothing and seen on white, away from @@ -879,7 +939,7 @@ const PAST_THE_PAGE: f64 = 1.0; pub(super) fn compare(frame: &Frame<'_>, view: &mut PageView, layered: &Document, type_reflow: bool) -> Result, String> { let mut diff = view.difference_on_every_page(layered, frame.rect, type_reflow); if frame.whole - && let Some(art) = vectorcraft_render::encode::art_bounds(as_printed(layered).as_ref().unwrap_or(layered)) + && let Some(art) = vectorcraft_render::encode::art_bounds(as_printed(layered, false).as_ref().unwrap_or(layered)) .filter(|a| !frame.rect.inflate(PAST_THE_PAGE, PAST_THE_PAGE).contains_rect(*a)) { // The page and the art the layers print beyond it, each in its own document's place. @@ -1084,4 +1144,46 @@ mod tests { } assert_eq!(view.draws, 2, "each document is drawn once"); } + + /// The page of an RGB document printed in CMYK has its transparency blended in either space: a + /// green screened over a grey of black ink alone leaves no ink when blended in CMYK, and shows a + /// light green when blended in screen colours. The layers are weighed blended the way that + /// draws them closer to the page, so they match either page. + #[test] + fn an_rgb_documents_blending_matches_its_page_printed_in_cmyk() { + use vectorcraft_doc::ColorMode; + let area = Rect::new(0.0, 0.0, 100.0, 100.0); + let page_with = |centre: vectorcraft_color::Color, blend: vectorcraft_color::BlendMode| { + let mut page = Document::new_with_mode(100.0, 100.0, ColorMode::Cmyk); + let layer = page.layers[0].id; + filled(&mut page, layer, area, 0.6); + let paint = vectorcraft_color::Paint::solid(centre); + let mut n = Node::path( + page.alloc_id(), + vectorcraft_geom::shapes::rectangle(Rect::new(20.0, 20.0, 80.0, 80.0)), + vectorcraft_doc::Appearance::basic(paint, vectorcraft_color::Paint::None, 0.0), + ); + n.blend = blend; + page.insert(Some(layer), usize::MAX, n).unwrap(); + page + }; + let screened = page_with(vectorcraft_color::Color::cmyk(1.0, 0.0, 1.0, 0.0), vectorcraft_color::BlendMode::Screen); + let mut layers = screened.clone(); + layers.color_mode = ColorMode::Rgb; + // Blended in screen colours, the centre is a light green. + let shown = |d: &Document| comparison_render(&mut vectorcraft_render::Renderer::new(), d, area, compare_scale(area), 1); + let rgb = shown(&layers); + let at = (rgb.height as usize / 2 * rgb.width as usize + rgb.width as usize / 2) * 4; + let [r, g, b] = [0, 1, 2].map(|k| f32::from(rgb.pixels[at + k]) / 255.0); + assert!(compared(&shown(&screened), &rgb, &[], &[]).any > 0.3); + // A page blended in CMYK, and one blended in screen colours (its centre painted that green). + let in_rgb = page_with(vectorcraft_color::Color::rgb(r, g, b), vectorcraft_color::BlendMode::Normal); + for (page, cmyk) in [(&screened, true), (&in_rgb, false)] { + assert!(difference(page, area, &layers, area).any < 0.001, "cmyk: {cmyk}"); + let frame = frame_of(page, &[area]); + let mut view = PageView::new(&frame); + assert_eq!(compare(&frame, &mut view, &layers, false), Ok(vec![]), "cmyk: {cmyk}"); + assert_eq!(view.in_cmyk, Some(cmyk)); + } + } } diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index f60d46f622..4aa442bc09 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -1,6 +1,6 @@ # File format parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-06 · **Change:** minor (EPS and `.ai` editing data: a transparency set inside a clipping group stays after its `Q`; SVG import: filter and mask regions clip, #5876, #5875; SVG import: Gaussian blurs keep `color-interpolation-filters`, #5877; PDF and `.ai` export: objects' URLs as links, #5785; SVG import: `color-interpolation="linearRGB"` gradients, #5878; `.ai` import: paths with a Calligraphic brush open brushed, #372) · **Target:** Adobe Illustrator 2026 (30.x) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-06 · **Change:** minor (EPS import: the layers of an RGB document whose page is in CMYK are weighed blended in RGB or CMYK, whichever matches the page; EPS and `.ai` editing data: a transparency set inside a clipping group stays after its `Q`; SVG import: filter and mask regions clip, #5876, #5875; SVG import: Gaussian blurs keep `color-interpolation-filters`, #5877; PDF and `.ai` export: objects' URLs as links, #5785; SVG import: `color-interpolation="linearRGB"` gradients, #5878; `.ai` import: paths with a Calligraphic brush open brushed, #372) · **Target:** Adobe Illustrator 2026 (30.x) Every format Illustrator opens, places, saves or exports, against VectorCraft's format table (`FORMATS`, `OPEN_EXTS`, `PLACE_EXTS` in `crates/engine/src/cmd/fileio/formats.rs`). Illustrator's list comes from its public @@ -212,6 +212,7 @@ the app's own editing copy of a file (an EPS after its `%%EOF`, a `.ai`'s `AIPri | Date | Change | Summary | |---|---|---| +| 2026-11-06 | minor | EPS import: an RGB document saved as EPS with its page in CMYK (the CMYK PostScript option, https://helpx.adobe.com/illustrator/using/saving-artwork.html) has its transparency flattened in the document's blending space (Edit › Transparency Blend Space: Document RGB or Document CMYK), which the editing data doesn't name; blended in CMYK, Color, Screen and other blend modes mix the inks, not the screen colours. The check of the layers against the page now draws an RGB document with transparency both ways and weighs it the way that draws it closer to the page, so blends no longer count as art that differs. A user's Illustrator 24 EPS of balloons with Color and Screen blends (used locally, not committed) now opens from its layers instead of its page with empty layers. The document stays RGB. Test `import::native::compare::tests::an_rgb_documents_blending_matches_its_page_printed_in_cmyk` (crate `vectorcraft-eps`); scores unchanged | | 2026-11-06 | minor | EPS and `.ai` editing data: `Q` restores the painting state but not the transparency (`Xy`), which the writer only sets when the next object's differs from the last one written. A Screen glow followed by a clipping group set back to Normal no longer leaves the type after the group in Screen: two users' Illustrator 26.5 and 30 EPS posters (used locally, not committed) now show their gold heading and crescent, and both open from their layers (2.5% and 2.7% from the page before, under the limit after). Scores and estimates unchanged. | | 2026-11-06 | minor | EPS and `.ai` editing data: a blend whose spine was never edited, written with its keys and no spine part, comes in as a live blend along the straight lines between its keys' centres (in its record's order) instead of as its drawn steps. Checked on six users' Illustrator EPS files (used locally, not committed): every blend in four of them now comes in live, their renders unchanged; two still have blends the reader can't match to their drawn steps. Scores and estimates unchanged. | | 2026-11-06 | minor | EPS and `.ai` editing data: the art styles are found before the art is read, so objects in symbols defined ahead of `%AI9_BeginArtStyles` (as Illustrator 24 writes it) come in as themselves with their style instead of their drawn look. Checked on two users' EPS files (used locally, not committed): one's Symbols panel gains live Feather and Round Corners, its drawn-look count drops from 5 to 2, and both render unchanged; own-fixture test in `import::ai::tests`; scores and hours unchanged | From 9d788b400f851bd9873017fde26725bcaa26491e Mon Sep 17 00:00:00 2001 From: Don Omondi <282319807+mockydevs@users.noreply.github.com> Date: Sat, 7 Nov 2026 11:02:45 -0500 Subject: [PATCH 2/3] EPS import: an RGB document's blending space is chosen from every page The first weighing of an RGB document with transparency against its CMYK pages chose RGB or CMYK blending from the pages it was asked for, which a check of one object can make a few: later weighings of all the pages kept that choice. The choice is now made with the layers drawn both ways on every page, and all those drawings are kept. --- crates/eps/src/import/native/compare.rs | 34 +++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/crates/eps/src/import/native/compare.rs b/crates/eps/src/import/native/compare.rs index 0e3f389aed..4c8b9bfcc0 100644 --- a/crates/eps/src/import/native/compare.rs +++ b/crates/eps/src/import/native/compare.rs @@ -491,10 +491,12 @@ impl PageView { } // The page doesn't print what isn't printed. let drawn = if self.in_cmyk.is_none() && blends_in_cmyk(self.cmyk, b) { - // Drawn both ways, the closer to the page decides. + // Drawn both ways on every page (not only those wanted, which may not show the + // difference), the closer to the pages decides; the drawings of all of them are kept. + let every: Vec = (0..n).collect(); let both = [false, true].map(|cmyk| { let printed = as_printed(b, cmyk); - let drawn = self.draw(printed.as_ref().unwrap_or(b), &missing); + let drawn = self.draw(printed.as_ref().unwrap_or(b), &every); let off: f64 = drawn.iter().filter_map(|(i, d)| Some(compared(&self.pages.get(*i)?.drawn, d, &[], &[]).any)).sum(); (off, cmyk, drawn) }); @@ -1186,4 +1188,32 @@ mod tests { assert_eq!(view.in_cmyk, Some(cmyk)); } } + + /// The blending space is chosen from every page, also when the first pages drawn are only + /// some of them: here the first page has no transparency, and the second is blended in CMYK. + #[test] + fn the_blending_space_is_chosen_from_every_page() { + use vectorcraft_doc::ColorMode; + let (a, b) = (Rect::new(0.0, 0.0, 100.0, 100.0), Rect::new(200.0, 0.0, 300.0, 100.0)); + let mut page = Document::new_with_mode(300.0, 100.0, ColorMode::Cmyk); + let layer = page.layers[0].id; + filled(&mut page, layer, a, 0.6); + filled(&mut page, layer, b, 0.6); + let paint = vectorcraft_color::Paint::solid(vectorcraft_color::Color::cmyk(1.0, 0.0, 1.0, 0.0)); + let mut n = Node::path( + page.alloc_id(), + vectorcraft_geom::shapes::rectangle(Rect::new(220.0, 20.0, 280.0, 80.0)), + vectorcraft_doc::Appearance::basic(paint, vectorcraft_color::Paint::None, 0.0), + ); + n.blend = vectorcraft_color::BlendMode::Screen; + page.insert(Some(layer), usize::MAX, n).unwrap(); + let mut layers = page.clone(); + layers.color_mode = ColorMode::Rgb; + let frame = frame_of(&page, &[a, b]); + let mut view = PageView::new(&frame); + view.layered(&layers, &[0]); + assert_eq!(view.in_cmyk, Some(true)); + // Both pages were drawn, and kept. + assert!(view.drawn.last().is_some_and(|d| d.pages.iter().all(Option::is_some))); + } } From 00690a37d995f3882002a2d6e4653df085c0c718 Mon Sep 17 00:00:00 2001 From: Don Omondi <282319807+mockydevs@users.noreply.github.com> Date: Sun, 8 Nov 2026 04:14:28 -0500 Subject: [PATCH 3/3] EPS import: test the blending space end to end, its draw count and when it isn't weighed The test that picks the space from every page now also checks the layers match the pages; a new test pins that only an RGB document with transparency on a CMYK page is drawn both ways, once, and that later documents and the other cases are drawn once. --- crates/eps/src/import/native/compare.rs | 70 ++++++++++++++++++++++--- 1 file changed, 63 insertions(+), 7 deletions(-) diff --git a/crates/eps/src/import/native/compare.rs b/crates/eps/src/import/native/compare.rs index 4c8b9bfcc0..d0103e49d0 100644 --- a/crates/eps/src/import/native/compare.rs +++ b/crates/eps/src/import/native/compare.rs @@ -1189,13 +1189,11 @@ mod tests { } } - /// The blending space is chosen from every page, also when the first pages drawn are only - /// some of them: here the first page has no transparency, and the second is blended in CMYK. - #[test] - fn the_blending_space_is_chosen_from_every_page() { - use vectorcraft_doc::ColorMode; + /// Two pages in a document of `mode`, a grey on each; the second has a green over its grey, + /// blended Screen when `screened`, else Normal. Their areas are returned too. + fn two_pages(mode: vectorcraft_doc::ColorMode, screened: bool) -> (Document, [Rect; 2]) { let (a, b) = (Rect::new(0.0, 0.0, 100.0, 100.0), Rect::new(200.0, 0.0, 300.0, 100.0)); - let mut page = Document::new_with_mode(300.0, 100.0, ColorMode::Cmyk); + let mut page = Document::new_with_mode(300.0, 100.0, mode); let layer = page.layers[0].id; filled(&mut page, layer, a, 0.6); filled(&mut page, layer, b, 0.6); @@ -1205,8 +1203,20 @@ mod tests { vectorcraft_geom::shapes::rectangle(Rect::new(220.0, 20.0, 280.0, 80.0)), vectorcraft_doc::Appearance::basic(paint, vectorcraft_color::Paint::None, 0.0), ); - n.blend = vectorcraft_color::BlendMode::Screen; + if screened { + n.blend = vectorcraft_color::BlendMode::Screen; + } page.insert(Some(layer), usize::MAX, n).unwrap(); + (page, [a, b]) + } + + /// The blending space is chosen from every page, also when the first pages drawn are only + /// some of them: here the first page has no transparency, and the second is blended in CMYK. + /// The layers then match the pages. + #[test] + fn the_blending_space_is_chosen_from_every_page() { + use vectorcraft_doc::ColorMode; + let (page, [a, b]) = two_pages(ColorMode::Cmyk, true); let mut layers = page.clone(); layers.color_mode = ColorMode::Rgb; let frame = frame_of(&page, &[a, b]); @@ -1215,5 +1225,51 @@ mod tests { assert_eq!(view.in_cmyk, Some(true)); // Both pages were drawn, and kept. assert!(view.drawn.last().is_some_and(|d| d.pages.iter().all(Option::is_some))); + assert!(view.differences(&layers, a, false).iter().all(|d| d.any < 0.001)); + assert_eq!(compare(&frame, &mut view, &layers, false), Ok(vec![])); + } + + /// Only an RGB document with transparency, weighed against a CMYK page, is drawn both ways, and + /// only until the way is chosen: later documents are drawn once, in that way. An RGB document + /// without transparency, a CMYK document, and an RGB page are drawn once, as they are. + #[test] + fn only_an_rgb_document_with_transparency_on_a_cmyk_page_is_drawn_both_ways() { + use vectorcraft_doc::ColorMode; + // The draws of weighing `layers` (as RGB or not) on `page`, then of a second document, and + // the way chosen. + let weigh = |page: &Document, areas: [Rect; 2], layers: &Document, rgb: bool| { + let mut layers = layers.clone(); + if rgb { + layers.color_mode = ColorMode::Rgb; + } + let frame = frame_of(page, &areas); + let mut view = PageView::new(&frame); + view.layered(&layers, &[0, 1]); + let first = view.draws; + // The same document again draws nothing; another one is drawn once. + view.layered(&layers, &[0, 1]); + assert_eq!(view.draws, first); + let mut other = layers.clone(); + let layer = other.layers[0].id; + filled(&mut other, layer, Rect::new(10.0, 10.0, 20.0, 20.0), 1.0); + view.layered(&other, &[0, 1]); + (first, view.draws - first, view.in_cmyk) + }; + let (cmyk_page, areas) = two_pages(ColorMode::Cmyk, true); + let (both, then, chosen) = weigh(&cmyk_page, areas, &cmyk_page, true); + assert_eq!(chosen, Some(true)); + assert!(then > 0); + assert_eq!(both, 2 * then, "drawn both ways once, then one way"); + let (plain_page, _) = two_pages(ColorMode::Cmyk, false); + let (rgb_page, _) = two_pages(ColorMode::Rgb, true); + for (what, page, layers, rgb) in [ + ("an RGB document without transparency", &plain_page, &plain_page, true), + ("a CMYK document", &cmyk_page, &cmyk_page, false), + ("an RGB page", &rgb_page, &rgb_page, false), + ] { + let (first, second, chosen) = weigh(page, areas, layers, rgb); + assert_eq!(chosen, None, "{what}"); + assert_eq!((first, second), (then, then), "{what} is drawn once"); + } } }