mirror of
https://github.com/penpot/penpot.git
synced 2025-02-23 15:26:29 -05:00
✨ improve rotate matrix
This commit is contained in:
parent
1b3281457e
commit
538a05b359
1 changed files with 11 additions and 4 deletions
|
@ -198,10 +198,17 @@
|
||||||
|
|
||||||
(defn rotate-matrix
|
(defn rotate-matrix
|
||||||
([angle point]
|
([angle point]
|
||||||
(-> (matrix)
|
(let [cx (dm/get-prop point :x)
|
||||||
(multiply! (translate-matrix point))
|
cy (dm/get-prop point :y)
|
||||||
(multiply! (rotate-matrix angle))
|
nx (- cx)
|
||||||
(multiply! (translate-matrix (gpt/negate point)))))
|
ny (- cy)
|
||||||
|
a (mth/radians angle)
|
||||||
|
c (mth/cos a)
|
||||||
|
s (mth/sin a)
|
||||||
|
ns (- s)
|
||||||
|
tx (+ (* c nx) (* ns ny) cx)
|
||||||
|
ty (+ (* s nx) (* c ny) cy)]
|
||||||
|
(Matrix. c s ns c tx ty)))
|
||||||
([angle]
|
([angle]
|
||||||
(let [a (mth/radians angle)]
|
(let [a (mth/radians angle)]
|
||||||
(Matrix. (mth/cos a)
|
(Matrix. (mth/cos a)
|
||||||
|
|
Loading…
Add table
Reference in a new issue