Struct lux::graphics::Sprite [] [src]

pub struct Sprite {
    // some fields omitted
}

A ref-counted reference to a texture on the GPU.

This sprite can be cheaply cloned, resized, sliced, and drawn.

Methods

impl Sprite

fn ideal_size(&self) -> (Float, Float)

Returns the size of this sprite given the size of the image in pixels that this sprite was loaded from.

fn sub_sprite(&self, offset: (u32, u32), size: (u32, u32)) -> Option<Sprite>

Returns a new sprite located offset from this sprite with a specified size.

fn original_sprite(&self) -> Sprite

Returns a sprite that contains the entire texture that the sprite was loaded from.

fn bounds(&self) -> [[Float; 2]; 4]

Returns a an array containing the positions of

  • The top left corner,
  • The top right corner,
  • The bottom left corner,
  • the bottom right corner

all in order.

These positions are positions in texture space of the texture that this sprite has been loaded from.

fn texture(&self) -> Rc<Texture2d>

Returns a clone of the reference counted texture that this sprite was loaded from.

fn texture_ref(&self) -> &Texture2d

Returns a reference to the texture that this sprite wasa loaded from.

fn as_uniform_sprite_sheet(&self, indiv_width: u32, indiv_height: u32) -> UniformSpriteSheet

Returns a new uniform sprite sheet using this sprite as its base.

fn as_nonuniform_sprite_sheet<T>(&self) -> NonUniformSpriteSheet<T> where T: Eq + Hash

Returns a new nonuniform sprite sheet using this sprite as its base.

Trait Implementations

impl IntoSprite for Sprite

fn into_sprite<D: HasDisplay>(self, _display: &D) -> LuxResult<Sprite>

Derived Implementations

impl Debug for Sprite

fn fmt(&self, __arg_0: &mut Formatter) -> Result

impl Clone for Sprite

fn clone(&self) -> Sprite

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