Home

Awesome

Project logo

License

2D rectangular bin packing algorithms for the Haxe bin-packing haxelib. Run the demo in your browser.

Based on the public domain C++ bin packers by Jukka Jylänki.

Features

Usage

Run the demo in your browser and refer to the example code.

Basic usage example:

// Initialize a bin packer
var binWidth:Int = 800;
var binHeight:Int = 400;
var useWasteMap:Bool = true;
var packer = new SkylinePacker(binWidth, binHeight, useWasteMap);

// Start packing rectangles
var rectWidth:Int = 20;
var rectHeight:Int = 40;
var heuristic:LevelChoiceHeuristic = LevelChoiceHeuristic.MinWasteFit;
var rect:Rect = packer.insert(rectWidth, rectHeight, heuristic);

if(rect == null) {
    trace("Failed to pack rect");
} else {
    trace("Inserted rect at: " + Std.string(rect.x) + "," + Std.string(rect.y));
}

Install

Get the Haxe library code here or via haxelib.

Include it in your .hxml

-lib bin-packing

Or add it to your Project.xml:

<haxelib name="bin-packing" />

Screenshots

Screenshots of the demo:

Screenshot

Screenshot

Notes