pub struct TextureAtlasPacker { /* private fields */ }Expand description
Simplified packer API that wraps TextureAtlas.
Accepts a batch of (width, height) sprites and returns their allocated
(x, y, w, h) rectangles in the same order.
§Example
use oximedia_gpu::texture_atlas::TextureAtlasPacker;
let mut packer = TextureAtlasPacker::new(512, 512);
let rects = packer.pack(&[(64, 64), (32, 32)]);
assert_eq!(rects.len(), 2);Implementations§
Source§impl TextureAtlasPacker
impl TextureAtlasPacker
Sourcepub fn new(max_w: u32, max_h: u32) -> Self
pub fn new(max_w: u32, max_h: u32) -> Self
Create a packer backed by an atlas of max_w × max_h texels.
Sourcepub fn pack(&mut self, sprites: &[(u32, u32)]) -> Vec<(u32, u32, u32, u32)>
pub fn pack(&mut self, sprites: &[(u32, u32)]) -> Vec<(u32, u32, u32, u32)>
Pack a slice of (width, height) sprites.
Returns a Vec of (x, y, w, h) tuples in the same order as the
input. Sprites that do not fit are represented by (0, 0, 0, 0).
Sourcepub fn utilisation(&self) -> f32
pub fn utilisation(&self) -> f32
Current utilisation fraction [0, 1].
Auto Trait Implementations§
impl Freeze for TextureAtlasPacker
impl RefUnwindSafe for TextureAtlasPacker
impl Send for TextureAtlasPacker
impl Sync for TextureAtlasPacker
impl Unpin for TextureAtlasPacker
impl UnsafeUnpin for TextureAtlasPacker
impl UnwindSafe for TextureAtlasPacker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more