1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! Pack small rectangles into a larger one. This is useful for creating texture atlases for the efficient GPU rendering.
//!
//! Usage example:
//!
//! ```
//! use rect_packer::Packer;
//!
//! let config = rect_packer::Config {
//! width: 1024,
//! height: 1024,
//!
//! border_padding: 5,
//! rectangle_padding: 10,
//! };
//!
//! let rectangles = [(50, 70), (350, 210), (255, 410)];
//!
//! let mut packer = Packer::new(config);
//! for &(width, height) in &rectangles {
//! if let Some(rect) = packer.pack(width, height, false) {
//! println!("Rectangle is at position ({}, {}) within the encompassing rectangle",
//! rect.x,
//! rect.y);
//! }
//! }
//!
extern crate rand;
extern crate image;
pub use Rect;
pub use Packer;
pub use DensePacker;
/// Describes size and padding requirements of rectangle packing.