bin-packing

2D rectangle bin packing algorithms
http://samcodes.co.uk/code/

To install, run:

haxelib install bin-packing 1.0.2 

See using Haxelib in Haxelib documentation for more information.

README.md

Project logo

License Build Status

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

  • Several fast approximate bin packing algorithms.
  • "Occupancy rate" measure to compare packing performance.
  • Configurable packing heuristics.

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

  • The algorithms in this haxelib are ported from public domain C++ code by Jukka Jylänki.
  • For details about the algorithms, see Jukka's blog posts and paper.
  • If you have any questions or suggestions then get in touch.
Contributors
samcodes
Version
1.0.2
Published
8 years ago
Dependencies
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub

⌂