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§
Source§impl 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§
Source§impl Bind for SubTexture
impl Bind for SubTexture
Source§impl Clone for SubTexture
impl Clone for SubTexture
Source§fn clone(&self) -> SubTexture
fn clone(&self) -> SubTexture
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 SubTexture
impl Debug for SubTexture
Auto Trait Implementations§
impl Freeze for SubTexture
impl RefUnwindSafe for SubTexture
impl !Send for SubTexture
impl !Sync for SubTexture
impl Unpin for SubTexture
impl UnwindSafe for SubTexture
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moreSource§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).Source§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.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.