webamp/experiments/resizeAlgorithm/resizeUtils.js
2017-11-05 19:45:30 -08:00

18 lines
614 B
JavaScript

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;
}