Struct atlas::Atlas
[−]
[src]
pub struct Atlas<T> { /* fields omitted */ }
Stores images, and automatically stitches them together.
While it's definitely okay to add the images in any order, to get any decent
space efficiency it's necessary to at least sort-of sort the frames in
terms of decreasing size. Particularly good orders are by width * height
and by max(width, height)
, both in descending order.
Methods
impl<T> Atlas<T>
[src]
fn new(blank: T) -> Self
Create a new, empty atlas.
The blank pixel will be used to represent the space that exists between images, in the almost certain case that 100% space utilization is not achieved.
fn add<U>(&mut self, image: U) -> (usize, usize) where
T: AsBytes + Clone + Sync + 'static,
U: Image<Pixel = T> + Sync,
T: AsBytes + Clone + Sync + 'static,
U: Image<Pixel = T> + Sync,
Adds an image to the atlas, placing it appropriately.
The return value is the location of the image within the atlas. If the
image is of zero size, then the coordinates (0, 0)
will be returned,
which you most likely won't need to special-case, since it is
technically valid.
Trait Implementations
impl<T> Into<Chunky<T>> for Atlas<T> where
T: AsBytes,
[src]
T: AsBytes,
impl<T> Image for Atlas<T> where
T: AsBytes,
[src]
T: AsBytes,
type Pixel = T
The kind of pixel that the frame is made of.
fn width(&self) -> usize
The width of the frame in pixels.
fn height(&self) -> usize
The height of the frame in pixels.
unsafe fn pixel(&self, x: usize, y: usize) -> Self::Pixel
Gets the pixel at the specified zero-indexed coordinates. Read more