install ¶
in your composer.json under the required section add
"ptheofan/binpacking2d": "dev-master"
how to use ¶
use ptheofan\binpacking2d\BinPacking;
use ptheofan\binpacking2d\Node;
$bin = new BinPacking();
$nodes = $bin->fit([
new Node2D['w' => 100, 'h' => 50],
new Node2D['w' => 140, 'h' => 30],
new Node2D['w' => 100, 'h' => 50],
new Node2D['w' => 30, 'h' => 50],
new Node2D['w' => 30, 'h' => 50],
new Node2D['w' => 30, 'h' => 50],
]);
foreach($nodes as $node)
print_r(['x' => $node->x, 'y' => $node->y, 'w' => $node->w, 'h' => $node->h]);
For information and details visit the github repository page
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.