#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 17253/week @ 2024-08-13 13846/week @ 2024-08-20 16079/week @ 2024-08-27 16681/week @ 2024-09-03 16922/week @ 2024-09-10 16575/week @ 2024-09-17 18407/week @ 2024-09-24 18011/week @ 2024-10-01 18201/week @ 2024-10-08 16369/week @ 2024-10-15 14291/week @ 2024-10-22 17062/week @ 2024-10-29 14103/week @ 2024-11-05 14425/week @ 2024-11-12 16572/week @ 2024-11-19 12277/week @ 2024-11-26

60,771 downloads per month
Used in 84 crates (21 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