rustbatch 0.4.0

purely game dewelopment crate that offers simple but powerfull 2D rendering and some fast solutions for game world bottle necks
Documentation
use crate::Vect;

/// More about Curve on [wikipedia](https://en.wikipedia.org/wiki/B%C3%A9zier_curve).
/// Its mainly used for interpolation.
#[derive(Copy, Clone)]
pub struct Curve {
    a: Vect,
    a_handle: Vect,
    b: Vect,
    b_handle: Vect,
    placeholder: bool
}

impl Curve {
    pub const NONE: Self = Self{a: Vect::ZERO, b: Vect::ZERO, a_handle: Vect::ZERO, b_handle: Vect::ZERO, placeholder: true };
    pub const LINEAR_INCREASING: Self = curve!(0, 0; 0, 0; 1, 1; 1, 1);
    pub const LINEAR_DECREASING: Self = curve!(0, 1; 0, 1; 1, 0; 1, 0);


    #[inline]
    pub fn new(a: (f32, f32), a_handle: (f32, f32), b: (f32, f32), b_handle: (f32, f32)) -> Self {
        Self {
            a: Vect {x: a.0, y: a.1},
            a_handle: Vect {x: a_handle.0, y: a_handle.1},
            b: Vect {x: b.0, y: b.1},
            b_handle: Vect {x: b_handle.0, y: b_handle.1},
            placeholder: false,
        }
    }

    /// only method fo Cure project t to position along the curve. There is lathery nothing else
    /// you can do with this thing anyway. If you use Curve::NONE This function always returns
    /// Vect::UP as optimization in case this Curve is just placeholder
    #[inline]
    pub fn get_point(&self, t: f32) -> Vect {
        if self.placeholder {
            return Vect::UP;
        }

        let omt = 1.0 - t;

        self.a * (omt * omt * omt) + self.a_handle * (omt * omt * t * 3.0) + self.b_handle * (omt * t * t * 3.0) + self.b * (t * t * t)
    }
}