{"dist":{"shasum":"080734832eab86cd9ee8260d2171a5145d072d18","tarball":"https://registry.npmjs.org/boxpack/-/boxpack-0.1.0.tgz","integrity":"sha512-2voo6+kPfiF/QnWjQ/Sg3x1lrO1IOoV9EXVjclPJYWCZyxIbAl3ukAhhi7LFlajO9g5sxsh2IHl81ghbnyzW+w==","signatures":[{"sig":"MEUCIHZs83g2y6xs66dEN/pQIwfwtxwIavrJ0kcL4MXWxm1+AiEAqEGg4hC6Qa6vNuHzFq6IC159/Y5kEDYCqqPVxq6Eino=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"boxpack.js","name":"boxpack","author":{"name":"Ryan Munro"},"readme":"# Boxpack—Bin packing algorithm! [![Build Status](https://secure.travis-ci.org/munro/boxpack.png?branch=master)](http://travis-ci.org/munro/boxpack)\n\nBin packing algorithm!\n\n## Example\n\n```javascript\nvar bin = boxpack();\n\nvar boxes = bin.pack([\n    {width: 50, height: 100},\n    {width: 75, height: 75},\n    {width: 25, height: 25},\n    {width: 100, height: 100}\n]);\n\ndocument.getElementById('result').innerHTML = boxes.map(function (box) {\n    return '<div style=\"' +\n        'position:absolute;' +\n        'border:1px solid black;' +\n        'left:' + box.x + 'px;' +\n        'top:' + box.y + 'px;' +\n        /* subtract border from width & height */\n        'width:' + (box.width - 2) + 'px;' +\n        'height:' + (box.height - 2) + 'px\"></div>';\n}).join('');\n```\n\n## Data structures\n\n### {Rect} `{width: {Number}, height: {Number}}`\n\nDefines rectangles that we want to pack in a bin.\n\n### {Box} `{x: {Number}, y: {Number}, width: {Number}, height: {Number}}`\n\nDefines where a rectangle was packed in a bin.\n\n## Bin methods\n\n### var bin = boxpack({Object} options)\n\nCreates a new bin for packing rects into.\n\n### var result = bin.pack({width: 50, height: 100})\n\n`result` will return `false` if there was no room left to pack the `Rect`.\nOtherwise it will return `Box`\n\n## Weighting algorithms\n\n### boxpack.algo.dist\n\nSorts boxes based on their distance from (0, 0)\n\n### boxpack.algo.top\n\nSorts boxes based on their distance from the X-axis\n\n### boxpack.algo.left\n\nSorts boxes based on their distance from the Y-axis\n\n## Helper functions\n\n### boxpack.rectFit({Rect}, {Box}) -> {Boolean}\n### boxpack.boxFit({Box}, {Box}) -> {Boolean}\n### boxpack.intersect({Box}, {Box}) -> {Boolean}\n### boxpack.divideX({Box}, {Number}) -> {Array {Box}}\n### boxpack.divideY({Box}, {Number}) -> {Array {Box}}\n### boxpack.subtract({Box}, {Box}) -> {Array {Box}}\n\n## License\n\nMIT\n","license":"BSD","scripts":{"test":"tap test.js"},"keywords":["box","bin","pack","rect"],"repository":{"url":"https://github.com/munro/boxpack.git","type":"git"},"description":"Bin packing algorithm for rectangles","maintainers":[{"name":"munro","email":"munro.github@gmail.com"}],"dependencies":{},"devDependencies":{"tap":"~0.3.0"},"_id":"boxpack@0.1.0","version":"0.1.0"}