@mark1russell7/packing 0.2.9 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +22 -1
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/src/skyline.ts +24 -1
package/build/index.js
CHANGED
|
@@ -1716,6 +1716,9 @@ function packSkyline(rects, outer, options = {}) {
|
|
|
1716
1716
|
/**
|
|
1717
1717
|
* This function packs rectangles with a skyline in a free space. Each cell has a free range: the skyline is its start,
|
|
1718
1718
|
* and `limit` is its end. A cell with less room than the lowest rectangle left goes to its next free range.
|
|
1719
|
+
*
|
|
1720
|
+
* A rectangle that needs more cells than the outer rectangle has goes at the left edge. Its y is the first y where each
|
|
1721
|
+
* cell is free over its height. Then each cell starts after the rectangle, as in the plain skyline.
|
|
1719
1722
|
*/
|
|
1720
1723
|
function packSkylineInSpace(rects, outer, order, space) {
|
|
1721
1724
|
const width = Math.floor(outer.size.x);
|
|
@@ -1751,9 +1754,27 @@ function packSkylineInSpace(rects, outer, order, space) {
|
|
|
1751
1754
|
x = 0;
|
|
1752
1755
|
y = 0;
|
|
1753
1756
|
for (let i = 0; i < width; i++) if (Number.isFinite(skyline[i]) && skyline[i] > y) y = skyline[i];
|
|
1757
|
+
for (let moved = true; moved;) {
|
|
1758
|
+
moved = false;
|
|
1759
|
+
for (let i = 0; i < width; i++) {
|
|
1760
|
+
if (!Number.isFinite(skyline[i])) continue;
|
|
1761
|
+
const [s, e] = rangeOf(i, y);
|
|
1762
|
+
const next = s > y ? s : e < y + rh ? rangeOf(i, e)[0] : y;
|
|
1763
|
+
if (next > y && Number.isFinite(next)) {
|
|
1764
|
+
y = next;
|
|
1765
|
+
moved = true;
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
}
|
|
1754
1769
|
rect.position.set(x + ox, y + oy);
|
|
1755
1770
|
rect.wasPacked = true;
|
|
1756
|
-
|
|
1771
|
+
const top = y + rh;
|
|
1772
|
+
for (let i = 0; i < width; i++) {
|
|
1773
|
+
if (!Number.isFinite(skyline[i])) continue;
|
|
1774
|
+
if (top <= limit[i]) skyline[i] = top;
|
|
1775
|
+
else [skyline[i], limit[i]] = rangeOf(i, top);
|
|
1776
|
+
}
|
|
1777
|
+
outer.size.y = Math.max(outer.size.y, top);
|
|
1757
1778
|
continue;
|
|
1758
1779
|
}
|
|
1759
1780
|
let found = findWindow(skyline, width, rw, limit, rh);
|