Skip to main content

RavenSprite

Struct RavenSprite 

Source
pub struct RavenSprite { /* private fields */ }
Expand description

The signature effect. A stylized raven ๐Ÿฆ (painted from shapes โ€” no asset dependency, so it never goes missing) that flies in along a bezier arc with ease-out and perches on a target egui::Rect, then idle-bobs.

Motion is deterministic given (start, target, elapsed) โ€” thatโ€™s what makes RavenSprite::pos_at unit-testable. The egui-driven loop is:

โ“˜
raven.update(ctx);       // reads ctx.input(i.time), requests a repaint while flying
raven.paint(&painter);   // draws the bird at its current pos

Implementationsยง

Sourceยง

impl RavenSprite

Source

pub fn new() -> Self

A raven waiting off the top-left, ready to be aimed with [fly_to].

Source

pub fn from(self, start: Pos2) -> Self

Launch point of the flight (defaults to off-screen top-left).

Source

pub fn color(self, color: Color32) -> Self

Raven body colour (override the default near-black, e.g. for hugin_noir you might tint the beak/eye via accent separately).

Source

pub fn scale(self, scale: f32) -> Self

Overall sprite scale (1.0 โ‰ˆ a ~14px-tall bird body).

Source

pub fn fly_to(self, target: Rect) -> Self

Aim the raven at target: it will perch centred on the top edge of the rect (like landing on a table row). Resets the flight clock.

Source

pub fn pos_at(&self, elapsed: f32) -> Pos2

Deterministic position at elapsed seconds since launch โ€” the testable core. Eases along the bezier arc with easing::ease_out_back (a confident landing), holds the perch afterwards. Adds a subtle idle bob once perched.

Source

pub fn is_perched(&self) -> bool

True once the flight is over (raven is perched, idle-bobbing).

Source

pub fn pos(&self) -> Pos2

Current sprite position (set by the last update).

Source

pub fn update(&mut self, ctx: &Context)

Drive the animation from the egui clock. Pins the launch time on first call, advances current, and request_repaints while still in flight so the animation keeps ticking. Call once per frame before [paint].

Source

pub fn advance(&mut self, elapsed: f32)

Time-driven core shared by [update] and the headless test: set the current pos + facing + perched flag for elapsed seconds since launch.

Source

pub fn paint(&self, painter: &Painter)

Paint the raven at its current position. A stylized corvid built from a body ellipse-ish blob, swept wings, a wedge tail, a head, and a beak โ€” wings flap while flying and fold once perched.

Trait Implementationsยง

Sourceยง

impl Clone for RavenSprite

Sourceยง

fn clone(&self) -> RavenSprite

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) ยท Sourceยง

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Sourceยง

impl Default for RavenSprite

Sourceยง

fn default() -> Self

Returns the โ€œdefault valueโ€ for a type. Read more

Auto Trait Implementationsยง

Blanket Implementationsยง

Sourceยง

impl<T> Any for T
where T: 'static + ?Sized,

Sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Sourceยง

impl<T> Borrow<T> for T
where T: ?Sized,

Sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Sourceยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

Sourceยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Sourceยง

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Sourceยง

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Sourceยง

impl<T> CloneToUninit for T
where T: Clone,

Sourceยง

unsafe fn clone_to_uninit(&self, dest: *mut u8)

๐Ÿ”ฌThis is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

Sourceยง

fn into(self) -> U

Calls U::from(self).

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

Sourceยง

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Sourceยง

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,

Sourceยง

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Sourceยง

fn simd_from(value: T, _simd: S) -> T

Sourceยง

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Sourceยง

fn simd_into(self, simd: S) -> T

Sourceยง

impl<T> ToOwned for T
where T: Clone,

Sourceยง

type Owned = T

The resulting type after obtaining ownership.
Sourceยง

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Sourceยง

type Error = Infallible

The type returned in the event of a conversion error.
Sourceยง

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Sourceยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Sourceยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.