🎉 Stroke caps support for wasm render

This commit is contained in:
Alejandro Alonso 2025-01-08 14:14:26 +01:00
parent 4bd1e32462
commit 13ec04dd65
5 changed files with 288 additions and 35 deletions

View file

@ -347,26 +347,32 @@ pub extern "C" fn set_shape_path_content() {
}
#[no_mangle]
pub extern "C" fn add_shape_center_stroke(width: f32, style: i32) {
pub extern "C" fn add_shape_center_stroke(width: f32, style: u8, cap_start: u8, cap_end: u8) {
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
if let Some(shape) = state.current_shape() {
shape.add_stroke(shapes::Stroke::new_center_stroke(width, style));
shape.add_stroke(shapes::Stroke::new_center_stroke(
width, style, cap_start, cap_end,
));
}
}
#[no_mangle]
pub extern "C" fn add_shape_inner_stroke(width: f32, style: i32) {
pub extern "C" fn add_shape_inner_stroke(width: f32, style: u8, cap_start: u8, cap_end: u8) {
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
if let Some(shape) = state.current_shape() {
shape.add_stroke(shapes::Stroke::new_inner_stroke(width, style))
shape.add_stroke(shapes::Stroke::new_inner_stroke(
width, style, cap_start, cap_end,
))
}
}
#[no_mangle]
pub extern "C" fn add_shape_outer_stroke(width: f32, style: i32) {
pub extern "C" fn add_shape_outer_stroke(width: f32, style: u8, cap_start: u8, cap_end: u8) {
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
if let Some(shape) = state.current_shape() {
shape.add_stroke(shapes::Stroke::new_outer_stroke(width, style))
shape.add_stroke(shapes::Stroke::new_outer_stroke(
width, style, cap_start, cap_end,
))
}
}