Algorithm-BinPack-2D

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    Algorithm::BinPack::2D - efficiently pack items into rectangles

SYNOPSIS
    `Algorithm::BinPack::2D' efficiently packs items into bins. The bins are
    given a maximum width and height, and items are packed in with as little
    empty space as possible. An example use would be backing up small images
    to concatenated images, while minimizing the number of images required.

        my $bp = Algorithm::BinPack::2D->new(binwidth => 512, binheight => 512);

        $bp->add_item(label => "one.png",   width =>  30, height =>  10);
        $bp->add_item(label => "two.png",   width => 200, height =>  40);
        $bp->add_item(label => "three.png", width =>  30, height => 300);
        $bp->add_item(label => "four.png",  width => 400, height => 100);

        for ($bp->pack_bins) {
            print "Bin width: ", $_->{width}, " x ", $_->{height}, "\n";
            print "     Item: ", $_->{label}, "\n" for @{ $_->{items} };
        }
    =cut

METHODS
    new     Creates a new `Algorithm::BinPack::2D' object. The maximum bin
            width and height is specified as a named argument 'binwidth' and

lib/Algorithm/BinPack/2D.pm  view on Meta::CPAN

=head1 SYNOPSIS

C<Algorithm::BinPack::2D> efficiently packs items into bins.
The bins are given a maximum width and height,
and items are packed in with as little empty space as possible.
An example use would be backing up small images to concatenated images,
while minimizing the number of images required.

    my $bp = Algorithm::BinPack::2D->new(binwidth => 512, binheight => 512);

    $bp->add_item(label => "one.png",   width =>  30, height =>  10);
    $bp->add_item(label => "two.png",   width => 200, height =>  40);
    $bp->add_item(label => "three.png", width =>  30, height => 300);
    $bp->add_item(label => "four.png",  width => 400, height => 100);

    for ($bp->pack_bins) {
        print "Bin width: ", $_->{width}, " x ", $_->{height}, "\n";
        print "     Item: ", $_->{label}, "\n" for @{ $_->{items} };
    }
=cut

=head1 METHODS

=over 8



( run in 4.310 seconds using v1.01-cache-2.11-cpan-df04353d9ac )