Trait AtlasAllocator

Source
pub trait AtlasAllocator {
    type Config;

    // Required methods
    fn with_max_size(max_size: Vec2<u16>, config: Self::Config) -> Self;
    fn allocate(&mut self, size: Vec2<u16>) -> Option<Rectangle>;
    fn size(&self) -> Vec2<u16>;
    fn grow(&mut self, new_size: Vec2<u16>);
}
Expand description

Abstraction over different atlas allocators. Useful to swap out the allocator implementation for specific cases (e.g. sprites).

Required Associated Types§

Required Methods§

Source

fn with_max_size(max_size: Vec2<u16>, config: Self::Config) -> Self

Creates a new instance of this atlas allocator taking into account the provided max size;

Source

fn allocate(&mut self, size: Vec2<u16>) -> Option<Rectangle>

Allocates a rectangle of the given size.

Source

fn size(&self) -> Vec2<u16>

Retrieves the current size of the atlas being allocated from.

Source

fn grow(&mut self, new_size: Vec2<u16>)

Grows the size of the atlas to the provided size.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl AtlasAllocator for SimpleAtlasAllocator

Source§

fn allocate(&mut self, size: Vec2<u16>) -> Option<Rectangle>

Allocates a rectangle of the given size.

Source§

fn size(&self) -> Vec2<u16>

Retrieves the current size of the atlas being allocated from.

Source§

fn grow(&mut self, new_size: Vec2<u16>)

Grows the size of the atlas to the provided size.

Source§

type Config = AllocatorOptions

Source§

fn with_max_size(max_size: Vec2<u16>, config: Self::Config) -> Self

Implementors§