logo
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: Componentx: 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

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.

Calculate the bounding box of an entity hierarchy. Returns the smallest rectangle in local coordinates that fully encloses all child sprites.

Renders an entity hierarchy to the given Graphics.

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.

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.

Returns true if the given point (in viewport/stage coordinates) lies inside this sprite.

Returns true if the given point (in local coordinates) lies inside this sprite.

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.

Returns the view transformation matrix, relative to the root. Do NOT modify this matrix.

Chainable convenience method to set the anchor position. @returns This instance, for chaining.

Chainable convenience method to center the anchor using the natural width and height. @returns This instance, for chaining.

Chainable convenience method to set the position. @returns This instance, for chaining.

Chainable convenience method to set the alpha. @returns This instance, for chaining.

Chainable convenience method to set the rotation. @returns This instance, for chaining.

Chainable convenience method to uniformly set the scale. @returns This instance, for chaining.

Chainable convenience method to set the scale. @returns This instance, for chaining.

Chainable convenience method to set the blendMode. @returns This instance, for chaining.

Chainable convenience method to set pointerEnabled to false. @returns This instance, for chaining.

Chainable convenience method to set pixelSnapping to false. @returns This instance, for chaining.

Draws this sprite to the given Graphics.

Trait Implementations

Converts this type into a shared reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Typed getter

Inspect the context.

Inspect the context.

Inspect the context.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Convert into color

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Sets value as a parameter of self.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.