Clip-paths, polylines, polygons and fixes

This commit is contained in:
alonso.torres 2021-03-02 15:19:54 +01:00 committed by Andrey Antukh
parent 237ef2a205
commit d3345c0fa6
4 changed files with 64 additions and 14 deletions

View file

@ -107,9 +107,13 @@
(:stroke-color-gradient shape)
(assoc :stroke (str/format "url(#%s)" stroke-color-gradient-id))
(not (:stroke-color-gradient shape))
(assoc :stroke (:stroke-color shape nil)
:strokeOpacity (:stroke-opacity shape nil))
(and (not (:stroke-color-gradient shape))
(:stroke-color shape nil))
(assoc :stroke (:stroke-color shape nil))
(and (not (:stroke-color-gradient shape))
(:stroke-opacity shape nil))
(assoc :strokeOpacity (:stroke-opacity shape nil))
(not= stroke-style :svg)
(assoc :strokeDasharray (stroke-type->dasharray stroke-style)))]
@ -124,8 +128,7 @@
id))
svg-attrs (-> svg-attrs
(usvg/clean-attrs)
(usvg/update-attr-ids replace-id)
)
(usvg/update-attr-ids replace-id))
attrs (-> svg-attrs (dissoc :style) (clj->js))
styles (-> svg-attrs (:style {}) (clj->js))]

View file

@ -55,6 +55,9 @@
(every? d/num-string? [(:x attrs "0") (:y attrs "0") (:width attrs "0") (:height attrs "0")])
(= "userSpaceOnUse" (get attrs :patternUnits "userSpaceOnUse")))
transform-clippath? (and (= :clipPath tag)
(= "userSpaceOnUse" (get attrs :clipPathUnits "userSpaceOnUse")))
transform-filter? (and (= #{:filter
;; Filter primitives. We need to remap subregions
:feBlend :feColorMatrix :feComponentTransfer :feComposite :feConvolveMatrix
@ -70,6 +73,7 @@
(cond->
transform-gradient? (add-matrix :gradientTransform transform)
transform-pattern? (add-matrix :patternTransform transform)
transform-clippath? (add-matrix :transform transform)
transform-filter? (transform-region transform)))
[wrapper wrapper-props] (if (= tag :mask)
@ -93,9 +97,10 @@
(gmt/matrix)
(usvg/svg-transform-matrix shape)))
transform (gmt/multiply
transform
(or (:svg-transform shape) (gmt/matrix)))
;; Paths doesn't have transform so we have to transform its gradients
transform (if (and (= :path (:type shape)) (contains? shape :svg-transform))
(gmt/multiply transform (or (:svg-transform shape) (gmt/matrix)))
transform)
prefix-id
(fn [id]