Skip to content

Commit

Permalink
fix: doubling of shadow smoothstep lower bound for tiny skia, use int…
Browse files Browse the repository at this point in the history
…o_color
  • Loading branch information
nicksenger committed Jul 18, 2023
1 parent b9e3e47 commit 9fc99af
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions tiny_skia/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,23 +259,15 @@ impl Backend {
);
let shadow_alpha = 1.0
- smoothstep(
-shadow_blur_radius * scale_factor * 2.0,
-shadow_blur_radius * scale_factor,
*shadow_blur_radius * scale_factor,
shadow_distance,
);

tiny_skia::Color::from_rgba(
// This configuration gives the correct color, but how are
// the blue and red channels getting mixed up?
shadow_color.b,
shadow_color.g,
shadow_color.r,
shadow_color.a * shadow_alpha,
)
.map(|color| color.to_color_u8().premultiply())
.unwrap_or_else(|| {
tiny_skia::PremultipliedColorU8::TRANSPARENT
})
let mut color = into_color(*shadow_color);
color.apply_opacity(shadow_alpha);

color.to_color_u8().premultiply()
})
.collect();

Expand Down

0 comments on commit 9fc99af

Please sign in to comment.