[−][src]Struct sfml::graphics::Sprite
Drawable representation of a texture
Sprite is a drawable type that allows to easily
display a Texture
(or a part of it) on a render target.
Methods
impl<'s> Sprite<'s>
[src]
pub fn new() -> Sprite<'s>
[src]
Create a new sprite
Return Some(Sprite) or None
pub fn with_texture(texture: &'s Texture) -> Sprite<'s>
[src]
Create a new sprite with a texture
Return Some(Sprite) or None
pub fn set_texture(&mut self, texture: &'s Texture, reset_rect: bool)
[src]
Change the source texture of a sprite
The texture argument refers to a texture that must
exist as long as the sprite uses it. Indeed, the sprite
doesn't store its own copy of the texture, but rather keeps
a pointer to the one that you passed to this function.
If the source texture is destroyed and the sprite tries to
use it, the behaviour is undefined.
If reset_rect is true, the texture_rect
property of
the sprite is automatically adjusted to the size of the new
texture. If it is false, the texture rect is left unchanged.
Arguments
- texture - New texture
- reset_rect - Should the texture rect be reset to the size of the new texture?
pub fn disable_texture(&mut self)
[src]
Disable Texturing
Disable the current texture and reset the texture rect
pub fn set_color(&mut self, color: Color)
[src]
Set the global color of a sprite
This color is modulated (multiplied) with the sprite's texture. It can be used to colorize the sprite, or change its global opacity. By default, the sprite's color is opaque white.
Arguments
- color - New color of the sprite
pub fn texture(&self) -> Option<&'s Texture>
[src]
Get the source texture of a sprite
If the sprite has no source texture, None is returned. You can't modify the texture when you retrieve it with this function.
Return an Option to the sprite's texture
pub fn color(&self) -> Color
[src]
Get the global color of a sprite
Return the global color of the sprite
pub fn local_bounds(&self) -> FloatRect
[src]
Get the local bounding rectangle of a sprite
The returned rectangle is in local coordinates, which means that it ignores the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the entity in the entity's coordinate system.
Return the local bounding rectangle of the entity
pub fn global_bounds(&self) -> FloatRect
[src]
Get the global bounding rectangle of a sprite
The returned rectangle is in global coordinates, which means that it takes in account the transformations (translation, rotation, scale, ...) that are applied to the entity. In other words, this function returns the bounds of the sprite in the global 2D world's coordinate system.
Return the global bounding rectangle of the entity
pub fn texture_rect(&self) -> IntRect
[src]
Get the sub-rectangle of the texture displayed by a sprite
Return the texture rectangle of the sprite
pub fn set_texture_rect(&mut self, rect: &IntRect)
[src]
Set the sub-rectangle of the texture that a sprite will display
The texture rect is useful when you don't want to display the whole texture, but rather a part of it. By default, the texture rect covers the entire texture.
Arguments
- rectangle - Rectangle defining the region of the texture to display
Trait Implementations
impl<'s> Drawable for Sprite<'s>
[src]
fn draw<'a: 'shader, 'texture, 'shader, 'shader_texture>(
&'a self,
target: &mut dyn RenderTarget,
states: RenderStates<'texture, 'shader, 'shader_texture>
)
[src]
&'a self,
target: &mut dyn RenderTarget,
states: RenderStates<'texture, 'shader, 'shader_texture>
)
impl<'s> Transformable for Sprite<'s>
[src]
fn set_position<P: Into<Vector2f>>(&mut self, position: P)
[src]
fn set_rotation(&mut self, angle: f32)
[src]
fn set_scale<S: Into<Vector2f>>(&mut self, scale: S)
[src]
fn set_origin<O: Into<Vector2f>>(&mut self, origin: O)
[src]
fn position(&self) -> Vector2f
[src]
fn rotation(&self) -> f32
[src]
fn get_scale(&self) -> Vector2f
[src]
fn origin(&self) -> Vector2f
[src]
fn move_<O: Into<Vector2f>>(&mut self, offset: O)
[src]
fn rotate(&mut self, angle: f32)
[src]
fn scale<F: Into<Vector2f>>(&mut self, factors: F)
[src]
fn transform(&self) -> Transform
[src]
fn inverse_transform(&self) -> Transform
[src]
impl<'s> Drop for Sprite<'s>
[src]
impl<'s> Clone for Sprite<'s>
[src]
fn clone(&self) -> Sprite<'s>
[src]
Return a new Sprite or panic! if there is not enough memory
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'s> Default for Sprite<'s>
[src]
impl<'s> Debug for Sprite<'s>
[src]
Auto Trait Implementations
impl<'s> !Send for Sprite<'s>
impl<'s> !Sync for Sprite<'s>
impl<'s> Unpin for Sprite<'s>
impl<'s> UnwindSafe for Sprite<'s>
impl<'s> RefUnwindSafe for Sprite<'s>
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,