diff --git a/common/src/app/common/types/fills/impl.cljc b/common/src/app/common/types/fills/impl.cljc index 20813ee91f..fb41340a45 100644 --- a/common/src/app/common/types/fills/impl.cljc +++ b/common/src/app/common/types/fills/impl.cljc @@ -23,7 +23,7 @@ (def ^:const GRADIENT-STOP-SIZE 8) (def ^:const GRADIENT-BYTE-SIZE 156) (def ^:const SOLID-BYTE-SIZE 4) -(def ^:const IMAGE-BYTE-SIZE 28) +(def ^:const IMAGE-BYTE-SIZE 36) (def ^:const METADATA-BYTE-SIZE 36) (def ^:const FILL-BYTE-SIZE (+ 4 (mth/max GRADIENT-BYTE-SIZE @@ -121,13 +121,13 @@ (let [image-id (get image :id) image-width (get image :width) image-height (get image :height) - keep-ratio (get image :keep-aspect-ratio false)] + keep-aspect-ratio (get image :keep-aspect-ratio false)] (buf/write-byte buffer (+ offset 0) 0x03) - (buf/write-bool buffer (+ offset 1) keep-ratio) (buf/write-uuid buffer (+ offset 4) image-id) (buf/write-float buffer (+ offset 20) opacity) (buf/write-int buffer (+ offset 24) image-width) (buf/write-int buffer (+ offset 28) image-height) + (buf/write-bool buffer (+ offset 32) keep-aspect-ratio) (+ offset FILL-BYTE-SIZE))) (defn- write-metadata @@ -203,7 +203,7 @@ :type type}}) 3 - (let [ratio (buf/read-bool dbuffer (+ doffset 1)) + (let [ratio (buf/read-bool dbuffer (+ doffset 32)) id (buf/read-uuid dbuffer (+ doffset 4)) alpha (buf/read-float dbuffer (+ doffset 20)) width (buf/read-int dbuffer (+ doffset 24)) diff --git a/render-wasm/src/wasm/fills/image.rs b/render-wasm/src/wasm/fills/image.rs index c35c5426d9..07ae137d37 100644 --- a/render-wasm/src/wasm/fills/image.rs +++ b/render-wasm/src/wasm/fills/image.rs @@ -11,6 +11,7 @@ pub struct RawImageFillData { opacity: f32, width: i32, height: i32, + keep_aspect_ratio: i32, } impl From for ImageFill { @@ -18,7 +19,12 @@ impl From for ImageFill { let id = uuid_from_u32_quartet(value.a, value.b, value.c, value.d); let opacity = (value.opacity * 255.).floor() as u8; - // TODO: read keep_aspect_ratio from RawImageFillData when implemented - Self::new(id, opacity, value.width, value.height, true) + Self::new( + id, + opacity, + value.width, + value.height, + value.keep_aspect_ratio != 0, + ) } }