mirror of
https://github.com/penpot/penpot.git
synced 2025-08-06 12:38:33 +02: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
|
:x x
|
||||||
:y y}))
|
: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
|
(defn translate-coords
|
||||||
"Given a shape and initial coords, transform
|
"Given a shape and initial coords, transform
|
||||||
it mapping its coords to new provided initial coords."
|
it mapping its coords to new provided initial coords."
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue