Crate rect_packer [] [src]

Usage example:

use rect_packer::Packer;

let config = rect_packer::Config {
    width: 1024,
    height: 1024,

    border_padding: 5,
    rectangle_padding: 10,
};

let rectangles = [(50, 70), (350, 210), (255, 410)];

let mut packer = Packer::new(config);
for &(width, height) in &rectangles {
    if let Some(rect) = packer.pack(width, height, false) {
        println!("Rectangle is at position ({}, {}) within encompassing rectangle",
            rect.x,
            rect.y);
    }
}

Structs

Config

Describes size and padding requirements of rectangle packing.

Packer

Packer is the main structure in this crate. It holds packing context.

Rect

Rectangle with integer coordinates.