pub struct Sprite {Show 14 fields
pub component: Component,
pub x: AnimatedFloat,
pub y: AnimatedFloat,
pub rotation: AnimatedFloat,
pub scale_x: AnimatedFloat,
pub scale_y: AnimatedFloat,
pub anchor_x: AnimatedFloat,
pub anchor_y: AnimatedFloat,
pub alpha: AnimatedFloat,
pub blend_mode: BlendMode,
pub scissor: Option<Rectangle>,
pub visible: bool,
pub pixel_snapping: bool,
pub pointer_enabled: bool,
/* private fields */
}
Fields
component: Component
x: AnimatedFloat
X position, in pixels.
y: AnimatedFloat
Y position, in pixels.
rotation: AnimatedFloat
Rotation angle, in degrees.
scale_x: AnimatedFloat
Horizontal scale factor.
scale_y: AnimatedFloat
Vertical scale factor.
anchor_x: AnimatedFloat
The X position of this sprite’s anchor point. Local transformations are applied relative to this point.
anchor_y: AnimatedFloat
The Y position of this sprite’s anchor point. Local transformations are applied relative to this point.
alpha: AnimatedFloat
The alpha (opacity) of this sprite, between 0 (invisible) and 1 (fully opaque).
blend_mode: BlendMode
The blend mode used to draw this sprite, or None to use its parent’s blend mode.
scissor: Option<Rectangle>
The scissor rectangle used for clipping/masking, in the local coordinate system. The scissor rectangle affects both rendering and hit testing, and applies to this sprite and all children. Rectangles with negative width or height are OK.
WARNING: When using scissor testing, this sprite (and its parents) must not be rotated. The scissor rectangle must be axis-aligned when converted to screen coordinates.
visible: bool
Whether this sprite should be drawn. Invisible sprites do not receive pointer events.
pixel_snapping: bool
Whether this sprite’s position will be rounded to the nearest whole pixel when rendering, for crisper images. Defaults to true. This can be disabled for smoother animation, at the risk of fuzziness when an image lies on a subpixel.
pointer_enabled: bool
Whether this sprite or any children should receive pointer events. Defaults to true.
Implementations
sourceimpl Sprite
impl Sprite
pub const VISIBLE: u32 = 2u32
pub const POINTER_ENABLED: u32 = 4u32
pub const LOCAL_MATRIX_DIRTY: u32 = 8u32
pub const VIEW_MATRIX_DIRTY: u32 = 16u32
pub const PIXEL_SNAPPING: u32 = 32u32
pub const HOVERING: u32 = 64u32
pub const ROTATION_DIRTY: u32 = 128u32
pub const NEXT_FLAG: u32 = 256u32
pub fn new() -> Self
sourcepub fn hit_test(entity: Entity, x: f32, y: f32) -> Option<Sprite>
pub fn hit_test(entity: Entity, x: f32, y: f32) -> Option<Sprite>
Search for a sprite in the entity hierarchy lying under the given point, in local coordinates. Ignores sprites that are invisible or not pointerEnabled during traversal. Returns None if neither the entity or its children contain a sprite under the given point.
sourcepub fn bounds(entity: Entity, result: Option<Rectangle>) -> Rectangle
pub fn bounds(entity: Entity, result: Option<Rectangle>) -> Rectangle
Calculate the bounding box of an entity hierarchy. Returns the smallest rectangle in local coordinates that fully encloses all child sprites.
sourcepub fn render(entity: &Entity, gfx: &Box<dyn Graphics>)
pub fn render(entity: &Entity, gfx: &Box<dyn Graphics>)
Renders an entity hierarchy to the given Graphics.
sourcepub fn natural_width(&self) -> f32
pub fn natural_width(&self) -> f32
The “natural” width of this sprite, without any transformations being applied. Used for hit testing. This does not consider child sprites, use Sprite.getBounds for that.
sourcepub fn natural_height(&self) -> f32
pub fn natural_height(&self) -> f32
The “natural” height of this sprite, without any transformations being applied. Used for hit testing. This does not consider child sprites, use Sprite.getBounds for that.
sourcepub fn contains(&mut self, view_x: f32, view_y: f32) -> bool
pub fn contains(&mut self, view_x: f32, view_y: f32) -> bool
Returns true if the given point (in viewport/stage coordinates) lies inside this sprite.
sourcepub fn contains_local(&self, local_x: f32, local_y: f32) -> bool
pub fn contains_local(&self, local_x: f32, local_y: f32) -> bool
Returns true if the given point (in local coordinates) lies inside this sprite.
sourcepub fn local_matrix(&mut self) -> Matrix
pub fn local_matrix(&mut self) -> Matrix
Returns the local transformation matrix, relative to the parent. This matrix may be modified to position the sprite, but any changes will be invalidated when the x, y, scaleX, scaleY, rotation, anchorX, or anchorY properties are updated.
sourcepub fn view_matrix(&mut self) -> Matrix
pub fn view_matrix(&mut self) -> Matrix
Returns the view transformation matrix, relative to the root. Do NOT modify this matrix.
sourcepub fn set_anchor(&mut self, x: f32, y: f32) -> &Self
pub fn set_anchor(&mut self, x: f32, y: f32) -> &Self
Chainable convenience method to set the anchor position. @returns This instance, for chaining.
sourcepub fn center_anchor(&mut self) -> &Self
pub fn center_anchor(&mut self) -> &Self
Chainable convenience method to center the anchor using the natural width and height. @returns This instance, for chaining.
sourcepub fn set_xy(&mut self, x: f32, y: f32) -> &Self
pub fn set_xy(&mut self, x: f32, y: f32) -> &Self
Chainable convenience method to set the position. @returns This instance, for chaining.
sourcepub fn set_alpha(&mut self, alpha: f32) -> &Self
pub fn set_alpha(&mut self, alpha: f32) -> &Self
Chainable convenience method to set the alpha. @returns This instance, for chaining.
sourcepub fn set_rotation(&mut self, rotation: f32) -> &Self
pub fn set_rotation(&mut self, rotation: f32) -> &Self
Chainable convenience method to set the rotation. @returns This instance, for chaining.
sourcepub fn set_scale(&mut self, scale: f32) -> &Self
pub fn set_scale(&mut self, scale: f32) -> &Self
Chainable convenience method to uniformly set the scale. @returns This instance, for chaining.
sourcepub fn set_scale_xy(&mut self, scale_x: f32, scale_y: f32) -> &Self
pub fn set_scale_xy(&mut self, scale_x: f32, scale_y: f32) -> &Self
Chainable convenience method to set the scale. @returns This instance, for chaining.
sourcepub fn set_blend_mode(&mut self, blend_mode: BlendMode) -> &Self
pub fn set_blend_mode(&mut self, blend_mode: BlendMode) -> &Self
Chainable convenience method to set the blendMode. @returns This instance, for chaining.
sourcepub fn disable_pointer(&mut self) -> &Self
pub fn disable_pointer(&mut self) -> &Self
Chainable convenience method to set pointerEnabled to false. @returns This instance, for chaining.
sourcepub fn disable_pixel_snapping(&mut self) -> &Self
pub fn disable_pixel_snapping(&mut self) -> &Self
Chainable convenience method to set pixelSnapping to false. @returns This instance, for chaining.
pub fn on_added(&self)
pub fn on_removed(&mut self)
pub fn on_update(&mut self, dt: f32)
pub fn is_view_matrix_dirty(&self) -> bool
pub fn parent_sprite(&self) -> Option<Sprite>
pub fn pointer_down(&mut self) -> &Option<Signal1<PointerEvent>>
pub fn pointer_move(&mut self) -> &Option<Signal1<PointerEvent>>
pub fn pointer_up(&mut self) -> &Option<Signal1<PointerEvent>>
pub fn pointer_in(&mut self) -> &Option<Signal1<PointerEvent>>
pub fn pointer_out(&mut self) -> &Option<Signal1<PointerEvent>>
pub fn connect_hover(&self)
pub fn visible(&self) -> bool
pub fn set_visible(&mut self, visible: bool)
pub fn pointer_enabled(&self) -> bool
pub fn set_pointer_enabled(&mut self, pointer_enabled: bool)
pub fn pixel_snapping(&self) -> bool
pub fn set_pixel_snapping(&mut self, pixel_snapping: bool)
pub fn on_pointer_down(&mut self, event: PointerEvent)
pub fn on_pointer_move(&mut self, event: PointerEvent)
pub fn on_hover(&mut self, event: PointerEvent)
pub fn on_pointer_up(&mut self, event: PointerEvent)
pub fn hit_test_backwards(
entity: Option<Entity>,
x: f32,
y: f32
) -> Option<Sprite>
pub fn extend_rect(matrix: Matrix, x: f32, y: f32, rect: &mut Rectangle)
Trait Implementations
sourceimpl AsRef<Sprite> for EmitterSprite
impl AsRef<Sprite> for EmitterSprite
sourceimpl AsRef<Sprite> for FillSprite
impl AsRef<Sprite> for FillSprite
sourceimpl AsRef<Sprite> for ImageSprite
impl AsRef<Sprite> for ImageSprite
sourceimpl AsRef<Sprite> for PatternSprite
impl AsRef<Sprite> for PatternSprite
sourceimpl AsRef<Sprite> for TextSprite
impl AsRef<Sprite> for TextSprite
sourceimpl AsRef<Sprite> for MovieSprite
impl AsRef<Sprite> for MovieSprite
Auto Trait Implementations
impl !RefUnwindSafe for Sprite
impl !Send for Sprite
impl !Sync for Sprite
impl Unpin for Sprite
impl !UnwindSafe for Sprite
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Fr, To> IntoColor<To> for Fr where
To: FromColor<Fr>,
impl<Fr, To> IntoColor<To> for Fr where
To: FromColor<Fr>,
sourcefn into_color(self) -> To
fn into_color(self) -> To
Convert into color
impl<T> Pointable for T
impl<T> Pointable for T
impl<T> SetParameter for T
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
Sets value
as a parameter of self
.