11 releases

0.2.10 Nov 17, 2023
0.2.8 Jul 4, 2023
0.2.7 May 4, 2022
0.2.6 Oct 4, 2021
0.2.1 Nov 26, 2020

#33 in Graphics APIs

Download history 5839/week @ 2023-11-20 6026/week @ 2023-11-27 5525/week @ 2023-12-04 6320/week @ 2023-12-11 5207/week @ 2023-12-18 4598/week @ 2023-12-25 5069/week @ 2024-01-01 6658/week @ 2024-01-08 9971/week @ 2024-01-15 11002/week @ 2024-01-22 9173/week @ 2024-01-29 9807/week @ 2024-02-05 9840/week @ 2024-02-12 11670/week @ 2024-02-19 10520/week @ 2024-02-26 10499/week @ 2024-03-04

43,739 downloads per month
Used in 53 crates (13 directly)

MIT/Apache

80KB
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.8MB
~19K SLoC