mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02: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
|
;; 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
|
(defn container-rect
|
||||||
[{:keys [x y width height rotation] :as shape}]
|
[{:keys [x y width height rotation] :as shape}]
|
||||||
(let [center-x (+ x (/ width 2))
|
(let [center-x (+ x (/ width 2))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue