mirror of
https://github.com/penpot/penpot.git
synced 2025-05-25 11:46:10 +02:00
✨ Ability to add multiple fills to a shape
This commit is contained in:
parent
aecb8a1464
commit
23a9c74297
25 changed files with 475 additions and 243 deletions
|
@ -358,16 +358,40 @@
|
|||
(= type :path)
|
||||
(parse-path center svg-data))))
|
||||
|
||||
(defn add-library-refs
|
||||
[props node]
|
||||
|
||||
(let [stroke-color-ref-id (get-meta node :stroke-color-ref-id uuid/uuid)
|
||||
stroke-color-ref-file (get-meta node :stroke-color-ref-file uuid/uuid)
|
||||
component-id (get-meta node :component-id uuid/uuid)
|
||||
component-file (get-meta node :component-file uuid/uuid)
|
||||
shape-ref (get-meta node :shape-ref uuid/uuid)
|
||||
component-root? (get-meta node :component-root str->bool)]
|
||||
|
||||
(cond-> props
|
||||
(some? stroke-color-ref-id)
|
||||
(assoc :stroke-color-ref-id stroke-color-ref-id
|
||||
:stroke-color-ref-file stroke-color-ref-file)
|
||||
|
||||
(some? component-id)
|
||||
(assoc :component-id component-id
|
||||
:component-file component-file)
|
||||
|
||||
component-root?
|
||||
(assoc :component-root? component-root?)
|
||||
|
||||
(some? shape-ref)
|
||||
(assoc :shape-ref shape-ref))))
|
||||
|
||||
(defn add-fill
|
||||
[props node svg-data]
|
||||
|
||||
(let [fill (:fill svg-data)
|
||||
hide-fill-on-export (get-meta node :hide-fill-on-export str->bool)
|
||||
fill-color-ref-id (get-meta node :fill-color-ref-id uuid/uuid)
|
||||
fill-color-ref-file (get-meta node :fill-color-ref-file uuid/uuid)
|
||||
gradient (when (str/starts-with? fill "url")
|
||||
(parse-gradient node fill))
|
||||
meta-fill-color (get-meta node :fill-color)
|
||||
meta-fill-opacity (get-meta node :fill-opacity)
|
||||
meta-fill-color-gradient (get-meta node :fill-color-gradient)]
|
||||
(parse-gradient node fill))]
|
||||
|
||||
(cond-> props
|
||||
:always
|
||||
|
@ -386,14 +410,9 @@
|
|||
(some? hide-fill-on-export)
|
||||
(assoc :hide-fill-on-export hide-fill-on-export)
|
||||
|
||||
(some? meta-fill-color)
|
||||
(assoc :fill-color meta-fill-color
|
||||
:fill-opacity (d/parse-double meta-fill-opacity))
|
||||
|
||||
(some? meta-fill-color-gradient)
|
||||
(assoc :fill-color-gradient meta-fill-color-gradient
|
||||
:fill-color nil
|
||||
:fill-opacity nil))))
|
||||
(some? fill-color-ref-id)
|
||||
(assoc :fill-color-ref-id fill-color-ref-id
|
||||
:fill-color-ref-file fill-color-ref-file))))
|
||||
|
||||
(defn add-stroke
|
||||
[props node svg-data]
|
||||
|
@ -658,6 +677,21 @@
|
|||
|
||||
props)))
|
||||
|
||||
(defn add-fills
|
||||
[props node svg-data]
|
||||
(let [fills (-> node
|
||||
(find-node :defs)
|
||||
(find-node :pattern)
|
||||
(find-node :g)
|
||||
(find-all-nodes :rect)
|
||||
(reverse))
|
||||
fills (if (= 0 (count fills))
|
||||
[(add-fill {} node svg-data)]
|
||||
(map #(add-fill {} node (get-svg-data :rect %)) fills))]
|
||||
(-> props
|
||||
(assoc :fills fills))))
|
||||
|
||||
|
||||
(defn add-svg-content
|
||||
[props node]
|
||||
(let [svg-content (get-data node :penpot:svg-content)
|
||||
|
@ -715,37 +749,6 @@
|
|||
svg-data (or image-data pattern-data)]
|
||||
(:xlink:href svg-data)))
|
||||
|
||||
(defn add-library-refs
|
||||
[props node]
|
||||
|
||||
(let [fill-color-ref-id (get-meta node :fill-color-ref-id uuid/uuid)
|
||||
fill-color-ref-file (get-meta node :fill-color-ref-file uuid/uuid)
|
||||
stroke-color-ref-id (get-meta node :stroke-color-ref-id uuid/uuid)
|
||||
stroke-color-ref-file (get-meta node :stroke-color-ref-file uuid/uuid)
|
||||
component-id (get-meta node :component-id uuid/uuid)
|
||||
component-file (get-meta node :component-file uuid/uuid)
|
||||
shape-ref (get-meta node :shape-ref uuid/uuid)
|
||||
component-root? (get-meta node :component-root str->bool)]
|
||||
|
||||
(cond-> props
|
||||
(some? fill-color-ref-id)
|
||||
(assoc :fill-color-ref-id fill-color-ref-id
|
||||
:fill-color-ref-file fill-color-ref-file)
|
||||
|
||||
(some? stroke-color-ref-id)
|
||||
(assoc :stroke-color-ref-id stroke-color-ref-id
|
||||
:stroke-color-ref-file stroke-color-ref-file)
|
||||
|
||||
(some? component-id)
|
||||
(assoc :component-id component-id
|
||||
:component-file component-file)
|
||||
|
||||
component-root?
|
||||
(assoc :component-root? component-root?)
|
||||
|
||||
(some? shape-ref)
|
||||
(assoc :shape-ref shape-ref))))
|
||||
|
||||
(defn parse-data
|
||||
[type node]
|
||||
|
||||
|
@ -754,7 +757,6 @@
|
|||
(-> {}
|
||||
(add-common-data node)
|
||||
(add-position type node svg-data)
|
||||
(add-fill node svg-data)
|
||||
(add-stroke node svg-data)
|
||||
(add-layer-options svg-data)
|
||||
(add-shadows node)
|
||||
|
@ -762,6 +764,7 @@
|
|||
(add-exports node)
|
||||
(add-svg-attrs node svg-data)
|
||||
(add-library-refs node)
|
||||
(add-fills node svg-data)
|
||||
|
||||
(cond-> (= :svg-raw type)
|
||||
(add-svg-content node))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue