From 17cdaab2ccc528f5c68efd768886bc45839a46cc Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 28 Sep 2016 22:11:59 +0200 Subject: [PATCH] Add support for circle shape in size geom function. With minor private function naming refactor. --- src/uxbox/main/geom.cljs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/uxbox/main/geom.cljs b/src/uxbox/main/geom.cljs index 022d50c2a2..aa241eb2eb 100644 --- a/src/uxbox/main/geom.cljs +++ b/src/uxbox/main/geom.cljs @@ -130,24 +130,33 @@ ;; --- Size -(declare rect-size) +(declare size-rect) +(declare size-circle) (defn size "Calculate the size of the shape." [shape] (case (:type shape) - :text (rect-size shape) - :rect (rect-size shape) - :icon (rect-size shape) - :path (rect-size shape))) + :circle (size-circle shape) + :text (size-rect shape) + :rect (size-rect shape) + :icon (size-rect shape) + :path (size-rect shape))) -(defn- rect-size +(defn- size-rect "A specialized function for calculate size for rect-like shapes." [{:keys [x1 y1 x2 y2] :as shape}] {:width (- x2 x1) :height (- y2 y1)}) +(defn- size-circle + "A specialized function for calculate size + for circle shape." + [{:keys [rx ry]}] + {:width (* rx 2) + :height (* ry 2)}) + ;; --- Vertex Access (declare get-rect-vertext-point)