@mark1russell7/packing 0.2.15 → 0.2.16
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.d.ts.map +1 -1
- package/build/index.js +17 -11
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/src/pack.ts +22 -13
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["Item","Sides","ContractMeasureSpec","Direction","SelectLevel","SelectLevel","Portfolio","LayoutContainer","LayoutEdge","LayoutInput","ContainerTest","PackHard"],"sources":["../src/vector.ts","../src/rect.ts","../src/order.ts","../src/contract.ts","../src/space.ts","../src/maxrects.ts","../src/shelf.ts","../src/pack.ts","../src/skyline.ts","../src/free.ts","../src/push.ts","../src/metrics.ts","../src/measures.ts","../src/strategy.ts","../src/adapters.ts","../src/convert.ts","../src/registry.ts","../src/aspect-fit.ts","../src/select-key.ts","../src/portfolio.ts","../src/layout-input.ts","../src/portfolio-cell.ts","../src/portfolio-sets.ts","../src/portfolio-strategy.ts","../src/select.ts","../src/check.ts","../src/generators.ts","../src/corpus.ts"],"mappings":";;qBACa;;EAIX,YAAY,YAAO;;MAMf;MACA,EAAE;;MAEF;MACA,EAAE;;EAGN,IAAI,WAAW;;EAMf,MAAM,GAAG;;EAMT,IAAI,OAAO,SAAS;;EAKpB;;EAKA,SAAS;;EAKT,MAAM,KAAK,QAAQ,KAAK,SAAS;;SAQ1B,GAAG,iBAAiB;;SAKpB,IAAI,SAAS,WAAW;;SASxB,IAAI,SAAS,WAAW;;aASpB,YAAY;;;qBCxEZ,KAAK;;;EAKhB,KAAK;;EAEL;;EAEA;;EAEA;;;;;EAKA;;MAGI,YAAY;;MAEZ,QAAQ;;EAGZ;;EAEA;;EAGA,WAAW;;EAOX,YAAY,QAAQ;;EAMpB;;SAGO,OAAO,GAAG,OAAO,KAAK,OAAO,KAAK;;SAKlC,SAAS,GAAG,OAAO,KAAK,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","PackHard"],"sources":["../src/vector.ts","../src/rect.ts","../src/order.ts","../src/contract.ts","../src/space.ts","../src/maxrects.ts","../src/shelf.ts","../src/pack.ts","../src/skyline.ts","../src/free.ts","../src/push.ts","../src/metrics.ts","../src/measures.ts","../src/strategy.ts","../src/adapters.ts","../src/convert.ts","../src/registry.ts","../src/aspect-fit.ts","../src/select-key.ts","../src/portfolio.ts","../src/layout-input.ts","../src/portfolio-cell.ts","../src/portfolio-sets.ts","../src/portfolio-strategy.ts","../src/select.ts","../src/check.ts","../src/generators.ts","../src/corpus.ts"],"mappings":";;qBACa;;EAIX,YAAY,YAAO;;MAMf;MACA,EAAE;;MAEF;MACA,EAAE;;EAGN,IAAI,WAAW;;EAMf,MAAM,GAAG;;EAMT,IAAI,OAAO,SAAS;;EAKpB;;EAKA,SAAS;;EAKT,MAAM,KAAK,QAAQ,KAAK,SAAS;;SAQ1B,GAAG,iBAAiB;;SAKpB,IAAI,SAAS,WAAW;;SASxB,IAAI,SAAS,WAAW;;aASpB,YAAY;;;qBCxEZ,KAAK;;;EAKhB,KAAK;;EAEL;;EAEA;;EAEA;;;;;EAKA;;MAGI,YAAY;;MAEZ,QAAQ;;EAGZ;;EAEA;;EAGA,WAAW;;EAOX,YAAY,QAAQ;;EAMpB;;SAGO,OAAO,GAAG,OAAO,KAAK,OAAO,KAAK;;SAKlC,SAAS,GAAG,OAAO,KAAK,OAAO,KAAK;;SAKpC,YAAY,GAAG,OAAO,KAAK;;SAK3B,SAAS,GAAG,OAAO,KAAK;;SAKxB,UAAU,GAAG,OAAO,KAAK;;;;;;KC/DtB;;qBAGC,sBAAsB;;wBAGnB,aAAa,OAAO,aAAa,GAAG,GAAG,KAAK,IAAI,GAAG,KAAK;;wBCiBxD,SAAS,MAAM,KAAKA,oBAAkBC;;;;;;;wBAWtC,SAAS,MAAMD,SAAOA;;UC/BrB;WACN;WACA;;;UAIM;WACN;WACA;WACA;WACA;;;;;;;;;;;UAYM;;WAEN;;WAEA;;;;;WAKA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e;EACf,gBAAgB;EAChB,WAAW;EACX,OAAO;EACP;;;;;;qBAOW,UAAU,gBAAgB;;cA2BjC;;KAGM,mBAAmB;EAC7B,eAAe;;;;;;qBAOJ,YAAY,gBAAgB;;KA0B7B;EACV,eAAe;EACf;;;qBA0BW,SAAS,gBAAgB;;qBAWzB,WAAW,gBAAgB;;qBAS3B,OAAO,gBAAgB;;qBAUvB,WAAW,gBAAgB;;KAY5B;;KAGA;EAAmB,MAAM;EAAU;;;;;;;;;;;qBAoBlC,WAAW,gBAAgB;;qBAwF3B,qBAAqB;;;;;wBAMlB,UAAU,cAAc,mBAAmB;;UCxsB1C;;EAEf;;EAEA;;EAEA,SAAS;EACT;;;UAIe;EACf;EACA;EACA,MAAM;;;UAIS;EACf;;EAEA;;EAEA;IAAS;IAAmB;IAAiB,QAAQ;IAAiB;;EACtE,QAAQ;;;UAIO;EACf,UAAU;EACV,QAAQ;;;;;;wBAOM,OAAO,cAAc,gBAAgB,eAAe"}
|
package/build/index.js
CHANGED
|
@@ -1858,11 +1858,11 @@ function packSkylineInSpace(rects, outer, order, space) {
|
|
|
1858
1858
|
// src/pack.ts
|
|
1859
1859
|
/** The depth of the calls of `packInto`. Only the outer gap fill counts its rectangles as moves. */
|
|
1860
1860
|
let fillDepth = 0;
|
|
1861
|
-
function packInto(
|
|
1862
|
-
const unpacked = Rect.unpacked(
|
|
1861
|
+
function packInto(byOrder, region, offset, order) {
|
|
1862
|
+
const unpacked = Rect.unpacked(byOrder);
|
|
1863
1863
|
fillDepth++;
|
|
1864
1864
|
try {
|
|
1865
|
-
|
|
1865
|
+
packSortedRows(unpacked, region, order);
|
|
1866
1866
|
} finally {
|
|
1867
1867
|
fillDepth--;
|
|
1868
1868
|
}
|
|
@@ -1870,13 +1870,12 @@ function packInto(rects, region, offset, order) {
|
|
|
1870
1870
|
if (fillDepth === 0) countMove(MOVES.rows, placed.length);
|
|
1871
1871
|
for (const r of placed) r.translateBy(offset);
|
|
1872
1872
|
}
|
|
1873
|
-
function packRow(
|
|
1873
|
+
function packRow(byOrder, outer, order) {
|
|
1874
1874
|
const row = [];
|
|
1875
|
-
const byHeight = rects.toSorted(compareRects(order));
|
|
1876
1875
|
const fillGaps = order !== "input";
|
|
1877
1876
|
const rowRect = new Rect();
|
|
1878
1877
|
rowRect.size.set(outer.size.x, 0);
|
|
1879
|
-
for (const rect of
|
|
1878
|
+
for (const rect of byOrder) {
|
|
1880
1879
|
if (rect.wasPacked) continue;
|
|
1881
1880
|
if (rect.size.x > rowRect.size.x) {
|
|
1882
1881
|
if (outer.fixedSize && rect.size.x > outer.size.x) continue;
|
|
@@ -1884,7 +1883,7 @@ function packRow(rects, outer, order) {
|
|
|
1884
1883
|
outerLeft.position.setTo(rowRect.position);
|
|
1885
1884
|
outerLeft.size.set(outer.size.x - rowRect.position.x, rowRect.size.y);
|
|
1886
1885
|
outerLeft.fixedSize = true;
|
|
1887
|
-
if (fillGaps) packInto(
|
|
1886
|
+
if (fillGaps) packInto(byOrder, outerLeft, outer.position, order);
|
|
1888
1887
|
rowRect.position.set(0, rowRect.bottom());
|
|
1889
1888
|
rowRect.size.set(outer.size.x, 0);
|
|
1890
1889
|
row.length = 0;
|
|
@@ -1893,7 +1892,7 @@ function packRow(rects, outer, order) {
|
|
|
1893
1892
|
if (outer.fixedSize) continue;
|
|
1894
1893
|
outer.size.y += rect.size.y;
|
|
1895
1894
|
if (!outer.fixedWidth && !outer.size.x) outer.size.x = rect.size.x;
|
|
1896
|
-
Rect.resetPacked(
|
|
1895
|
+
Rect.resetPacked(byOrder);
|
|
1897
1896
|
return false;
|
|
1898
1897
|
}
|
|
1899
1898
|
row.push(rect);
|
|
@@ -1908,12 +1907,20 @@ function packRow(rects, outer, order) {
|
|
|
1908
1907
|
outerLeft.size.set(rectInRow.size.x, rowRect.size.y - rectInRow.size.y);
|
|
1909
1908
|
outerLeft.fixedWidth = true;
|
|
1910
1909
|
outerLeft.fixedSize = true;
|
|
1911
|
-
packInto(
|
|
1910
|
+
packInto(byOrder, outerLeft, outer.position, order);
|
|
1912
1911
|
}
|
|
1913
1912
|
}
|
|
1914
1913
|
return true;
|
|
1915
1914
|
}
|
|
1916
1915
|
/**
|
|
1916
|
+
* This function packs rows of rectangles that are in the order `order` already. A stable sort orders by the key and then
|
|
1917
|
+
* by the position in the input, and a filter keeps that order. Thus a gap fill gives the layout of a sort again.
|
|
1918
|
+
*/
|
|
1919
|
+
function packSortedRows(byOrder, outer, order) {
|
|
1920
|
+
for (const r of byOrder) if (r.locked) r.wasPacked = true;
|
|
1921
|
+
while (!packRow(byOrder, outer, order)) if (fillDepth === 0) clearMoves(MOVES.rows);
|
|
1922
|
+
}
|
|
1923
|
+
/**
|
|
1917
1924
|
* This function packs rectangles into an outer rectangle of a given width with a guillotine row packing. It does
|
|
1918
1925
|
* not change the width. Without `fixedSize`, the height grows until all rectangles fit. A `locked` rectangle keeps
|
|
1919
1926
|
* its position, but the rows do not go around it. `pack` sets the width first and then uses this function.
|
|
@@ -1925,8 +1932,7 @@ function packRows(rects, outer, options = {}) {
|
|
|
1925
1932
|
const order = options.sortOrder ?? "height-desc";
|
|
1926
1933
|
const space = options.space;
|
|
1927
1934
|
if (space !== void 0 && (!space.plain || rects.some((r) => r.locked))) return packRowsInSpace(rects, outer, order, space);
|
|
1928
|
-
|
|
1929
|
-
while (!packRow(rects, outer, order)) if (fillDepth === 0) clearMoves(MOVES.rows);
|
|
1935
|
+
packSortedRows(rects.toSorted(compareRects(order)), outer, order);
|
|
1930
1936
|
return outer;
|
|
1931
1937
|
}
|
|
1932
1938
|
/**
|