mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-25 11:04:00 +00:00
Start sketching out new resize algo
This commit is contained in:
parent
8a13222aa0
commit
797aeffa17
3 changed files with 374 additions and 0 deletions
18
experiments/resizeAlgorithm/resizeUtils.js
Normal file
18
experiments/resizeAlgorithm/resizeUtils.js
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue