Simplified outer rect calculation.

This commit is contained in:
Andrey Antukh 2016-02-28 09:28:21 +02:00
parent 11e399ae21
commit a9186bfbaa

View file

@ -230,12 +230,9 @@
(defmethod outer-rect' ::shape (defmethod outer-rect' ::shape
[{:keys [group] :as shape}] [{:keys [group] :as shape}]
(let [group (get-in @st/state [:shapes-by-id group])]
(as-> shape $ (as-> shape $
(assoc $ :x (+ (:x1 shape) (:dx group 0))) (assoc $ :x (:x1 shape) :y (:y1 shape))
(assoc $ :y (+ (:y1 shape) (:dy group 0))) (merge $ (size $))))
(merge $ (size $))
(container-rect $))))
(defmethod outer-rect' :builtin/line (defmethod outer-rect' :builtin/line
[{:keys [x1 y1 x2 y2 group] :as shape}] [{:keys [x1 y1 x2 y2 group] :as shape}]
@ -267,15 +264,15 @@
x' (apply max (map (fn [{:keys [x width]}] (+ x width)) shapes)) x' (apply max (map (fn [{:keys [x width]}] (+ x width)) shapes))
y' (apply max (map (fn [{:keys [y height]}] (+ y height)) shapes)) y' (apply max (map (fn [{:keys [y height]}] (+ y height)) shapes))
width (- x' x) width (- x' x)
height (- y' y)] height (- y' y)
(let [group (get-in @st/state [:shapes-by-id group])] x (+ x dx)
y (+ y dy)]
(as-> shape $ (as-> shape $
(merge $ {:width width (merge $ {:width width
:height height :height height
:x (+ x (or (:dx group) 0)) :x x
:y (+ y (or (:dy group) 0)) :y y})
}) (container-rect $))))
(container-rect $)))))
(defmethod outer-rect' :default (defmethod outer-rect' :default
[shape _] [shape _]