onyx 0.2.0

A simple engine for simple minds
Documentation
use super::real::Real;
use super::Vec2;

#[derive(Copy, Clone)]
pub struct Rect<R: Real = f32> {
    pub position: Vec2<R>,
    pub size: Vec2<R>,
}

impl<R: Real> Rect<R> {
    pub fn new(position: Vec2<R>, size: Vec2<R>) -> Self {
        Self { position, size }
    }

    pub fn contains(&self, v: Vec2<R>) -> bool {
        (self.position.x <= v.x) && (v.x < self.position.x + self.size.x) &&
        (self.position.y <= v.y) && (v.y < self.position.y + self.size.y)
    }
}