Struct radiant_rs::Sprite [−][src]
pub struct Sprite { /* fields omitted */ }
A sprite used for drawing on a Layer
.
Sprites are created from spritesheets containing one or more frames. To determine frame
dimensions, Sprite::from_file()
expects sprite sheet file names to
follow a specific pattern. (Future versions will add more configurable means to load sprites.)
Methods
impl<'a> Sprite
[src]
impl<'a> Sprite
pub fn from_file(context: &RenderContext, file: &str) -> Result<Self>
[src]
pub fn from_file(context: &RenderContext, file: &str) -> Result<Self>
Creates a new sprite texture. Given filename is expected to end
on _
pub fn from_data(
context: &RenderContext,
data: &[u8],
parameters: &SpriteParameters
) -> Result<Self>
[src]
pub fn from_data(
context: &RenderContext,
data: &[u8],
parameters: &SpriteParameters
) -> Result<Self>
Creates a new sprite texture.
ⓘImportant traits for &'a mut Rpub fn draw<T>(
&self,
layer: &Layer,
frame_id: u32,
position: T,
color: Color
) -> &Self where
(f32, f32): From<T>,
[src]
pub fn draw<T>(
&self,
layer: &Layer,
frame_id: u32,
position: T,
color: Color
) -> &Self where
(f32, f32): From<T>,
Draws a sprite onto the given layer.
ⓘImportant traits for &'a mut Rpub fn draw_transformed<T, U>(
&self,
layer: &Layer,
frame_id: u32,
position: T,
color: Color,
rotation: f32,
scale: U
) -> &Self where
(f32, f32): From<T>,
(f32, f32): From<U>,
[src]
pub fn draw_transformed<T, U>(
&self,
layer: &Layer,
frame_id: u32,
position: T,
color: Color,
rotation: f32,
scale: U
) -> &Self where
(f32, f32): From<T>,
(f32, f32): From<U>,
Draws a sprite onto the given layer and applies given color, rotation and scaling.
ⓘImportant traits for &'a mut Rpub fn set_anchor(&mut self, anchor: (f32, f32)) -> &Self
[src]
pub fn set_anchor(&mut self, anchor: (f32, f32)) -> &Self
Defines the sprite origin. Defaults to (0.5, 0.5), meaning that the center of the
sprite would be drawn at the coordinates given to Sprite::draw()
. Likewise, (0.0, 0.0)
would mean that the sprite's top left corner would be drawn at the given coordinates.
pub fn width(&self) -> u32
[src]
pub fn width(&self) -> u32
Returns the width of the sprite.
pub fn height(&self) -> u32
[src]
pub fn height(&self) -> u32
Returns the height of the sprite.
pub fn num_frames(&self) -> u32
[src]
pub fn num_frames(&self) -> u32
Returns the number of frames of the sprite.
pub fn arc(self) -> Arc<Self>
[src]
pub fn arc(self) -> Arc<Self>
Returns the sprite wrapped in an std::Arc
Trait Implementations
impl Clone for Sprite
[src]
impl Clone for Sprite
fn clone(&self) -> Sprite
[src]
fn clone(&self) -> Sprite
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for Sprite
[src]
impl Debug for Sprite