{"_id":"bin-pack","_rev":"411064","name":"bin-pack","description":"A packing algorithm for 2D bin packing. Largely based on code and a blog post by Jake Gordon.","dist-tags":{"latest":"1.0.2"},"maintainers":[{"name":"bryanburgers","email":"bryan@burgers.io"}],"time":{"modified":"2021-08-04T05:08:41.000Z","created":"2014-02-19T16:03:31.474Z","1.0.2":"2016-02-26T12:37:44.555Z","1.0.1":"2014-02-21T20:51:09.993Z","1.0.0":"2014-02-19T16:03:31.474Z"},"users":{"bobonthenet":true,"vorg":true},"author":{"name":"Bryan Burgers","email":"bryan@burgers.io","url":"http://burgers.io"},"repository":{"type":"git","url":"git@github.com:bryanburgers/bin-pack.git"},"versions":{"1.0.2":{"name":"bin-pack","version":"1.0.2","description":"A packing algorithm for 2D bin packing. Largely based on code and a blog post by Jake Gordon.","author":{"name":"Bryan Burgers","email":"bryan@burgers.io","url":"http://burgers.io"},"main":"index.js","keywords":["bin","rectangle","square","sprite","pack"],"license":"MIT","homepage":"https://github.com/bryanburgers/bin-pack","bugs":{"url":"https://github.com/bryanburgers/bin-pack/issues"},"repository":{"type":"git","url":"git@github.com:bryanburgers/bin-pack.git"},"dependencies":{},"devDependencies":{"mocha":"~1.12.1"},"scripts":{"test":"node node_modules/mocha/bin/mocha"},"gitHead":"d8fdced4664838455d5b2b16ea1e7b731b0e80ff","_id":"bin-pack@1.0.2","_shasum":"c2a014edbf0bed70a3292062ed46577b96120679","_from":".","_npmVersion":"3.3.12","_nodeVersion":"5.3.0","_npmUser":{"name":"bryanburgers","email":"bryan.burgers@gmail.com"},"maintainers":[{"name":"bryanburgers","email":"bryan@burgers.io"}],"dist":{"shasum":"c2a014edbf0bed70a3292062ed46577b96120679","size":4851,"noattachment":false,"key":"/bin-pack/-/bin-pack-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/bin-pack/download/bin-pack-1.0.2.tgz"},"_npmOperationalInternal":{"host":"packages-5-east.internal.npmjs.com","tmp":"tmp/bin-pack-1.0.2.tgz_1456490263190_0.5052245715633035"},"directories":{},"publish_time":1456490264555,"_cnpm_publish_time":1456490264555,"_hasShrinkwrap":false},"1.0.1":{"name":"bin-pack","version":"1.0.1","description":"A packing algorithm for 2D bin packing. Largely based on code and a blog post by Jake Gordon.","author":{"name":"Bryan Burgers","email":"bryan@burgers.io","url":"http://burgers.io"},"main":"index.js","keywords":["bin","rectangle","square","sprite","pack"],"license":"MIT","homepage":"https://github.com/bryanburgers/bin-pack","bugs":{"url":"https://github.com/bryanburgers/bin-pack/issues"},"repository":{"type":"git","url":"git@github.com:bryanburgers/bin-pack.git"},"dependencies":{},"devDependencies":{"mocha":"~1.12.1"},"scripts":{"test":"node node_modules/mocha/bin/mocha"},"_id":"bin-pack@1.0.1","dist":{"shasum":"556da38f866f2aebe56ecb45f42849b084b0c66f","size":8394,"noattachment":false,"key":"/bin-pack/-/bin-pack-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/bin-pack/download/bin-pack-1.0.1.tgz"},"_from":".","_npmVersion":"1.2.17","_npmUser":{"name":"bryanburgers","email":"bryan.burgers@gmail.com"},"maintainers":[{"name":"bryanburgers","email":"bryan@burgers.io"}],"directories":{},"publish_time":1393015869993,"_cnpm_publish_time":1393015869993,"_hasShrinkwrap":false},"1.0.0":{"name":"bin-pack","version":"1.0.0","description":"A packing algorithm for 2D bin packing. Largely based on code and a blog post by Jake Gordon.","author":{"name":"Bryan Burgers","email":"bryan@burgers.io","url":"http://burgers.io"},"main":"index.js","keywords":["bin","rectangle","square","sprite","pack"],"license":"MIT","repository":{"type":"git","url":"bryanburgers/bin-pack"},"dependencies":{},"devDependencies":{"mocha":"~1.12.1"},"scripts":{"test":"node node_modules/mocha/bin/mocha"},"_id":"bin-pack@1.0.0","dist":{"shasum":"72383da8f86b06fcd55df4e533bd132e60ed8b8a","size":8426,"noattachment":false,"key":"/bin-pack/-/bin-pack-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/bin-pack/download/bin-pack-1.0.0.tgz"},"_from":".","_npmVersion":"1.2.17","_npmUser":{"name":"bryanburgers","email":"bryan.burgers@gmail.com"},"maintainers":[{"name":"bryanburgers","email":"bryan@burgers.io"}],"directories":{},"publish_time":1392825811474,"_cnpm_publish_time":1392825811474,"_hasShrinkwrap":false}},"readme":"# Bin Pack\n\n[![Build Status](https://travis-ci.org/bryanburgers/bin-pack.png?branch=master)](https://travis-ci.org/bryanburgers/bin-pack)\n\nA packing algorithm for 2D bin packing. Largely based on [code][code] and a\n[blog post][post] by Jake Gordon.\n\nThis library packs objects that have a width and a height into as small of a\nsquare as possible, using a binary tree bin packing algorithm. After packing,\neach object is given an (x, y) coordinate of where it would be optimally\npacked.\n\nThe algorithm may not find the *optimal* bin packing, but it should do pretty\nwill for things like sprite maps.\n\n## Installation\n\n```\nnpm install bin-pack\n```\n\n## Use\n\n```\nvar pack = require('bin-pack');\nvar bins = [\n\t{ width: 10,  height: 20 },\n\t{ width: 100, height: 100 },\n\t{ width: 50,  height: 19 },\n\t...\n\t];\n\nvar result = pack(bins);\n\n// result.width: width of the containing box\n// result.height: height of the containing box\n// result.items: packed items\n// result.items[0].x: x coordinate of the packed box\n// result.items[0].y: y coordinate of the packed box\n// result.items[0].width: width of the packed box\n// result.items[0].height: height of the packed box\n// result.items[0].item: original object that was passed in\n```\n\nIf your object doesn't have `x` and `y` properties, and you don't mind a\nlibrary writing to your objects, then specify `inPlace: true` and your objects\nwill have a `x` and `y` properties added to them.\n\n```\nvar pack = require('bin-pack');\nvar bins = [\n\t{ width: 10,  height: 20 },\n\t{ width: 100, height: 100 },\n\t{ width: 50,  height: 19 },\n\t...\n\t];\n\nvar result = pack(bins, { inPlace: true });\n// result.width: width of the containing box\n// result.height: height of the containing box\n// bins[0].x: x coordinate of the packed box\n// bins[0].y: y coordinate of the packed box\n```\n\n## Contributing\n\nContributing tests, documentation, or code is all appreciated. All code should\nbe accompanied by valid tests.\n\n[code]: https://github.com/jakesgordon/bin-packing\n[post]: http://codeincomplete.com/posts/2011/5/7/bin_packing/\n","_attachments":{},"homepage":"https://github.com/bryanburgers/bin-pack","bugs":{"url":"https://github.com/bryanburgers/bin-pack/issues"},"license":"MIT"}