Skip to main content

Animator

Struct Animator 

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

Animates the values of a chart’s series.

The animator keeps the values the chart showed last and the values it should show now, and interpolates between them. The chart’s layout is recomputed on every frame of the animation, so the shapes really move rather than jumping at the end.

The clock and the easing come from euv-engine: the chart’s motion is the framework’s motion, down to the delay and the pause. The engine’s tween counts in seconds and the chart’s API counts in milliseconds, and the conversion happens here and nowhere else.

Implementations§

Source§

impl Animator

Inherent implementation of Animator.

Source

pub fn new() -> Self

Returns an animator with the default settings.

Source

pub fn duration(&self) -> f64

Returns the duration of one animation, in milliseconds.

§Returns
  • f64 - A 64-bit float.
Source

pub fn set_duration(&mut self, duration: f64) -> &mut Self

Sets the duration of one animation, in milliseconds.

A duration of zero turns the animation off, which is what a server-side render or a benchmark wants. The new duration applies to the animation that starts next.

§Arguments
  • f64 - A 64-bit float (f64).
§Returns
  • &mut Self - A mut Self value.
Source

pub fn delay(&self) -> f64

Returns the delay before the animation starts, in milliseconds.

§Returns
  • f64 - A 64-bit float.
Source

pub fn set_delay(&mut self, delay: f64) -> &mut Self

Sets the delay before the animation starts, in milliseconds.

§Arguments
  • f64 - A 64-bit float (f64).
§Returns
  • &mut Self - A mut Self value.
Source

pub fn easing(&self) -> Easing

Returns the easing of the animation.

§Returns
  • Easing - A Easing value.
Source

pub fn set_easing(&mut self, easing: Easing) -> &mut Self

Sets the easing of the animation.

§Arguments
  • Easing - A Easing parameter.
§Returns
  • &mut Self - A mut Self value.
Source

pub fn is_running(&self) -> bool

Returns true when an animation is running.

§Returns
  • bool - A boolean.
Source

pub fn pause(&mut self) -> &mut Self

Pauses the animation.

The values stay where they are until the animation is resumed.

§Returns
  • &mut Self - A mut Self value.
Source

pub fn resume(&mut self) -> &mut Self

Resumes a paused animation.

§Returns
  • &mut Self - A mut Self value.
Source

pub fn reset(&mut self) -> &mut Self

Starts the animation over.

The values go back to where the animation started, and the animation runs again from there.

§Returns
  • &mut Self - A mut Self value.
Source

pub fn remember_initial(&mut self, option: &ChartOption) -> &mut Self

Remembers the option the chart started with.

§Arguments
  • &ChartOption - Shared reference to a ChartOption.
§Returns
  • &mut Self - A mut Self value.
Source

pub fn begin(&mut self, option: &ChartOption) -> &mut Self

Starts an animation towards the given option.

The values the chart shows now become the starting point of the animation; a series that is new grows from zero.

§Arguments
  • &ChartOption - Shared reference to a ChartOption.
§Returns
  • &mut Self - A mut Self value.
Source

pub fn advance(&mut self, delta: f64) -> bool

Advances the animation by the given number of milliseconds.

Returns true when the animation is still running.

§Arguments
  • f64 - A 64-bit float (f64).
§Returns
  • bool - A boolean.
Source

pub fn apply(&self, option: &mut ChartOption)

Writes the animated values into the option.

The option’s series data is replaced by the animated values, so that the layout — and therefore the picture — follows the animation.

§Arguments
  • &mut ChartOption - Mutable reference to a ChartOption (mutated in place).

Trait Implementations§

Source§

impl Clone for Animator

Source§

fn clone(&self) -> Self

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 Debug for Animator

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Animator

Default construction for Animator.

Source§

fn default() -> Self

Constructs a default Animator value.

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<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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more