Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Tw1ddle/Rectangle-Bin-Packing
:handbag: Haxe algorithms for 2D rectangular bin packing
https://github.com/Tw1ddle/Rectangle-Bin-Packing
algorithms bin-algorithm bin-packer bin-packing binpacking haxe haxelib jukka packing-algorithm packing-algorithms
Last synced: about 1 month ago
JSON representation
:handbag: Haxe algorithms for 2D rectangular bin packing
- Host: GitHub
- URL: https://github.com/Tw1ddle/Rectangle-Bin-Packing
- Owner: Tw1ddle
- License: mit
- Created: 2015-12-29T21:32:03.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-12-12T19:51:53.000Z (about 3 years ago)
- Last Synced: 2024-11-13T02:08:57.296Z (about 2 months ago)
- Topics: algorithms, bin-algorithm, bin-packer, bin-packing, binpacking, haxe, haxelib, jukka, packing-algorithm, packing-algorithms
- Language: Haxe
- Homepage: https://samcodes.co.uk/code/
- Size: 575 KB
- Stars: 41
- Watchers: 8
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
![Project logo](https://github.com/Tw1ddle/Rectangle-Bin-Packing/blob/master/screenshots/bin_packing_logo.png?raw=true "Bin Packing Algorithms Logo")
[![License](https://img.shields.io/:license-mit-blue.svg?style=flat-square)](https://github.com/Tw1ddle/Rectangle-Bin-Packing/blob/master/LICENSE)
2D rectangular bin packing algorithms for the Haxe [bin-packing haxelib](https://lib.haxe.org/p/bin-packing). Run the demo [in your browser](https://tw1ddle.github.io/Rectangle-Bin-Packing-Demo/index.html).
Based on the public domain C++ bin packers by [Jukka Jylänki](https://github.com/juj/RectangleBinPack).
## Features ##
* Several fast approximate bin packing algorithms.
* "Occupancy rate" measure to compare packing performance.
* Configurable packing heuristics.## Usage ##
Run the [demo](https://tw1ddle.github.io/Rectangle-Bin-Packing-Demo/index.html) in your browser and refer to the [example code](https://github.com/Tw1ddle/Rectangle-Bin-Packing-Demo/).
Basic usage example:
```haxe
// 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```:
``````
## Screenshots ##
Screenshots of the [demo](https://github.com/Tw1ddle/Rectangle-Bin-Packing-Demo/):![Screenshot](https://github.com/Tw1ddle/Rectangle-Bin-Packing-Demo/blob/master/screenshots/screenshot1.png?raw=true "Bin Packing Algorithms screenshot 1")
![Screenshot](https://github.com/Tw1ddle/Rectangle-Bin-Packing-Demo/blob/master/screenshots/screenshot2.png?raw=true "Bin Packing Algorithms screenshot 2")
## Notes ##
* The algorithms in this haxelib are ported from public domain C++ code by [Jukka Jylänki](https://github.com/juj/RectangleBinPack).
* For details about the algorithms, see Jukka's [blog posts](https://clb.demon.fi/projects/even-more-rectangle-bin-packing) and [paper](https://clb.demon.fi/files/RectangleBinPack.pdf).
* If you have any questions or suggestions then [get in touch](https://samcodes.co.uk/contact).