pub struct Sprite {
pub container: Container,
pub texture: Texture,
pub anchor: Vec2,
pub tint: Color,
}Expand description
Textured quad node. Local rect is [0, 1]²; anchor shifts that local
origin (0,0 = top-left, 1,1 = bottom-right). The sprite’s
Container::transform is then applied.
Fields§
§container: ContainerScene-graph state (transform, alpha, visible, blend mode, parent/children).
texture: TextureGPU texture sampled in the fragment shader.
anchor: Vec2Normalized anchor in [0, 1]². 0,0 = top-left, 0.5, 0.5 = center.
tint: ColorMultiplied with the sampled texel.
Implementations§
Source§impl Sprite
impl Sprite
Sourcepub fn from_texture(texture: Texture) -> Self
pub fn from_texture(texture: Texture) -> Self
Construct a sprite from a texture with default container, top-left anchor, and white tint.
Sourcepub fn with_anchor(self, anchor: Vec2) -> Self
pub fn with_anchor(self, anchor: Vec2) -> Self
Builder: set the anchor.
Source§impl Sprite
impl Sprite
Sourcepub fn with_anchor_set(&mut self, anchor: Vec2) -> &mut Self
pub fn with_anchor_set(&mut self, anchor: Vec2) -> &mut Self
Helper used by CaptionBlock to set the anchor mutably without
needing a re-construction. Public so other compositions can
reuse it; identical to Sprite::with_anchor but takes &mut self.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sprite
impl !RefUnwindSafe for Sprite
impl Send for Sprite
impl Sync for Sprite
impl Unpin for Sprite
impl UnsafeUnpin for Sprite
impl !UnwindSafe for Sprite
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more