From adfe4c3945b8dfc3a633adbc745f81c74859ed17 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 14 Apr 2026 19:37:12 +0000 Subject: [PATCH] :bug: Fix update-rect :size and unqualified abs in corners->rect update-rect with :size type was only updating :x2 and :y2 but not :x1 and :y1, leaving the Rect record in an inconsistent state (x1/y1 would not match x/y). Aligned its behaviour with update-rect! which correctly updates all four corner fields. corners->rect was calling unqualified abs which is not imported in app.common.geom.rect namespace. Replaced with mth/abs which is the proper namespaced version already available in the ns require. Signed-off-by: Andrey Antukh --- common/src/app/common/geom/rect.cljc | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/common/src/app/common/geom/rect.cljc b/common/src/app/common/geom/rect.cljc index 925c784e65..f53024ca02 100644 --- a/common/src/app/common/geom/rect.cljc +++ b/common/src/app/common/geom/rect.cljc @@ -119,12 +119,14 @@ (defn update-rect [rect type] (case type - :size + (:size :position) (let [x (dm/get-prop rect :x) y (dm/get-prop rect :y) w (dm/get-prop rect :width) h (dm/get-prop rect :height)] (assoc rect + :x1 x + :y1 y :x2 (+ x w) :y2 (+ y h))) @@ -137,19 +139,7 @@ :x (mth/min x1 x2) :y (mth/min y1 y2) :width (mth/abs (- x2 x1)) - :height (mth/abs (- y2 y1)))) - - ;; FIXME: looks unused - :position - (let [x (dm/get-prop rect :x) - y (dm/get-prop rect :y) - w (dm/get-prop rect :width) - h (dm/get-prop rect :height)] - (assoc rect - :x1 x - :y1 y - :x2 (+ x w) - :y2 (+ y h))))) + :height (mth/abs (- y2 y1)))))) (defn update-rect! [rect type] @@ -382,8 +372,8 @@ ([xp1 yp1 xp2 yp2] (make-rect (mth/min xp1 xp2) (mth/min yp1 yp2) - (abs (- xp1 xp2)) - (abs (- yp1 yp2))))) + (mth/abs (- xp1 xp2)) + (mth/abs (- yp1 yp2))))) (defn clip-rect [selrect bounds]