From 847075cdc82e97cd388e616b0cb425271c9ce12b Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Sat, 23 Jan 2016 22:10:41 +0200 Subject: [PATCH] Add outer-rect function helper. --- src/uxbox/shapes.cljs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/uxbox/shapes.cljs b/src/uxbox/shapes.cljs index 1c01ba9d1..dfa38bfc6 100644 --- a/src/uxbox/shapes.cljs +++ b/src/uxbox/shapes.cljs @@ -181,6 +181,23 @@ :x x :y y})) +(declare resolve-position) + +(defn outer-rect + [shapes] + {:pre [(seq shapes)]} + (let [shapes (map -outer-rect shapes) + x (apply min (map :x shapes)) + y (apply min (map :y shapes)) + x' (apply max (map (fn [{:keys [x width]}] (+ x width)) shapes)) + y' (apply max (map (fn [{:keys [y height]}] (+ y height)) shapes)) + width (- x' x) + height (- y' y)] + {:width width + :height height + :x x + :y y})) + (defn translate-coords "Given a shape and initial coords, transform it mapping its coords to new provided initial coords."