0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-22 06:46:40 -05:00

improve rotate matrix

This commit is contained in:
Aitor 2023-03-14 13:05:52 +01:00
parent 1b3281457e
commit 538a05b359

View file

@ -198,10 +198,17 @@
(defn rotate-matrix
([angle point]
(-> (matrix)
(multiply! (translate-matrix point))
(multiply! (rotate-matrix angle))
(multiply! (translate-matrix (gpt/negate point)))))
(let [cx (dm/get-prop point :x)
cy (dm/get-prop point :y)
nx (- cx)
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]
(let [a (mth/radians angle)]
(Matrix. (mth/cos a)