PHP code example of dagmike / bin-packing
1. Go to this page and download the library: Download dagmike/bin-packing 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/ */
dagmike / bin-packing example snippets
use BinPacking\RectangleBinPack;
use BinPacking\Rectangle;
$bin = (new RectangleBinPack(1000, 1000))->init();
$packed = $bin->insert(new Rectangle(100, 100), "RectBestAreaFit");
if ($packed) {
echo "Item ({$packed->getWidth()}x{$packed->getHeight()}) packed at position ({$packed->getX()}, {$packed->getY()})";
} else {
echo "Unable to pack item";
}