0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-13 10:38:13 -05:00

🐛 Fix rotation of path and curve shapes.

This commit is contained in:
Andrey Antukh 2020-01-30 13:28:27 +01:00
parent 85f4d4824f
commit 8d99bd723b
2 changed files with 16 additions and 8 deletions

View file

@ -575,6 +575,7 @@
xf-resolve-shapes
(comp (map shape->rect-shape)
(map resolve-modifier)
(map shape->rect-shape)
(map resolve-rotation)
(map shape->rect-shape)))

View file

@ -62,23 +62,30 @@
(mf/defc path-shape
[{:keys [shape background?] :as props}]
(let [modifier-mtx (:modifier-mtx shape)
rotation (:rotation shape)
shape (cond
(gmt/matrix? modifier-mtx) (geom/transform shape modifier-mtx)
:else shape)
moving? (boolean modifier-mtx)
{:keys [id x y width height]} (geom/shape->rect-shape shape)
transform (when (and rotation (pos? rotation))
(str/format "rotate(%s %s %s)"
rotation
(+ x (/ width 2))
(+ y (/ height 2))))
pdata (render-path shape)
props {:id (str (:id shape))
:class (classnames :move-cursor moving?)
:d pdata}
attrs (merge (attrs/extract-style-attrs shape) props)]
props (-> (attrs/extract-style-attrs shape)
(assoc :transform transform
:id (str "shape-" id)
:d pdata))]
(if background?
[:g
[:path {:stroke "transparent"
:fill "transparent"
:stroke-width "20px"
:d pdata}]
[:> :path (normalize-props attrs)]]
[:> :path (normalize-props attrs)])))
[:& "path" props]]
[:& "path" props])))