🐛 Fix blend mode against background

This commit is contained in:
Belén Albeza 2024-12-11 16:48:41 +01:00
parent 579a5729e6
commit 21da6ddd4a
5 changed files with 34 additions and 2 deletions

View file

@ -49,6 +49,7 @@ pub(crate) struct RenderState {
options: RenderOptions,
pub viewbox: Viewbox,
images: ImageStore,
background_color: skia::Color,
}
impl RenderState {
@ -72,6 +73,7 @@ impl RenderState {
options: RenderOptions::default(),
viewbox: Viewbox::new(width as f32, height as f32),
images: ImageStore::new(),
background_color: skia::Color::TRANSPARENT,
}
}
@ -97,6 +99,11 @@ impl RenderState {
}
}
pub fn set_background_color(&mut self, color: skia::Color) {
self.background_color = color;
let _ = self.render_all_from_cache();
}
pub fn resize(&mut self, width: i32, height: i32) {
let dpr_width = (width as f32 * self.options.dpr()).floor() as i32;
let dpr_height = (height as f32 * self.options.dpr()).floor() as i32;
@ -136,7 +143,7 @@ impl RenderState {
.reset_matrix();
self.final_surface
.canvas()
.clear(skia::Color::TRANSPARENT)
.clear(self.background_color)
.reset_matrix();
self.debug_surface
.canvas()