Bug 1874684 - Part 33: Defer allocation of options object for CalendarDateFromFields...
[gecko.git] / third_party / rust / etagere / README.md
blob1caf05d4ec2b55f80cc680f70607c1e3119faa86
1 # Étagère
3 <p align="center">
4   <a href="https://crates.io/crates/etagere">
5       <img src="https://img.shields.io/crates/v/etagere.svg" alt="crates.io">
6   </a>
7   <a href="https://docs.rs/etagere">
8       <img src="https://docs.rs/etagere/badge.svg" alt="documentation">
9   </a>
11 </p>
13 A dynamic texture atlas allocator using the shelf packing algorithm.
15 ## Motivation
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.
23 ## Example
25 ```rust
26 use etagere::*;
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);
41 ```
43 ## License
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)
50 at your option.