🎉 Shape opacity for wasm render

This commit is contained in:
Alejandro Alonso 2024-11-25 07:17:29 +01:00
parent e675ff6db5
commit d09e5ef9b3
5 changed files with 19 additions and 1 deletions

View file

@ -166,6 +166,14 @@ pub extern "C" fn set_shape_blend_mode(mode: i32) {
}
}
#[no_mangle]
pub extern "C" fn set_shape_opacity(opacity: f32) {
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
if let Some(shape) = state.current_shape() {
shape.opacity = opacity;
}
}
fn main() {
init_gl();
}

View file

@ -164,6 +164,7 @@ impl RenderState {
let mut paint = skia::Paint::default();
paint.set_blend_mode(shape.blend_mode.into());
paint.set_alpha_f(shape.opacity);
self.drawing_surface.draw(
&mut self.final_surface.canvas(),
(0.0, 0.0),

View file

@ -104,6 +104,7 @@ pub struct Shape {
pub rotation: f32,
fills: Vec<Fill>,
pub blend_mode: BlendMode,
pub opacity: f32,
}
impl Shape {
@ -117,6 +118,7 @@ impl Shape {
rotation: 0.,
fills: vec![],
blend_mode: BlendMode::default(),
opacity: 1.,
}
}