0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 23:49:45 -05:00

Add outer-rect function helper.

This commit is contained in:
Andrey Antukh 2016-01-23 22:10:41 +02:00
parent 59af707143
commit 847075cdc8

View file

@ -181,6 +181,23 @@
:x x
:y y}))
(declare resolve-position)
(defn outer-rect
[shapes]
{:pre [(seq shapes)]}
(let [shapes (map -outer-rect shapes)
x (apply min (map :x shapes))
y (apply min (map :y shapes))
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)]
{:width width
:height height
:x x
:y y}))
(defn translate-coords
"Given a shape and initial coords, transform
it mapping its coords to new provided initial coords."