Crates.io | max_rects |
lib.rs | max_rects |
version | 1.0.2 |
source | src |
created_at | 2023-09-28 01:57:24.03744 |
updated_at | 2023-09-28 03:00:59.013409 |
description | An implementation of the maximal rectangles algorithm for 2d bin packing. |
homepage | |
repository | https://github.com/jeremycg/max_rects/ |
max_upload_size | |
id | 985470 |
size | 59,483 |
An implementation of the maximal rectangles algorithm by Jukka Jylänki for 2d bin packing. This crate utilizes the MaxRects algorithm to efficiently pack a given number of boxes into a specified number of bins, and generate a visualization of the packing result.
This was created as an effort to learn rust with one of my favorite algorithms. Included is a png generator to visualize results:
git clone https://github.com/jeremycg/max_rects.git
cd max_rects
cargo run -- -b 50 -n 10
use max_rects::{Bucket, MaxRects, PackingBox};
fn main() {
let boxes = vec![PackingBox::new(5, 6), PackingBox::new(4, 4)];
let bins = vec![Bucket::new(10, 20, 0, 0, 1)];
let mut max_rects = MaxRects::new(boxes, bins);
let (placed, remaining, updated_bins) = max_rects.place();
}
You can generate the documentation for this crate by running:
cargo doc --open
This project is licensed under the MIT License - see the LICENSE.md file for details.
Feel free to submit issues and pull requests, we appreciate your help!