Struct gamemath::Curve[][src]

pub struct Curve<T>(_);

A heap allocated structure for representing a value curve.

Methods

impl<T> Curve<T> where
    T: Default + Clone + Copy + From<f32> + Into<f32>, 
[src]

Constructs a Curve from a slice of values.

Examples

use gamemath::Curve;

let c: Curve<f32> = Curve::new(&[0.0, 10.0, 5.0, 0.0]);

assert_eq!(c[0], 0.0);
assert_eq!(c[1], 10.0);
assert_eq!(c[2], 5.0);
assert_eq!(c[3], 0.0);

Linearly interpolates between the values of the curve by a factor.

Examples

use gamemath::Curve;

let c: Curve<f32> = Curve::new(&[0.0, 10.0, 5.0, 0.0]);

assert_eq!(c.lerp(0.75), 3.75);

Trait Implementations

impl<T> Index<usize> for Curve<T>
[src]

The returned type after indexing.

Performs the indexing (container[index]) operation.

impl<T> IndexMut<usize> for Curve<T>
[src]

Performs the mutable indexing (container[index]) operation.

Auto Trait Implementations

impl<T> Send for Curve<T> where
    T: Send

impl<T> Sync for Curve<T> where
    T: Sync