Start sketching out new resize algo

This commit is contained in:
Jordan Eldredge 2017-11-05 19:44:42 -08:00
parent 8a13222aa0
commit 797aeffa17
3 changed files with 374 additions and 0 deletions

View file

@ -0,0 +1,18 @@
export function double(boxes) {
const doubledBoxes = new Map();
// Find the top/left most box
// Update the width/height of the first box.
// Find any boxes that are touching the bottom of that box
// Move those boxes down
// Find any boxes that are touching the right of that box
// Move those boxes right
// Repeat for boxes that are touching
// Resize any remaining boxes
for (const [key, box] of boxes) {
const width = box.width * 2;
const height = box.height * 2;
const top = box.top * 2;
doubledBoxes.set(key, { ...box, top, width, height });
}
return doubledBoxes;
}