Linear and radial gradient handlers

This commit is contained in:
alonso.torres 2020-10-05 13:23:23 +02:00
parent 8466c1c54d
commit 08b537a158
6 changed files with 442 additions and 26 deletions

View file

@ -13,7 +13,12 @@
[app.main.ui.shapes.attrs :as attrs]
[app.main.ui.shapes.custom-stroke :refer [shape-custom-stroke]]
[app.common.geom.shapes :as geom]
[app.util.object :as obj]))
[app.util.object :as obj]
[app.main.ui.shapes.gradients :refer [gradient]]
[cuerdas.core :as str]
[app.common.uuid :as uuid]
[app.common.geom.point :as gpt]))
(mf/defc rect-shape
{::mf/wrap-props false}
@ -21,7 +26,10 @@
(let [shape (unchecked-get props "shape")
{:keys [id x y width height]} shape
transform (geom/transform-matrix shape)
props (-> (attrs/extract-style-attrs shape)
gradient-id (when (:fill-color-gradient shape) (str (uuid/next)))
props (-> (attrs/extract-style-attrs shape gradient-id)
(obj/merge!
#js {:x x
:y y
@ -30,7 +38,12 @@
:width width
:height height}))]
[:& shape-custom-stroke {:shape shape
:base-props props
:elem-name "rect"}]))
[:*
(when gradient-id
[:& gradient {:id gradient-id
:shape shape
:gradient (:fill-color-gradient shape)}])
[:& shape-custom-stroke {:shape shape
:base-props props
:elem-name "rect"}]]))