PICT: warn when a brushed stroke's blending mode is left out

Scene::stroke returned from the brush branch before it checked the stroke's
blending mode, so a brushed stroke with Multiply lost its blend in WMF, EMF
and PICT output without the blending warning. The check now runs first.

docs/mcp.md: name the output files for one and several artboards, the
visible-art frame limit, and when oversized fills are split or thinned.
docs/control-protocol.md: Open and Place also read .pct, .pic and .pict.
This commit is contained in:
dotCooCoo committed 2026-12-05 16:08:31 -08:00
1 parent d69995131f
commit 78a6c7460d
4 files changed
+35 -8

No files matched your search

+3 -3
View File
@@ -483,6 +483,9 @@ impl<'a> Scene<'a> {
}
fn stroke(&mut self, bp: &BezPath, rule: FillRule, st: &StrokeLayer, bounds: Rect) {
if st.blend != BlendMode::Normal {
self.warn(BLENDING);
}
if st.brush.is_some()
&& self.nest < MAX_NEST
&& let Some(art) = self.brush_art(bp, st)
@@ -495,9 +498,6 @@ impl<'a> Scene<'a> {
self.opacity = opacity;
return;
}
if st.blend != BlendMode::Normal {
self.warn(BLENDING);
}
// A pen paints one colour along the path itself: anything else is the stroke's outline,
// filled.
let flat_paint = matches!(st.paint, Paint::Solid { .. }) || !self.clips;
+24
View File
@@ -295,6 +295,30 @@ fn turned_and_translucent_images_are_reported() {
assert!(pict(&d).warnings.iter().any(|w| w.contains("quarter turns")));
}
#[test]
fn a_brushed_stroke_reports_its_blending_mode() {
let mut bp = BezPath::new();
bp.move_to((10.0, 50.0));
bp.line_to((90.0, 50.0));
let plain = path(PathData::from_bezpath(&bp), Paint::None, blue(), 3.0);
let mut line = plain.clone();
if let Some(s) = line.appearance.stroke_mut() {
s.brush = Some("3 pt. Round".into());
s.blend = vectorcraft_color::BlendMode::Multiply;
}
let out = pict(&doc_with(100.0, 100.0, vec![line]));
assert!(!fills(&read(&out)).is_empty(), "the brush's art is written");
// A brush that doesn't resolve falls back to the stroke's outline.
let mut unresolved = plain;
if let Some(s) = unresolved.appearance.stroke_mut() {
s.brush = Some("missing".into());
s.blend = vectorcraft_color::BlendMode::Multiply;
}
let fallback = pict(&doc_with(100.0, 100.0, vec![unresolved]));
assert_ne!(out.bytes, fallback.bytes, "the brush resolves, so its art is written rather than the fallback outline");
assert!(out.warnings.iter().any(|w| w.contains("blending modes are left out")), "{:?}", out.warnings);
}
#[test]
fn large_images_are_written_in_tiles() {
let (w, h) = (1500usize, 3usize);
+1 -1
View File
@@ -993,7 +993,7 @@ preset's name, the level as a number), and a value none of them names shows as i
EMF, WMF and PICT: Export As… lists the three formats (`file.exportAs {format: "emf"}`, `"wmf"` or `"pict"`); they
have no options dialog, so `ui.dialog.confirm` asks for the path and writes the file (one per artboard with Use
Artboards). Open and Place read `.emf` and `.wmf`; a paste of `image/emf` from a system clipboard service runs
Artboards). Open and Place read `.emf`, `.wmf`, `.pct`, `.pic` and `.pict`; a paste of `image/emf` from a system clipboard service runs
`clipboard.importEmf`.
HP-GL Options: Export As… with the HP-GL format (`file.exportAs {format: "hpgl"}`, then the save dialog), or
+7 -4
View File
@@ -13700,8 +13700,10 @@ draws nothing VectorCraft reads opens empty with a warning. A file that holds no
`document.export` (and `export`) with format `pict`, or a path ending in `.pct`, `.pic` or `.pict`, writes a QuickDraw
version 2 picture of the first artboard (or `artboard`): 512 bytes of application data, then the picture. Export As
offers it as PICT with the `.pct` extension. `useArtboards: true` writes one file per chosen artboard (`{stem}-{artboard}.pct`), `false` the bounds of the
visible art. The picture's frame is the artboard in points, at most 32,767 points on a side (a larger artboard is
offers it as PICT with the `.pct` extension. `useArtboards: true` writes one file per chosen artboard. With a `path`, one
chosen artboard goes to the path as given, and several go beside it as `{stem}-{artboard}{ext}`, keeping the path's extension
(`.pct`, `.pic` or `.pict`). `false` writes the bounds of the visible art. The picture's frame is the artboard, or with
`useArtboards: false` the visible art's bounds, in points, at most 32,767 points on a side (a larger frame is
refused). The drawing uses the extended version 2 header at up to 16 device units a point (1,152 dpi), as many as keep
the frame within 16-bit coordinates. The writer follows the opcodes and data layouts of Apple's
[Opcodes in Pictures](https://dev.os9.ca/techpubs/mac/QuickDraw/QuickDraw-461.html) and
@@ -13711,8 +13713,9 @@ the frame within 16-bit coordinates. The writer follows the opcodes and data lay
several figures is one polygon that runs back along the line between its figures, and a non-zero fill is first
resolved into figures that don't overlap. Art is cut to the frame. A fill too complex to resolve or cut is written
as it is, filled even-odd. Oversized fills first have their curves flattened more coarsely, with a warning.
A fill of more than 8,189 points is written as several polygons, and a single outline of
more than 8,187 points keeps that many points, evenly spaced. Each of these adds a warning.
Each figure counts two points more than its outline holds. A fill of several figures that still counts more than
8,189 points after that is written as several polygons; a figure of more than 8,187 points keeps that many points,
evenly spaced, so a fill of one such figure stays one polygon. Each of these adds a warning.
- Strokes are their filled outlines, with their caps, joins, miter limit and dashes; a stroke thinner than a device unit
is written one unit wide.
- Images are `DirectBitsRect` pixel maps of 24-bit color in tiles of at most 1,024 pixels on a side, each row packed