#texture-atlas #2d #2d-graphics #packing #dynamic #allocation #webrender

etagere

Dynamic 2D texture atlas allocation using the shelf packing algorithm

14 releases

0.2.13 Jun 17, 2024
0.2.10 Nov 17, 2023
0.2.8 Jul 4, 2023
0.2.7 May 4, 2022
0.2.1 Nov 26, 2020

#27 in Graphics APIs

Download history 19688/week @ 2024-07-21 18683/week @ 2024-07-28 18258/week @ 2024-08-04 19944/week @ 2024-08-11 14318/week @ 2024-08-18 15782/week @ 2024-08-25 16045/week @ 2024-09-01 17208/week @ 2024-09-08 17003/week @ 2024-09-15 17873/week @ 2024-09-22 17356/week @ 2024-09-29 18581/week @ 2024-10-06 17164/week @ 2024-10-13 14397/week @ 2024-10-20 15980/week @ 2024-10-27 15514/week @ 2024-11-03

64,411 downloads per month
Used in 80 crates (20 directly)

MIT/Apache

88KB
2K SLoC

É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.

Dependencies

~0.6–0.8MB
~19K SLoC