#[repr(C)]pub struct SpriteInstance {
pub pos: [f32; 2],
pub size: [f32; 2],
pub uv_min: [f32; 2],
pub uv_max: [f32; 2],
pub color: [f32; 4],
pub rotation: f32,
pub _pad: [f32; 3],
}Fields§
§pos: [f32; 2]§size: [f32; 2]§uv_min: [f32; 2]§uv_max: [f32; 2]§color: [f32; 4]§rotation: f32§_pad: [f32; 3]Padding to a 16-byte multiple. _pad[0] doubles as the CPU-side marker for
SpriteInstance::with_pixel_region; leave it zeroed.
Implementations§
Source§impl SpriteInstance
impl SpriteInstance
pub fn at(pos: [f32; 2], size: [f32; 2]) -> SpriteInstance
pub fn with_color(self, c: impl Into<Color>) -> SpriteInstance
pub fn with_rotation(self, r: f32) -> SpriteInstance
Sourcepub fn with_uv(self, min: [f32; 2], max: [f32; 2]) -> SpriteInstance
pub fn with_uv(self, min: [f32; 2], max: [f32; 2]) -> SpriteInstance
Sample the UV rectangle min..max ([0.0, 0.0]..[1.0, 1.0] is the whole texture).
Beyond 0..1 the texture tiles only if it was set to crate::TextureWrap::Repeat
(or MirrorRepeat) with Graphics::set_texture_wrap; by default it clamps to the
edge texels.
Sourcepub fn with_region(
self,
min: [f32; 2],
size: [f32; 2],
tex_size: [u32; 2],
) -> SpriteInstance
pub fn with_region( self, min: [f32; 2], size: [f32; 2], tex_size: [u32; 2], ) -> SpriteInstance
Sample the size pixel rectangle at min (top-left, in pixels) of a texture that is
tex_size pixels large, e.g. one sprite of an atlas. Get tex_size from
Graphics::texture_size / Painter::texture_size, which never reports a zero side;
a zero tex_size side would produce non-finite UVs and is a debug-build panic.
Sourcepub fn with_pixel_region(self, min: [f32; 2], size: [f32; 2]) -> SpriteInstance
pub fn with_pixel_region(self, min: [f32; 2], size: [f32; 2]) -> SpriteInstance
Sample the size pixel rectangle at min (top-left, in pixels) of whatever texture
this is drawn with, like with_region but without passing the
texture size: crate::Painter::sprite_ex looks it up when the sprite is drawn, and
draws nothing for an unknown texture. Combine freely with flip_x /
flip_y, and draw the instance only through sprite_ex.
Sourcepub fn flip_x(self) -> SpriteInstance
pub fn flip_x(self) -> SpriteInstance
Mirror horizontally by swapping the u bounds. Works with any UV range or region;
apply it after with_uv / with_region.
Sourcepub fn flip_y(self) -> SpriteInstance
pub fn flip_y(self) -> SpriteInstance
Mirror vertically by swapping the v bounds. Works with any UV range or region;
apply it after with_uv / with_region.
Trait Implementations§
Source§impl Clone for SpriteInstance
impl Clone for SpriteInstance
Source§fn clone(&self) -> SpriteInstance
fn clone(&self) -> SpriteInstance
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SpriteInstance
Source§impl Debug for SpriteInstance
impl Debug for SpriteInstance
impl Pod for SpriteInstance
Auto Trait Implementations§
impl Freeze for SpriteInstance
impl RefUnwindSafe for SpriteInstance
impl Send for SpriteInstance
impl Sync for SpriteInstance
impl Unpin for SpriteInstance
impl UnsafeUnpin for SpriteInstance
impl UnwindSafe for SpriteInstance
Blanket Implementations§
impl<T> AnyBitPattern for Twhere
T: Pod,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.