Code Monkey home page Code Monkey logo

rectangle-bin-packing's Introduction

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

  • 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.

rectangle-bin-packing's People

Contributors

tw1ddle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rectangle-bin-packing's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.