Serialize image fills in binary

This commit is contained in:
Belén Albeza 2025-04-29 17:30:17 +02:00
parent f30441626e
commit 173d6c23b0
6 changed files with 109 additions and 51 deletions

View file

@ -1,6 +1,5 @@
use crate::mem;
use crate::shapes;
use crate::utils::uuid_from_u32_quartet;
use crate::with_current_shape;
use crate::STATE;
@ -68,23 +67,13 @@ pub extern "C" fn add_shape_stroke_radial_fill() {
}
#[no_mangle]
pub extern "C" fn add_shape_image_stroke(
a: u32,
b: u32,
c: u32,
d: u32,
alpha: f32,
width: i32,
height: i32,
) {
pub extern "C" fn add_shape_image_stroke() {
with_current_shape!(state, |shape: &mut Shape| {
let id = uuid_from_u32_quartet(a, b, c, d);
let bytes = mem::bytes();
let image_fill = shapes::ImageFill::try_from(&bytes[..]).expect("Invalid image fill data");
shape
.set_stroke_fill(shapes::Fill::new_image_fill(
id,
(alpha * 0xff as f32).floor() as u8,
(width, height),
))
.set_stroke_fill(shapes::Fill::Image(image_fill))
.expect("could not add stroke image fill");
});
}