4 <a href="https://crates.io/crates/etagere">
5 <img src="https://img.shields.io/crates/v/etagere.svg" alt="crates.io">
7 <a href="https://docs.rs/etagere">
8 <img src="https://docs.rs/etagere/badge.svg" alt="documentation">
13 A dynamic texture atlas allocator using the shelf packing algorithm.
17 The ability to dynamically batch textures together is important for some graphics rendering scenarios (for example [WebRender](https://github.com/servo/webrender)).
19 The shelf packing algorithm works very well when there is a high number of items with similar sizes, for example for dynamic glyph atlases.
21 See also [guillotière](https://github.com/nical/guillotiere), another dynamic atlas allocator based on a different algorithm, with different packing and performance characteristics.
28 let mut atlas = AtlasAllocator::new(size2(1000, 1000));
30 let a = atlas.allocate(size2(100, 1000)).unwrap();
31 let b = atlas.allocate(size2(900, 200)).unwrap();
33 atlas.deallocate(a.id);
35 let c = atlas.allocate(size2(300, 200)).unwrap();
37 assert_eq!(c.rectangle, atlas.get(c.id));
39 atlas.deallocate(c.id);
40 atlas.deallocate(b.id);
45 Licensed under either of
47 * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)
48 * MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)