#texture-atlas #sprite-atlas #texture-packer #texture

rect_packer

A rectangle packing library. Heavily tested with random data to ensure that it always produces correct result.

4 releases

Uses old Rust 2015

0.2.1 Sep 22, 2017
0.2.0 Feb 14, 2017
0.1.1 Dec 30, 2016
0.1.0 Jul 17, 2016

#1372 in Game dev

Download history 2185/week @ 2025-10-21 1816/week @ 2025-10-28 1278/week @ 2025-11-04 2443/week @ 2025-11-11 2435/week @ 2025-11-18 2033/week @ 2025-11-25 2134/week @ 2025-12-02 2777/week @ 2025-12-09 5253/week @ 2025-12-16 3250/week @ 2025-12-23 2500/week @ 2025-12-30 4671/week @ 2026-01-06 4573/week @ 2026-01-13 3273/week @ 2026-01-20 2035/week @ 2026-01-27 2411/week @ 2026-02-03

12,971 downloads per month
Used in 21 crates (9 directly)

MIT license

19KB
393 lines

Pack small rectangles into a larger one. This is useful for creating texture atlases for the efficient GPU rendering.

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 the encompassing rectangle",
            rect.x,
            rect.y);
    }
}


rect-packer Build Status

Pack multiple rectangles into a larger one. Can be used for packing sprites into a texture for 2d games. Uses skyline heuristic. Heavily tested with random data to ensure that it always produces correct result.

Documentation

Crates.io package

Skyline packer


MIT License

No runtime deps