1. Go to this page and download the library: Download padam87/bin-packer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
padam87 / bin-packer example snippets
$bin = new Bin(1000, 1000);
$blocks = [
new Block(100, 100),
new Block(300, 100),
new Block(175, 125),
new Block(200, 75),
new Block(200, 75),
];
$packer = new BinPacker();
$blocks = $packer->pack($bin, $blocks);
foreach ($blocks as $block) {
if ($block->getNode() && $block->getNode()->isUsed()) {
// packed
}
}
new Block(100, 100, false);
new Block(100, 100, false, 'My id, can be anything.');
$bin = new Bin(1000, 1000, true);
$bin = new Bin(1000, 1000);
$blocks = [
new Block(100, 100),
new Block(300, 100),
new Block(175, 125),
new Block(200, 75),
new Block(200, 75),
];
$packer = new BinPacker();
$blocks = $packer->pack($bin, $blocks);
$image = $visualizer->visualize($bin, $blocks);