{"name":"potpack","version":"1.0.2","description":"A tiny library for packing 2D rectangles (for sprite layouts)","main":"index","module":"index.mjs","unpkg":"index.js","jsdelivr":"index.js","types":"index.d.ts","scripts":{"pretest":"eslint index.mjs test.mjs bench.mjs","test":"node -r esm test.mjs","bench":"node -r esm bench.mjs","build":"rollup -c","start":"rollup -w","prepublishOnly":"npm run build"},"eslintConfig":{"extends":"mourner"},"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","@rollup/plugin-buble":"^0.21.3","bin-pack":"^1.0.2","eslint":"^8.0.1","eslint-config-mourner":"^3.0.0","esm":"^3.2.25","rollup":"^2.58.0","tape":"^5.3.1"},"gitHead":"b2df24995f43740e362a1ceb2ad25da77e44dd88","_id":"potpack@1.0.2","_nodeVersion":"14.18.0","_npmVersion":"7.24.1","dist":{"integrity":"sha512-choctRBIV9EMT9WGAZHn3V7t0Z2pMQyl0EZE6pFc/6ml3ssw7Dlf/oAOvFwjm1HVsqfQN8GfeFyJ+d8tRzqueQ==","shasum":"23b99e64eb74f5741ffe7656b5b5c4ddce8dfc14","tarball":"http://registry-npm.ywwl.com/potpack/download/potpack-1.0.2.tgz","fileCount":6,"unpackedSize":11008,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh23CWCRA9TVsSAnZWagAA8xMP/20Wsyz5tpxcQC/sSrZT\n1CqHf9g6dCdpnQp0xC1fc4R3K7yYCaIwKj/7lPigI/jkwrtofEjd+NaELU/y\nn5IjlL9zQJ8YUEeai3ceDiKdR9qPWdW01nooehNR+ou4AUX1/GDYHdUEBhhp\n+sRtTm2uajw6/PShtg+7FCFDiEOjWbzIb5rBGyKv7N0vi6ALS1GAf10oLTdK\n/C39WDla0mnJup1xBCw2VWo8YsaTSHf2v3rNPlFFl3Q81ZJcMlmlGyHRHf+J\nsUroN5vgAwOWnupKcx1VQhnZnHoMg15m+k5ml/V6EDGCX5a++YZT2vWhdZNc\nWmGSwF6KvYB8Pzkm7OLSwizReUf2/bqKLuwZ+1ivx/RjeKL93qgzg8bpCU2e\nhUBSzD/kW1IW8POkFtkVCS+nDKEDJoxEmD6ZyuKYl2jIDC1nNzm2CO6mJp8D\nndAmCuZFasWoJqbMNfoUOLl9ocIddAYa78pcTF/9Oo5ENrw6hHjZTYHz+mNq\nwB/bQjzaMa38vZRybgrGI3Gk8QvYHqIWV5zr6+26SUmtY9/LQ/ZkTXnjDdaK\nGYMQETa8EDnVYD9cVlLUFqIfpSVoiInN02Or2/m4Gm/Ab71H6p3lXyv8I3jL\nYfVkadWWPIeEuBLhop3OXSDljv8uFEdcnr9PG9USzOsDDx+ghkFKYaon4Rcr\n5M6D\r\n=dLZq\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDJrQNumx0QWWVKq9T4BXsKi+dZmX6LJOKi/56CDsxe3wIgKKRQqyZq3iH0TSnpe4H3mjuBCX9wk5zW1tf9PrzGZIU="}],"size":3440,"noattachment":false,"key":"/potpack/-/potpack-1.0.2.tgz"},"_npmUser":{"name":"mourner","email":"agafonkin@gmail.com"},"directories":{},"maintainers":[{"name":"mourner","email":"agafonkin@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/potpack_1.0.2_1634891214911_0.16557632626017038"},"_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":1634891215083,"_cnpm_publish_time":1634891215083,"dist-tags":{"latest":"2.1.0"}}