🎉 Feat masks

This commit is contained in:
AzazelN28 2025-01-22 16:41:25 +01:00 committed by Aitor Moreno
parent 3ea52a0198
commit f8d58cb74e
9 changed files with 249 additions and 102 deletions

View file

@ -108,7 +108,7 @@
(h/call internal-module "_set_shape_clip_content" clip-content))
(defn set-shape-type
[type]
[type {:keys [masked]}]
(cond
(= type :circle)
(h/call internal-module "_set_shape_kind_circle")
@ -119,6 +119,9 @@
(= type :bool)
(h/call internal-module "_set_shape_kind_bool")
(= type :group)
(h/call internal-module "_set_shape_kind_group" masked)
:else
(h/call internal-module "_set_shape_kind_rect")))
@ -537,6 +540,7 @@
(let [shape (nth shapes index)
id (dm/get-prop shape :id)
type (dm/get-prop shape :type)
masked (dm/get-prop shape :masked-group)
selrect (dm/get-prop shape :selrect)
clip-content (if (= type :frame)
(not (dm/get-prop shape :show-content))
@ -563,7 +567,7 @@
shadows (dm/get-prop shape :shadow)]
(use-shape id)
(set-shape-type type)
(set-shape-type type {:masked masked})
(set-shape-clip-content clip-content)
(set-shape-selrect selrect)
(set-shape-rotation rotation)

View file

@ -110,34 +110,35 @@
[self k v]
(when ^boolean shape/*wasm-sync*
(api/use-shape (:id self))
(case k
:type (api/set-shape-type v)
:bool-type (api/set-shape-bool-type v)
:bool-content (api/set-shape-bool-content v)
:selrect (api/set-shape-selrect v)
:show-content (if (= (:type self) :frame)
(api/set-shape-clip-content (not v))
(api/set-shape-clip-content false))
:rotation (api/set-shape-rotation v)
:transform (api/set-shape-transform v)
:fills (api/set-shape-fills v)
:strokes (api/set-shape-strokes v)
:blend-mode (api/set-shape-blend-mode v)
:opacity (api/set-shape-opacity v)
:hidden (api/set-shape-hidden v)
:shapes (api/set-shape-children v)
:blur (api/set-shape-blur v)
:svg-attrs (when (= (:type self) :path)
(api/set-shape-path-attrs v))
:constraints-h (api/set-constraints-h v)
:constraints-v (api/set-constraints-v v)
:content (cond
(= (:type self) :path)
(api/set-shape-path-content v)
(let [masked (:masked-group self)]
(case k
:type (api/set-shape-type v {:masked masked})
:bool-type (api/set-shape-bool-type v)
:bool-content (api/set-shape-bool-content v)
:selrect (api/set-shape-selrect v)
:show-content (if (= (:type self) :frame)
(api/set-shape-clip-content (not v))
(api/set-shape-clip-content false))
:rotation (api/set-shape-rotation v)
:transform (api/set-shape-transform v)
:fills (api/set-shape-fills v)
:strokes (api/set-shape-strokes v)
:blend-mode (api/set-shape-blend-mode v)
:opacity (api/set-shape-opacity v)
:hidden (api/set-shape-hidden v)
:shapes (api/set-shape-children v)
:blur (api/set-shape-blur v)
:svg-attrs (when (= (:type self) :path)
(api/set-shape-path-attrs v))
:constraints-h (api/set-constraints-h v)
:constraints-v (api/set-constraints-v v)
:content (cond
(= (:type self) :path)
(api/set-shape-path-content v)
(= (:type self) :svg-raw)
(api/set-shape-svg-raw-content (api/get-static-markup self)))
nil)
(= (:type self) :svg-raw)
(api/set-shape-svg-raw-content (api/get-static-markup self)))
nil))
;; when something synced with wasm
;; is modified, we need to request
;; a new render.