Struct moon_engine::texture::SubTexture
source · [−]pub struct SubTexture { /* private fields */ }
Expand description
A SubTexture
is a part of a full Texture
.
It stores the UV co-ordinates of the part of the Texture it occupies.
Implementations
sourceimpl SubTexture
impl SubTexture
sourcepub fn new(texture: Rc<Texture>) -> Self
pub fn new(texture: Rc<Texture>) -> Self
Create a new SubTexture
with the full UV co-ordinates.
sourcepub fn new_with_coords(texture: Rc<Texture>, uv: Color32) -> Self
pub fn new_with_coords(texture: Rc<Texture>, uv: Color32) -> Self
Create a new SubTexture
with the given UV co-ordinates.
sourcepub fn get_uv_coords(&self) -> [[f32; 2]; 4]
pub fn get_uv_coords(&self) -> [[f32; 2]; 4]
Get the UV co-ordinates as an array of four two-component f32
.
sourcepub fn create_tiles_from_spritesheet(
texture: Rc<Texture>,
horizontal_cells: u32,
vertical_cells: u32
) -> Vec<SubTexture>
pub fn create_tiles_from_spritesheet(
texture: Rc<Texture>,
horizontal_cells: u32,
vertical_cells: u32
) -> Vec<SubTexture>
Create a Vec
of SubTexture
s from a sprite sheet.
Uses the number of cells horizontally and vertically to devide the cells.
Trait Implementations
sourceimpl Bind for SubTexture
impl Bind for SubTexture
sourceimpl Clone for SubTexture
impl Clone for SubTexture
sourcefn clone(&self) -> SubTexture
fn clone(&self) -> SubTexture
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for SubTexture
impl Debug for SubTexture
Auto Trait Implementations
impl RefUnwindSafe for SubTexture
impl !Send for SubTexture
impl !Sync for SubTexture
impl Unpin for SubTexture
impl UnwindSafe for SubTexture
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.