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

Merge pull request #3044 from penpot/azazeln28-improve-rotate-matrix

Improve rotate matrix
This commit is contained in:
Alejandro 2023-03-14 13:42:31 +01:00 committed by GitHub
commit b6e01077ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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)