mirror of
https://github.com/storytold/deckcraft.git
synced 2026-11-18 08:04:53 +00:00
fix(render): an emphasis tint recolours the fill behind a picture's and an object preview's transparent pixels
This commit is contained in:
1 parent
a8f1573fba
commit
c15e260794
2 files changed
+14
-5
No files matched your search
@@ -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() };
|
||||
|
||||
@@ -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:?}");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user