From a1ee857caac36631ca8418fcbd202db531859d01 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Sat, 23 Jan 2016 22:08:56 +0200 Subject: [PATCH] Add explicit function for apply rotation. --- src/uxbox/shapes.cljs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/uxbox/shapes.cljs b/src/uxbox/shapes.cljs index 90b718b9f..609a8c12f 100644 --- a/src/uxbox/shapes.cljs +++ b/src/uxbox/shapes.cljs @@ -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))