mirror of
https://github.com/penpot/penpot.git
synced 2026-08-01 19:06:18 +00:00
Add outer-rect function helper.
This commit is contained in:
parent
59af707143
commit
847075cdc8
@ -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…
x
Reference in New Issue
Block a user