Skip to main content

SpriteDraw

Struct SpriteDraw 

Source
pub struct SpriteDraw {
    pub texture: Handle<Texture>,
    pub uv: Rect,
    pub position: Vec2,
    pub size: Vec2,
    pub pivot: Vec2,
    pub rotation: f32,
    pub color: Color,
    pub layer: u8,
    pub sort: SortMode,
    pub flip: Flip,
}
Expand description

One sprite to draw in the world.

Fields§

§texture: Handle<Texture>

The texture, usually an atlas page.

§uv: Rect

The region of the texture, normalized: (0, 0) to (1, 1) is all of it. A texture that failed to load shows all of its placeholder instead.

§position: Vec2

Where the pivot is in the world.

§size: Vec2

The size in world units.

§pivot: Vec2

The point of the sprite at position, normalized: (0.5, 1) is the middle of its bottom edge, its feet.

§rotation: f32

Radians, clockwise on screen, about the pivot.

§color: Color

A tint, sRGB, multiplied with the texture in linear light.

§layer: u8

Higher layers are drawn in front of lower ones.

§sort: SortMode

How it is ordered within its layer.

§flip: Flip

Which way it is mirrored, about its pivot, so that a trimmed frame mirrors as its untrimmed cell would: one whose pivot is in the middle of its width mirrors in place left to right, and one with its pivot at its feet hangs below them when mirrored top to bottom.

Implementations§

Source§

impl SpriteDraw

Source

pub fn new(texture: Handle<Texture>, position: Vec2, size: Vec2) -> Self

A sprite of all of texture, size large, with its feet at position: untinted, unrotated, y-sorted in layer 0.

Trait Implementations§

Source§

impl Clone for SpriteDraw

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SpriteDraw

Source§

impl Debug for SpriteDraw

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for SpriteDraw

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SpriteDraw

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.