mirror of
https://github.com/penpot/penpot.git
synced 2025-02-18 13:04:38 -05:00
🐛 Fix rotation transformation on image shape.
This commit is contained in:
parent
866da08cab
commit
de09217e30
1 changed files with 14 additions and 6 deletions
|
@ -8,13 +8,13 @@
|
||||||
(:require
|
(:require
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
|
[cuerdas.core :as str]
|
||||||
[uxbox.main.data.images :as udi]
|
[uxbox.main.data.images :as udi]
|
||||||
[uxbox.main.geom :as geom]
|
[uxbox.main.geom :as geom]
|
||||||
[uxbox.main.refs :as refs]
|
[uxbox.main.refs :as refs]
|
||||||
[uxbox.main.store :as st]
|
[uxbox.main.store :as st]
|
||||||
[uxbox.main.ui.shapes.attrs :as attrs]
|
[uxbox.main.ui.shapes.attrs :as attrs]
|
||||||
[uxbox.main.ui.shapes.common :as common]
|
[uxbox.main.ui.shapes.common :as common]
|
||||||
[uxbox.util.data :refer [classnames normalize-props]]
|
|
||||||
[uxbox.util.geom.matrix :as gmt]))
|
[uxbox.util.geom.matrix :as gmt]))
|
||||||
|
|
||||||
;; --- Refs
|
;; --- Refs
|
||||||
|
@ -47,17 +47,25 @@
|
||||||
|
|
||||||
(mf/defc image-shape
|
(mf/defc image-shape
|
||||||
[{:keys [shape image] :as props}]
|
[{:keys [shape image] :as props}]
|
||||||
(let [{:keys [id x y width height modifier-mtx]} shape
|
(let [{:keys [id rotation modifier-mtx]} shape
|
||||||
moving? (boolean modifier-mtx)
|
|
||||||
transform (when (gmt/matrix? modifier-mtx)
|
shape (cond
|
||||||
(str modifier-mtx))
|
(gmt/matrix? modifier-mtx) (geom/transform shape modifier-mtx)
|
||||||
|
:else shape)
|
||||||
|
|
||||||
|
{:keys [x y width height]} shape
|
||||||
|
|
||||||
|
transform (when (and rotation (pos? rotation))
|
||||||
|
(str/format "rotate(%s %s %s)"
|
||||||
|
rotation
|
||||||
|
(+ x (/ width 2))
|
||||||
|
(+ y (/ height 2))))
|
||||||
|
|
||||||
props (-> (attrs/extract-style-attrs shape)
|
props (-> (attrs/extract-style-attrs shape)
|
||||||
(assoc :x x
|
(assoc :x x
|
||||||
:y y
|
:y y
|
||||||
:id (str "shape-" id)
|
:id (str "shape-" id)
|
||||||
:preserveAspectRatio "none"
|
:preserveAspectRatio "none"
|
||||||
:className (classnames :move-cursor moving?)
|
|
||||||
:xlinkHref (:url image)
|
:xlinkHref (:url image)
|
||||||
:transform transform
|
:transform transform
|
||||||
:width width
|
:width width
|
||||||
|
|
Loading…
Add table
Reference in a new issue