pub struct Levels {
pub width: u32,
pub height: u32,
pub levels: Vec<Vec<u8>>,
}Expand description
An RGBA8 texture’s mip levels, each stored row by row, four bytes a texel. Level n is the base size halved n
times (at least 1); Levels::size gives it.
Fields§
§width: u32The base level’s width in texels.
height: u32The base level’s height in texels.
levels: Vec<Vec<u8>>The RGBA8 bytes of each level, base level first. The fields are public, so the sampling methods check the
level they read: one that is missing, or does not hold exactly its Levels::size in texels, is refused.
Implementations§
Source§impl Levels
impl Levels
Sourcepub fn one(width: u32, height: u32, rgba: Vec<u8>) -> Result<Levels>
pub fn one(width: u32, height: u32, rgba: Vec<u8>) -> Result<Levels>
One level of RGBA8 texels.
Sourcepub fn rows_reversed(self) -> Result<Levels>
pub fn rows_reversed(self) -> Result<Levels>
Each level’s rows in reverse order, for a texture stored bottom row first when row 0 is wanted at v = 0: addressing then applies about that texture’s own origin. A level that isn’t its size’s whole rows is refused.
Sourcepub fn size(&self, level: usize) -> (u32, u32)
pub fn size(&self, level: usize) -> (u32, u32)
Level level’s size: the base halved per level, at least 1.
Sourcepub fn texel(
&self,
level: usize,
x: i64,
y: i64,
address: [Address; 2],
) -> Result<[u8; 4]>
pub fn texel( &self, level: usize, x: i64, y: i64, address: [Address; 2], ) -> Result<[u8; 4]>
The texel at (x, y) of level level, addressed by address. A level that is not stored, or does not hold
its size’s bytes, is refused, as is a coordinate outside a Address::Border axis (it reads no stored texel).
Sourcepub fn bilinear(
&self,
level: usize,
uv: [f64; 2],
address: impl Into<Addressing<2>>,
transfer: Transfer,
) -> Result<[f64; 4]>
pub fn bilinear( &self, level: usize, uv: [f64; 2], address: impl Into<Addressing<2>>, transfer: Transfer, ) -> Result<[f64; 4]>
Bilinear at uv of level level, in f64: weights (1 - tx)(1 - ty), tx (1 - ty), (1 - tx) ty, tx ty
summed in that order, a texel outside a border axis the border colour. A coordinate that isn’t finite or past an
i32’s range is refused, as is a border axis with no colour (Addressing::border).
Sourcepub fn point(
&self,
level: usize,
uv: [f64; 2],
address: impl Into<Addressing<2>>,
transfer: Transfer,
) -> Result<[f64; 4]>
pub fn point( &self, level: usize, uv: [f64; 2], address: impl Into<Addressing<2>>, transfer: Transfer, ) -> Result<[f64; 4]>
The texel of level level that uv falls in (texel i covering [i, i + 1) after scaling by the level’s
size), in f64: point filtering; outside a border axis, the border colour. A coordinate that isn’t finite or past
an i32’s range is refused, as is a border axis with no colour.
Source§impl Levels
impl Levels
Sourcepub fn trilinear(
&self,
uv: [f64; 2],
lod: f64,
address: impl Into<Addressing<2>>,
transfer: Transfer,
) -> Result<[f64; 4]>
pub fn trilinear( &self, uv: [f64; 2], lod: f64, address: impl Into<Addressing<2>>, transfer: Transfer, ) -> Result<[f64; 4]>
Trilinear at uv: the level of detail lod clamped to the stored levels, the bilinear values
(Levels::bilinear) of the level below it and the next mixed by its fraction (a + (b - a) f); a level
of detail that isn’t a number, or a coordinate or addressing Levels::bilinear refuses, is refused.
Sourcepub fn nearest_level(&self, lod: f64) -> Result<usize>
pub fn nearest_level(&self, lod: f64) -> Result<usize>
The stored level nearest the level of detail lod, as a point mip filter picks it: floor(lod + 0.5) (a half
rounds up), clamped to the stored levels. A level of detail that isn’t a number is refused.