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:
parent
59af707143
commit
847075cdc8
1 changed files with 17 additions and 0 deletions
|
@ -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."
|
||||
|
|
Loading…
Add table
Reference in a new issue