yii2-binpacking2d A simple yet effective implementation of 2D bin packing for Yii2

  1. install
  2. how to use

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

0 0
2 followers
0 downloads
Yii Version: 2.0
License: BSD-2-Clause
Category: Others
Developed by: Elecen
Created on: Oct 5, 2014
Last updated: 6 years ago

Related Extensions