etagere

Crates.ioetagere
lib.rsetagere
version0.2.13
sourcesrc
created_at2020-11-12 14:05:30.038714
updated_at2024-06-17 11:25:58.146284
descriptionDynamic 2D texture atlas allocation using the shelf packing algorithm.
homepage
repositoryhttps://github.com/nical/etagere
max_upload_size
id311591
size90,012
Nicolas Silva (nical)

documentation

https://docs.rs/etagere/

README

Étagère

crates.io documentation

A dynamic texture atlas allocator using the shelf packing algorithm.

Motivation

The ability to dynamically batch textures together is important for some graphics rendering scenarios (for example WebRender).

The shelf packing algorithm works very well when there is a high number of items with similar sizes, for example for dynamic glyph atlases.

See also guillotière, another dynamic atlas allocator based on a different algorithm, with different packing and performance characteristics.

Example

use etagere::*;

let mut atlas = AtlasAllocator::new(size2(1000, 1000));

let a = atlas.allocate(size2(100, 1000)).unwrap();
let b = atlas.allocate(size2(900, 200)).unwrap();

atlas.deallocate(a.id);

let c = atlas.allocate(size2(300, 200)).unwrap();

assert_eq!(c.rectangle, atlas.get(c.id));

atlas.deallocate(c.id);
atlas.deallocate(b.id);

License

Licensed under either of

at your option.

Commit count: 55

cargo fmt