#2d

etagere

Dynamic 2D texture atlas allocation using the shelf packing algorithm

9 releases

0.2.7 May 4, 2022
0.2.6 Oct 4, 2021
0.2.5 Sep 21, 2021
0.2.4 Jan 13, 2021
0.1.0 Nov 12, 2020

#109 in Algorithms

Download history 744/week @ 2022-11-30 642/week @ 2022-12-07 1089/week @ 2022-12-14 952/week @ 2022-12-21 605/week @ 2022-12-28 642/week @ 2023-01-04 693/week @ 2023-01-11 830/week @ 2023-01-18 912/week @ 2023-01-25 947/week @ 2023-02-01 731/week @ 2023-02-08 924/week @ 2023-02-15 979/week @ 2023-02-22 1172/week @ 2023-03-01 1257/week @ 2023-03-08 892/week @ 2023-03-15

4,471 downloads per month
Used in 6 crates (5 directly)

MIT/Apache

75KB
1.5K 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.9MB
~20K SLoC