0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-13 08:11:30 -05:00

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) :y (:y1 shape))
(assoc $ :x (+ (:x1 shape) (:dx group 0))) (merge $ (size $))))
(assoc $ :y (+ (:y1 shape) (:dy group 0)))
(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)
(as-> shape $ y (+ y dy)]
(merge $ {:width width (as-> shape $
:height height (merge $ {:width width
:x (+ x (or (:dx group) 0)) :height height
:y (+ y (or (:dy group) 0)) :x x
}) :y y})
(container-rect $))))) (container-rect $))))
(defmethod outer-rect' :default (defmethod outer-rect' :default
[shape _] [shape _]