From c15e260794e8ab153fda90eed895b90198125570 Mon Sep 17 00:00:00 2001 From: Dominik Strebel Date: Sat, 24 Oct 2026 16:48:24 +0200 Subject: [PATCH] fix(render): an emphasis tint recolours the fill behind a picture's and an object preview's transparent pixels --- crates/render/src/lib.rs | 15 ++++++++++----- crates/render/src/tests.rs | 4 ++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/crates/render/src/lib.rs b/crates/render/src/lib.rs index 37102d9b7..ee79b385a 100644 --- a/crates/render/src/lib.rs +++ b/crates/render/src/lib.rs @@ -1165,9 +1165,12 @@ impl Renderer { // Fill. match &s.kind { ShapeKind::Picture { fill: pf } => { - // The picture's own fill shows behind its transparent pixels, as in PowerPoint. - if let Some(fl) = s.fill.as_ref().filter(|f| !f.is_none()) { - self.fill_geometry(ctx, f, rctx, fl, None, &geo, (w, h), m, &fade); + // The picture's own fill shows behind its transparent pixels, as in PowerPoint (an + // emphasis tint recolours it, as it does any shape's fill). + if s.fill.as_ref().is_some_and(|f| !f.is_none()) + && let Some(fl) = &fill + { + self.fill_geometry(ctx, f, rctx, fl, fill_ph, &geo, (w, h), m, &fade); } ctx.set_transform(m); let bounds = Rect::new(0.0, 0.0, w, h); @@ -1181,8 +1184,10 @@ impl Renderer { ShapeKind::Opaque { preview: Some(media), .. } => { // An embedded object's fallback picture can carry a fill (old equation objects // drawn on coloured boxes): behind the preview, as for a picture. - if let Some(fl) = s.fill.as_ref().filter(|f| !f.is_none()) { - self.fill_geometry(ctx, f, rctx, fl, None, &geo, (w, h), m, &fade); + if s.fill.as_ref().is_some_and(|f| !f.is_none()) + && let Some(fl) = &fill + { + self.fill_geometry(ctx, f, rctx, fl, fill_ph, &geo, (w, h), m, &fade); } ctx.set_transform(m); let pf = deckcraft_model::style::PictureFill { media: *media, ..Default::default() }; diff --git a/crates/render/src/tests.rs b/crates/render/src/tests.rs index 7d1f78a18..686992c37 100644 --- a/crates/render/src/tests.rs +++ b/crates/render/src/tests.rs @@ -1936,6 +1936,10 @@ fn a_picture_and_an_embedded_objects_preview_draw_their_fill_behind_transparent_ assert!(opaque[2] > 140 && opaque[0] < 40, "the picture's own pixels ({object}): {opaque:?}"); if fill.is_some() { assert_eq!(clear[..3], [255, 153, 0], "the fill behind the clear half ({object})"); + // A fill-colour emphasis recolours that fill, as it does any shape's. + let tint = |_: ShapeId| ShapeState { tint: Some(deckcraft_color::Rgba::rgb(0, 160, 60)), ..Default::default() }; + let img = render_slide(&p, 0, &RenderOpts { scale: 1.0, state: Some(&tint), ..Default::default() }); + assert_eq!(img.pixel(200, 200)[..3], [0, 160, 60], "the tinted fill behind the clear half ({object})"); } else { assert!(clear[..3].iter().all(|v| *v > 240), "no fill: the slide shows through: {clear:?}"); }