🎉 Deserialize shape data in wasm

This commit is contained in:
Belén Albeza 2024-12-09 14:30:03 +01:00
parent 22b01c63b5
commit 0bfcc1f854
6 changed files with 140 additions and 18 deletions

View file

@ -11,9 +11,10 @@ pub use fills::*;
pub use images::*;
pub use paths::*;
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, PartialEq)]
pub enum Kind {
Rect,
Path(Path),
}
pub type Color = skia::Color;
@ -110,6 +111,12 @@ impl Shape {
Ok(())
}
pub fn set_path_segments(&mut self, buffer: Vec<RawPathData>) -> Result<(), String> {
let p = Path::try_from(buffer)?;
self.kind = Kind::Path(p);
Ok(())
}
pub fn set_blend_mode(&mut self, mode: BlendMode) {
self.blend_mode = mode;
}