0
Fork 0
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:
Andrey Antukh 2016-01-23 22:08:56 +02:00
parent 7301a774a4
commit a1ee857caa

View file

@ -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))