1#[derive(Debug, Clone, Copy, PartialEq)]
4pub struct Point {
5 pub x: f32,
6 pub y: f32,
7}
8
9impl Point {
10 pub const fn new(x: f32, y: f32) -> Self {
11 Self { x, y }
12 }
13}
14
15#[derive(Debug, Clone, Copy, PartialEq)]
16pub struct Rect {
17 pub x: f32,
18 pub y: f32,
19 pub w: f32,
20 pub h: f32,
21}
22
23impl Rect {
24 pub const fn new(x: f32, y: f32, w: f32, h: f32) -> Self {
25 Self { x, y, w, h }
26 }
27 pub fn right(&self) -> f32 {
28 self.x + self.w
29 }
30 pub fn bottom(&self) -> f32 {
31 self.y + self.h
32 }
33 pub fn contains(&self, p: Point) -> bool {
34 p.x >= self.x && p.x <= self.right() && p.y >= self.y && p.y <= self.bottom()
35 }
36}