🎉 Implement rounded corners

This commit is contained in:
Belén Albeza 2025-01-09 17:11:34 +01:00
parent 576c912c81
commit 6e7a8c239c
6 changed files with 115 additions and 18 deletions

View file

@ -1,3 +1,5 @@
use skia_safe as skia;
mod debug;
mod math;
mod mem;
@ -8,7 +10,6 @@ mod utils;
mod view;
use crate::shapes::{BoolType, Kind, Path};
use skia_safe as skia;
use crate::state::State;
use crate::utils::uuid_from_u32_quartet;
@ -125,7 +126,10 @@ pub unsafe extern "C" fn set_shape_kind_rect() {
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
if let Some(shape) = state.current_shape() {
shape.set_kind(Kind::Rect(math::Rect::new_empty()));
match shape.kind() {
Kind::Rect(_, _) => {}
_ => shape.set_kind(Kind::Rect(math::Rect::new_empty(), None)),
}
}
}
@ -502,6 +506,14 @@ pub extern "C" fn clear_shape_strokes() {
}
}
#[no_mangle]
pub extern "C" fn set_shape_corners(r1: f32, r2: f32, r3: f32, r4: f32) {
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
if let Some(shape) = state.current_shape() {
shape.set_corners((r1, r2, r3, r4))
}
}
fn main() {
init_gl();
}