From 84ef0a75e1908c4bf4f32a9904c0e4ae88df02ce Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 28 Sep 2016 22:06:18 +0200 Subject: [PATCH] Add `setup-proportions` function to geom helpers. --- src/uxbox/main/geom.cljs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/uxbox/main/geom.cljs b/src/uxbox/main/geom.cljs index fc3932ea7..022d50c2a 100644 --- a/src/uxbox/main/geom.cljs +++ b/src/uxbox/main/geom.cljs @@ -251,6 +251,23 @@ [shape index point] (assoc-in shape [:points index] point)) +;; --- Setup Proportions + +(declare setup-proportions-rect) + +(defn setup-proportions + [shape] + (case (:type shape) + :rect (setup-proportions-rect shape) + :icon (setup-proportions-rect shape) + :circle (setup-proportions-rect shape) + shape)) + +(defn setup-proportions-rect + [shape] + (let [{:keys [width height]} (size shape)] + (assoc shape :proportion (/ width height)))) + ;; --- Resize (Absolute) (declare resize-rect)