use crate::vec2::Vec2; use num::{Num, ToPrimitive}; #[derive(Copy, Clone)] pub struct Rect { pub pos: Vec2, pub size: Vec2, } impl Rect { pub fn new(x: T, y: T, w: T, h: T) -> Rect { Rect { pos: Vec2 { x, y }, size: Vec2 { x: w, y: h }, } } pub fn pos2(&self) -> Vec2 { self.pos + self.size } pub fn contains(&self, point: Vec2) -> bool { let p2 = self.pos2(); point.x >= self.pos.x && point.y >= self.pos.y && point.x < p2.x && point.y < p2.y } }