Skip to content

Commit

Permalink
Added syntax highlighting to example
Browse files Browse the repository at this point in the history
  • Loading branch information
munro committed Aug 10, 2012
1 parent e44a40b commit 8ae802a
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions README.md
Expand Up @@ -4,25 +4,27 @@ Bin packing algorithm!

## Example

var bin = boxpack();

var boxes = bin.pack([
{width: 50, height: 100},
{width: 75, height: 75},
{width: 25, height: 25},
{width: 100, height: 100}
]);

document.getElementById('result').innerHTML = boxes.map(function (box) {
return '<div style="' +
'position:absolute;' +
'border:1px solid black;' +
'left:' + box.x + 'px;' +
'top:' + box.y + 'px;' +
/* subtract border from width & height */
'width:' + (box.width - 2) + 'px;' +
'height:' + (box.height - 2) + 'px"></div>';
}).join('');
```javascript
var bin = boxpack();

var boxes = bin.pack([
{width: 50, height: 100},
{width: 75, height: 75},
{width: 25, height: 25},
{width: 100, height: 100}
]);

document.getElementById('result').innerHTML = boxes.map(function (box) {
return '<div style="' +
'position:absolute;' +
'border:1px solid black;' +
'left:' + box.x + 'px;' +
'top:' + box.y + 'px;' +
/* subtract border from width & height */
'width:' + (box.width - 2) + 'px;' +
'height:' + (box.height - 2) + 'px"></div>';
}).join('');
```

## Downloads

Expand Down

0 comments on commit 8ae802a

Please sign in to comment.