pub struct AtlasRegion {
pub page: usize,
pub col: u32,
pub row: u32,
}Expand description
Describes where a tile’s pixels are stored inside the atlas.
Returned by TileAtlas::insert and TileAtlas::get. The region
is used by the batch builder (crate::gpu::batch) to remap each
tile quad’s UVs from [0, 1] into the correct atlas sub-rectangle.
Fields§
§page: usizeIndex of the atlas page (into TileAtlas::pages).
col: u32Column of the slot within the page (0-based, max SLOTS_PER_SIDE-1).
row: u32Row of the slot within the page (0-based, max SLOTS_PER_SIDE-1).
Implementations§
Source§impl AtlasRegion
impl AtlasRegion
Sourcepub fn remap_uv(&self, u: f32, v: f32) -> [f32; 2]
pub fn remap_uv(&self, u: f32, v: f32) -> [f32; 2]
Remap a tile-local UV [0, 1] to an atlas-global UV.
Applies a half-texel inset so that bilinear sampling at slot edges never bleeds into the neighbouring slot.
§Mapping
u' = (col + u) / slots_per_side (+ half-texel inset)
v' = (row + v) / slots_per_side (+ half-texel inset)Trait Implementations§
Source§impl Clone for AtlasRegion
impl Clone for AtlasRegion
Source§fn clone(&self) -> AtlasRegion
fn clone(&self) -> AtlasRegion
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AtlasRegion
impl Debug for AtlasRegion
impl Copy for AtlasRegion
Auto Trait Implementations§
impl Freeze for AtlasRegion
impl RefUnwindSafe for AtlasRegion
impl Send for AtlasRegion
impl Sync for AtlasRegion
impl Unpin for AtlasRegion
impl UnsafeUnpin for AtlasRegion
impl UnwindSafe for AtlasRegion
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