smol-atlas

Crates.iosmol-atlas
lib.rssmol-atlas
version0.1.0
created_at2025-11-28 18:33:01.880756+00
updated_at2025-11-28 18:33:01.880756+00
description2D rectangular bin packing with optional item removal
homepage
repositoryhttps://github.com/cijiugechu/smol-atlas
max_upload_size
id1955849
size40,112
Cistus Creticus (cijiugechu)

documentation

https://docs.rs/smol-atlas

README

smol-atlas

Pack rectangles into a fixed-size 2D atlas with item removal. Uses the Shelf Best Height Fit heuristic; shelves never merge or move, and free spans inside a shelf are tracked to reuse space.

Usage

use smol_atlas::Atlas;

let mut atlas = Atlas::new(256, 256);
let a = atlas.add(64, 32).expect("fits");
let b = atlas.add(32, 32).expect("fits");

println!("a at ({}, {})", atlas.item_x(a).unwrap(), atlas.item_y(a).unwrap());
atlas.remove(b);
let c = atlas.add(32, 32).expect("reuses space");
assert_eq!(atlas.item_y(c), atlas.item_y(a)); // likely same shelf

Credits

Commit count: 0

cargo fmt