Skip to main content

Animatable

Trait Animatable 

Source
pub trait Animatable:
    Copy
    + Debug
    + PartialEq {
    const N: usize;

    // Required methods
    fn lerp(a: Self, b: Self, k: f64) -> Self;
    fn component(self, i: usize) -> f64;
    fn from_fn(f: impl FnMut(usize) -> f64) -> Self;

    // Provided method
    fn from_json(v: &Value) -> Option<Self> { ... }
}
Expand description

A value that can be keyframed: f64, [f64; N] (vectors, colours).

Required Associated Constants§

Source

const N: usize

Components.

Required Methods§

Source

fn lerp(a: Self, b: Self, k: f64) -> Self

Source

fn component(self, i: usize) -> f64

Source

fn from_fn(f: impl FnMut(usize) -> f64) -> Self

Provided Methods§

Source

fn from_json(v: &Value) -> Option<Self>

A number (N = 1), an array of N numbers, or (N = 3 or 4) a colour name.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Animatable for f64

Source§

const N: usize = 1

Source§

fn lerp(a: Self, b: Self, k: f64) -> Self

Source§

fn component(self, _: usize) -> f64

Source§

fn from_fn(f: impl FnMut(usize) -> f64) -> Self

Source§

impl<const N: usize> Animatable for [f64; N]

Source§

const N: usize = N

Source§

fn lerp(a: Self, b: Self, k: f64) -> Self

Source§

fn component(self, i: usize) -> f64

Source§

fn from_fn(f: impl FnMut(usize) -> f64) -> Self

Implementors§