mirror of
https://github.com/penpot/penpot.git
synced 2025-04-16 00:41:25 -05:00
Add explicit function for apply rotation.
This commit is contained in:
parent
7301a774a4
commit
a1ee857caa
1 changed files with 11 additions and 0 deletions
|
@ -70,6 +70,17 @@
|
|||
;; Helpers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn apply-rotation
|
||||
[[x y :as v] rotation]
|
||||
(let [angle (mth/radians rotation)
|
||||
rx (- (* x (mth/cos angle))
|
||||
(* y (mth/sin angle)))
|
||||
ry (+ (* x (mth/sin angle))
|
||||
(* y (mth/cos angle)))]
|
||||
(let [r [(mth/precision rx 6)
|
||||
(mth/precision ry 6)]]
|
||||
r)))
|
||||
|
||||
(defn container-rect
|
||||
[{:keys [x y width height rotation] :as shape}]
|
||||
(let [center-x (+ x (/ width 2))
|
||||
|
|
Loading…
Add table
Reference in a new issue