Plug-ins: a left-out piece opacity is 100%, and the PDF test reads back the look

docs/plugins.md said a piece's opacity, when left out, is the object's.
The piece takes no opacity of its own in that case: the object's opacity
applies once to all the pieces together, so the line now says 100%.

The export test also opens the exported PDF and draws it: the piece is
half green and grown by Offset Path, as on the canvas, so a PDF that
drops the opacity or writes the original path fails the test.
This commit is contained in:
dotCooCoo committed 2026-11-25 15:08:44 -08:00
1 parent fd7d4976e8
commit 032206d8fe
2 files changed
+10 -1

No files matched your search

+9
View File
@@ -597,6 +597,15 @@ fn a_painted_piece_s_look_is_exported_and_expanded() {
let pdf = s.execute("document.export", &json!({"format": "pdf"})).unwrap();
let pdf = vectorcraft_format::base64_decode(pdf["dataBase64"].as_str().unwrap()).unwrap();
assert!(pdf.windows(9).any(|w| w == b"/Multiply"), "the PDF sets the blending mode");
let back = vectorcraft_pdf::import(&pdf).unwrap();
let opts = vectorcraft_render::RenderOptions { background: Some([255, 255, 255, 255]), ..Default::default() };
let read = vectorcraft_render::Renderer::new().render(&back, 200, 200, vectorcraft_geom::Affine::IDENTITY, &opts);
let (got_inside, got_grown) = (read.pixel(50, 50), read.pixel(37, 50));
assert!(
near(got_inside, [128, 255, 128]) && near(got_grown, [128, 255, 128]),
"the PDF's piece is half green and grown: {got_inside:?} {got_grown:?}"
);
assert_eq!(read.pixel(32, 50), WHITE);
assert_eq!(s.doc().unwrap().doc, before, "export doesn't change the document");
run(&mut s, "select.set", json!({"ids": [id.0]}));
run(&mut s, "effect.expandAppearance", json!({}));
+1 -1
View File
@@ -1042,7 +1042,7 @@ fill and stroke the piece returns, three more keys:
the fills or strokes that an effect on a fill or a stroke returns take `opacity` and `blend` but no `effects` (its
pieces still take them). A plug-in effect (`plugin.<id>`), this effect's own included, is refused, so the effects a
piece carries never run a plug-in.
- Left out, a piece's opacity is the object's, its blending mode Normal and its effects none; a fill or stroke keeps
- Left out, a piece's opacity is 100%, its blending mode Normal and its effects none; a fill or stroke keeps
the opacity, blending and effects it would have without the keys. Given, a piece's opacity multiplies the object's,
and its effects and a fill's or stroke's come after the ones it already has. The object's own opacity, blending mode
and later effects still apply once to all the pieces together.