From 032206d8fe61c0a55cc7282174ad5ae5f6474322 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 25 Nov 2026 15:08:44 -0800 Subject: [PATCH] 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. --- crates/engine/src/tests/plugins.rs | 9 +++++++++ docs/plugins.md | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/tests/plugins.rs b/crates/engine/src/tests/plugins.rs index a2868201ce..8afe824501 100644 --- a/crates/engine/src/tests/plugins.rs +++ b/crates/engine/src/tests/plugins.rs @@ -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!({})); diff --git a/docs/plugins.md b/docs/plugins.md index 4659eee54e..334cf8254c 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -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.`), 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.