pub struct Texture {
pub data: &'static [Rgb565],
pub width: u32,
pub height: u32,
/* private fields */
}Expand description
A 2D texture with RGB565 pixel data
Textures must have power-of-2 dimensions (8, 16, 32, 64, 128, 256, etc.) for efficient wrapping using bit masks instead of modulo operations.
Fields§
§data: &'static [Rgb565]Texture pixel data in RGB565 format
width: u32Width of the texture (must be power of 2)
height: u32Height of the texture (must be power of 2)
Implementations§
Source§impl Texture
impl Texture
Sourcepub fn sample(&self, u: f32, v: f32) -> Rgb565
pub fn sample(&self, u: f32, v: f32) -> Rgb565
Sample the texture at UV coordinates
Uses nearest-neighbor sampling with wrapping (repeat mode). UV coordinates are in the range [0.0, 1.0] where:
- (0, 0) is the top-left corner
- (1, 1) is the bottom-right corner
§Arguments
u- Horizontal texture coordinate (0.0-1.0+, wraps)v- Vertical texture coordinate (0.0-1.0+, wraps)
Sourcepub fn sample_fixed(&self, u_fixed: u32, v_fixed: u32) -> Rgb565
pub fn sample_fixed(&self, u_fixed: u32, v_fixed: u32) -> Rgb565
Sample the texture at UV coordinates (integer version for performance)
Uses fixed-point UV coordinates (16.16 format) for faster inner loops.
§Arguments
u_fixed- Horizontal texture coordinate in 16.16 fixed-pointv_fixed- Vertical texture coordinate in 16.16 fixed-point
Sourcepub fn sample_affine_q16(&self, u_q16: u32, v_q16: u32) -> Rgb565
pub fn sample_affine_q16(&self, u_q16: u32, v_q16: u32) -> Rgb565
Sample the texture at Q16.16 fixed-point UV coordinates using fast affine indexing.
u_q16 and v_q16 are 16.16 fixed-point numbers where 65536 represents 1.0.
Sourcepub fn sample_affine_2xssaa_q16(&self, u_q16: u32, v_q16: u32) -> Rgb565
pub fn sample_affine_2xssaa_q16(&self, u_q16: u32, v_q16: u32) -> Rgb565
Sample the texture at Q16.16 fixed-point UV coordinates using 2xSSAA (4-sample sub-pixel anti-aliasing).
Offsets 4 sub-pixel samples by ±0.25 in Q16 (±0x4000) and averages their colors to reduce texture aliasing at non-rectilinear angles.
Sourcepub fn sample_affine_scanline_q16(
&self,
u_q16: u32,
v_q16: u32,
du_q16: u32,
dv_q16: u32,
out_buffer: &mut [Rgb565],
)
pub fn sample_affine_scanline_q16( &self, u_q16: u32, v_q16: u32, du_q16: u32, dv_q16: u32, out_buffer: &mut [Rgb565], )
Sample a horizontal scanline using Q16.16 fixed-point affine UV stepping.
Sourcepub fn dimensions(&self) -> (u32, u32)
pub fn dimensions(&self) -> (u32, u32)
Get texture dimensions
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Texture
impl RefUnwindSafe for Texture
impl Send for Texture
impl Sync for Texture
impl Unpin for Texture
impl UnsafeUnpin for Texture
impl UnwindSafe for Texture
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
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.