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:
commit
b6e01077ed
1 changed files with 11 additions and 4 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue