{"name":"potpack","version":"2.1.0","description":"A tiny library for packing 2D rectangles (for sprite layouts)","main":"index.js","type":"module","exports":"./index.js","types":"index.d.ts","sideEffects":false,"scripts":{"pretest":"eslint *.js","test":"tsc && node test.js","prepublishOnly":"npm test"},"repository":{"type":"git","url":"git+https://github.com/mapbox/potpack.git"},"keywords":["algorithms","sprites","bin packing","geometry","rectangles"],"author":{"name":"Vladimir Agafonkin"},"license":"ISC","bugs":{"url":"https://github.com/mapbox/potpack/issues"},"homepage":"https://mapbox.github.io/potpack/","devDependencies":{"@mapbox/shelf-pack":"^3.2.0","bin-pack":"^1.0.2","eslint":"^9.31.0","eslint-config-mourner":"^4.0.2","typescript":"^5.8.3"},"_id":"potpack@2.1.0","gitHead":"e06ed5c8808b1ab91942ac2ff7df7a9bfcfb3f30","_nodeVersion":"20.19.3","_npmVersion":"11.3.0","dist":{"integrity":"sha512-pcaShQc1Shq0y+E7GqJqvZj8DTthWV1KeHGdi0Z6IAin2Oi3JnLCOfwnCo84qc+HAp52wT9nK9H7FAJp5a44GQ==","shasum":"fe548e2f9061e9937f17191c1ab6dd98ca30e02f","tarball":"http://registry-npm.ywwl.com/potpack/download/potpack-2.1.0.tgz","fileCount":5,"unpackedSize":8467,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCeBJq+P3XLCX3sxzIV2t7G9k25qETHKZY2HMGi1siq/AIgb9kD3lh7pghU4eYN0DsjPCthccdC/5KRJZxNkXVf51U="}],"size":3079,"noattachment":false,"key":"/potpack/-/potpack-2.1.0.tgz"},"_npmUser":{"name":"mourner","email":"agafonkin@gmail.com"},"directories":{},"maintainers":[{"name":"mourner","email":"agafonkin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/potpack_2.1.0_1752482485145_0.4499191159610578"},"_hasShrinkwrap":false,"readme":"# potpack\n\nA tiny JavaScript library for packing 2D rectangles into a near-square container,\nwhich is useful for generating CSS sprites and WebGL textures. Similar to [shelf-pack](https://github.com/mapbox/shelf-pack),\nbut static (you can't add items once a layout is generated), and aims for maximal space utilization.\n\nA variation of algorithms used in\n[rectpack2D](https://github.com/TeamHypersomnia/rectpack2D) and\n[bin-pack](https://github.com/bryanburgers/bin-pack),\nwhich are in turn based on\n[this article by Blackpawn](http://blackpawn.com/texts/lightmaps/default.html).\n\n## [Demo](https://mapbox.github.io/potpack/)\n\n## Example usage\n\n```js\nimport potpack from 'potpack';\n\nconst boxes = [\n    {w: 300, h: 50},\n    {w: 100, h: 200},\n    ...\n];\n\nconst {w, h, fill} = potpack(boxes);\n// w and h are resulting container's width and height;\n// fill is the space utilization value (0 to 1), higher is better\n\n// potpack mutates the boxes array: it's sorted by height,\n// and box objects are augmented with x, y coordinates:\nboxes[0]; // {w: 300, h: 50,  x: 100, y: 0}\nboxes[1]; // {w: 100, h: 200, x: 0,   y: 0}\n```\n\n## Install\n\nInstall with NPM: `npm install potpack`.\n\nPotpack is provided as a ES module, so it's only supported on modern browsers, excluding IE:\n\n```html\n<script type=\"module\">\nimport potpack from 'https://cdn.skypack.dev/potpack';\n...\n</script>\n```\n\nIn Node, you can't use `require` — only `import` in ESM-capable versions (v12.15+):\n\n```js\nimport potpack from 'potpack';\n```\n","publish_time":1752482485323,"_cnpm_publish_time":1752482485323,"dist-tags":{"latest":"2.1.0"}}