NAME

CSS::SpriteMaker::Layout::Utils::BinPacking - Attempt to optimally pack multiple boxes into a rectangular bin.

Basically, a Perl port of packer.growing.js (https://npmjs.org/package/binpacking)

VERSION

Version 0.01

SYNOPSIS

use CSS::SpriteMaker::BinPacking;

# initialize the packer
my $Packer = CSS::SpriteMaker::BinPacking->new();

# create some blocks
my @blocks = (
    { w => 120 , h => 150 },
    { w => 64 , h => 64 },
    { w => 80 , h => 40 },
    { w => 100 , h => 200 },
    { w => 56 , h => 50 },
);

# fit the blocks into a rectangular bin
$Packer->fit(\@blocks);

METHODS

new

fit

find_node

split_node

grow_node

grow_right

grow_down