[][src]Struct sprite::Sprite

pub struct Sprite<I: ImageSize> { /* fields omitted */ }

A sprite is a texture with some properties.

Methods

impl<I: ImageSize> Sprite<I>[src]

pub fn from_texture(texture: Rc<I>) -> Sprite<I>[src]

Crate sprite from a texture

pub fn from_texture_rect(texture: Rc<I>, src_rect: SourceRectangle) -> Sprite<I>[src]

Create sprite from a rectangle selection of a texture

pub fn id(&self) -> Uuid[src]

Get the sprite's id

pub fn get_visible(&self) -> bool[src]

Whether or not the sprite is visible

pub fn set_visible(&mut self, visible: bool)[src]

Set the sprite's visibility

pub fn get_anchor(&self) -> (Scalar, Scalar)[src]

Get the sprite's anchor point

The value is normalized. Default value is [0.5, 0.5] (the center of texture)

pub fn set_anchor(&mut self, x: Scalar, y: Scalar)[src]

Set the sprite's anchor point

pub fn get_position(&self) -> (Scalar, Scalar)[src]

Get the sprite's position

pub fn set_position(&mut self, x: Scalar, y: Scalar)[src]

Set the sprite's position

pub fn set_color(&mut self, r: f32, g: f32, b: f32)[src]

Set the sprite's draw color (tint)

pub fn get_color(&self) -> (f32, f32, f32)[src]

get the sprite's color.s

pub fn get_rotation(&self) -> Scalar[src]

Get the sprite's rotation (in degree)

pub fn set_rotation(&mut self, deg: Scalar)[src]

Set the sprite's rotation (in degree)

pub fn get_scale(&self) -> (Scalar, Scalar)[src]

Get the sprite's scale

pub fn set_scale(&mut self, sx: Scalar, sy: Scalar)[src]

Set the sprite's scale

pub fn get_flip_x(&self) -> bool[src]

Whether or not the sprite is flipped horizontally.

It only flips the texture of the sprite, and not the texture of the sprite’s children.

Also, flipping the texture doesn’t alter the anchor.

If you want to flip the anchor too, and/or to flip the children too use: sprite.scale.x *= -1;

pub fn set_flip_x(&mut self, flip_x: bool)[src]

Flip the sprite

pub fn get_flip_y(&self) -> bool[src]

Whether or not the sprite is flipped vertically.

It only flips the texture of the sprite, and not the texture of the sprite’s children.

Also, flipping the texture doesn’t alter the anchor.

If you want to flip the anchor too, and/or to flip the children too use: sprite.scale.y *= -1;

pub fn set_flip_y(&mut self, flip_y: bool)[src]

Flip the sprite

pub fn get_opacity(&self) -> f32[src]

Get the sprite's opacity

pub fn set_opacity(&mut self, opacity: f32)[src]

Set the sprite's opacity

pub fn get_src_rect(&self) -> Option<SourceRectangle>[src]

Get the sprite's source rectangle

pub fn set_src_rect(&mut self, src_rect: SourceRectangle)[src]

Set the sprite's source rectangle

pub fn get_texture(&self) -> &Rc<I>[src]

Get the sprite's texture

pub fn set_texture(&mut self, texture: Rc<I>)[src]

Set the sprite's texture

pub fn add_child(&mut self, sprite: Sprite<I>) -> Uuid[src]

Add a sprite as the child of this sprite, return the added sprite's id.

pub fn remove_child(&mut self, id: Uuid) -> Option<Sprite<I>>[src]

Remove the child by id from this sprite's children or grandchild

pub fn child(&self, id: Uuid) -> Option<&Sprite<I>>[src]

Find the child by id from this sprite's children or grandchild

pub fn child_mut(&mut self, id: Uuid) -> Option<&mut Sprite<I>>[src]

Find the child by id from this sprite's children or grandchild, mutability

pub fn children(&self) -> &Vec<Sprite<I>>[src]

Get the sprite's children

pub fn draw<B: Graphics<Texture = I>>(&self, t: Matrix2d, b: &mut B)[src]

Draw this sprite and its children

pub fn draw_tinted<B: Graphics<Texture = I>>(
    &self,
    t: Matrix2d,
    b: &mut B,
    c: [f32; 3]
)
[src]

Draw this sprite and its children with color

pub fn bounding_box(&self) -> Rectangle[src]

Get the sprite's bounding box

Auto Trait Implementations

impl<I> !Sync for Sprite<I>

impl<I> !Send for Sprite<I>

impl<I> Unpin for Sprite<I>

impl<I> UnwindSafe for Sprite<I> where
    I: RefUnwindSafe

impl<I> !RefUnwindSafe for Sprite<I>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]