mirror of
https://github.com/penpot/penpot.git
synced 2026-02-12 22:53:02 +00:00
Add explicit function for apply rotation.
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user