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