mirror of
https://github.com/penpot/penpot.git
synced 2025-07-14 04:57:18 +02:00
🎉 Serialize data in clojure
This commit is contained in:
parent
f564b4e66d
commit
22b01c63b5
6 changed files with 121 additions and 8 deletions
|
@ -103,16 +103,15 @@ pub extern "C" fn use_shape(a: u32, b: u32, c: u32, d: u32) {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn set_shape_selrect(left: f32, top: f32, right: f32, bottom: f32) {
|
||||
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");
|
||||
|
||||
if let Some(shape) = state.current_shape() {
|
||||
shape.selrect.set_ltrb(left, top, right, bottom);
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn set_shape_rotation(rotation: f32) {
|
||||
pub extern "C" fn set_shape_rotation(rotation: f32) {
|
||||
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
|
||||
if let Some(shape) = state.current_shape() {
|
||||
shape.rotation = rotation;
|
||||
|
@ -120,7 +119,7 @@ pub unsafe extern "C" fn set_shape_rotation(rotation: f32) {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn set_shape_transform(a: f32, b: f32, c: f32, d: f32, e: f32, f: f32) {
|
||||
pub extern "C" fn set_shape_transform(a: f32, b: f32, c: f32, d: f32, e: f32, f: f32) {
|
||||
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
|
||||
if let Some(shape) = state.current_shape() {
|
||||
shape.transform.a = a;
|
||||
|
@ -271,6 +270,24 @@ pub extern "C" fn set_shape_hidden(hidden: bool) {
|
|||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn set_shape_path_content(n_segments: u32) {
|
||||
let state = unsafe { STATE.as_mut() }.expect("got an invalid state pointer");
|
||||
|
||||
if let Some(shape) = state.current_shape() {
|
||||
let len = n_segments as usize;
|
||||
|
||||
unsafe {
|
||||
let buffer = Vec::<shapes::RawPathData>::from_raw_parts(
|
||||
mem::buffer_ptr() as *mut shapes::RawPathData,
|
||||
len,
|
||||
len,
|
||||
);
|
||||
mem::free_bytes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
init_gl();
|
||||
}
|
||||
|
|
|
@ -5,9 +5,11 @@ use uuid::Uuid;
|
|||
mod blend;
|
||||
mod fills;
|
||||
mod images;
|
||||
mod paths;
|
||||
pub use blend::*;
|
||||
pub use fills::*;
|
||||
pub use images::*;
|
||||
pub use paths::*;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum Kind {
|
||||
|
|
4
render-wasm/src/shapes/paths.rs
Normal file
4
render-wasm/src/shapes/paths.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
#[derive(Debug)]
|
||||
pub struct RawPathData {
|
||||
data: [u8; 28],
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue