🎉 Add PathData data type

🎉 Add PathData data type
This commit is contained in:
Elena Torró 2025-03-27 13:39:54 +01:00 committed by GitHub
commit 06bfb1ad26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 443 additions and 82 deletions

View file

@ -12,8 +12,8 @@
[app.common.data.macros :as dm]
[app.common.geom.matrix :as gmt]
[app.common.math :as mth]
[app.common.svg.path :as path]
[app.common.types.shape.layout :as ctl]
[app.common.types.shape.path :as path]
[app.common.uuid :as uuid]
[app.config :as cf]
[app.main.refs :as refs]
@ -373,12 +373,11 @@
(defn set-shape-path-content
[content]
(let [buffer (path/content->buffer content)
size (.-byteLength buffer)
ptr (h/call internal-module "_alloc_bytes" size)
heap (gobj/get ^js internal-module "HEAPU8")
mem (js/Uint8Array. (.-buffer heap) ptr size)]
(.set mem (js/Uint8Array. buffer))
(let [pdata (path/path-data content)
size (* (count pdata) path/SEGMENT-BYTE-SIZE)
offset (h/call internal-module "_alloc_bytes" size)
heap (gobj/get ^js internal-module "HEAPU8")]
(path/-write-to pdata (.-buffer heap) offset)
(h/call internal-module "_set_shape_path_content")))
(defn set-shape-svg-raw-content