mirror of
https://github.com/penpot/penpot.git
synced 2025-07-19 10:37:24 +02:00
✨ Add constraints calculation on WASM (#5894)
* ✨ Add constraints calculation on WASM * ✨ Fix after review
This commit is contained in:
parent
f5c913d26e
commit
6cb1aa24cd
15 changed files with 746 additions and 76 deletions
|
@ -1,3 +1,4 @@
|
|||
use skia::Rect;
|
||||
use skia_safe as skia;
|
||||
|
||||
mod debug;
|
||||
|
@ -10,7 +11,7 @@ mod utils;
|
|||
mod view;
|
||||
|
||||
use crate::mem::SerializableResult;
|
||||
use crate::shapes::{BoolType, ConstraintH, ConstraintV, Group, Kind, Path, TransformEntry};
|
||||
use crate::shapes::{BoolType, ConstraintH, ConstraintV, Group, Kind, Path, TransformEntry, Type};
|
||||
|
||||
use crate::state::State;
|
||||
use crate::utils::uuid_from_u32_quartet;
|
||||
|
@ -142,7 +143,7 @@ pub extern "C" fn set_shape_kind_circle() {
|
|||
let state = unsafe { STATE.as_mut() }.expect("Got an invalid state pointer");
|
||||
|
||||
if let Some(shape) = state.current_shape() {
|
||||
shape.set_kind(Kind::Circle(math::Rect::new_empty()));
|
||||
shape.set_kind(Kind::Circle(Rect::new_empty()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,7 +154,7 @@ pub extern "C" fn set_shape_kind_rect() {
|
|||
if let Some(shape) = state.current_shape() {
|
||||
match shape.kind() {
|
||||
Kind::Rect(_, _) => {}
|
||||
_ => shape.set_kind(Kind::Rect(math::Rect::new_empty(), None)),
|
||||
_ => shape.set_kind(Kind::Rect(Rect::new_empty(), None)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -185,6 +186,15 @@ pub extern "C" fn set_shape_bool_type(raw_bool_type: u8) {
|
|||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn set_shape_type(shape_type: u8) {
|
||||
let state = unsafe { STATE.as_mut() }.expect("Got an invalid state pointer");
|
||||
|
||||
if let Some(shape) = state.current_shape() {
|
||||
shape.set_shape_type(Type::from(shape_type));
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn set_shape_selrect(left: f32, top: f32, right: f32, bottom: f32) {
|
||||
let state = unsafe { STATE.as_mut() }.expect("Got an invalid state pointer");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue