42 lines
967 B
Rust
Executable File
42 lines
967 B
Rust
Executable File
/*
|
|
* Copyright (C) 2022 Umut İnan Erdoğan <umutinanerdogan@pm.me>
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
pub struct Position {
|
|
x: u32,
|
|
y: u32,
|
|
width: u32,
|
|
height: u32,
|
|
}
|
|
|
|
impl Position {
|
|
pub fn new(x: u32, y: u32, width: u32, height: u32) -> Self {
|
|
Position { x, y, width, height }
|
|
}
|
|
|
|
pub fn contains(&self, x: u32, y: u32) -> bool {
|
|
x >= self.x && y >= self.y && x < self.x + self.width && y < self.y + self.height
|
|
}
|
|
|
|
pub fn x(&self) -> u32 {
|
|
self.x
|
|
}
|
|
|
|
pub fn y(&self) -> u32 {
|
|
self.y
|
|
}
|
|
|
|
pub fn width(&self) -> u32 {
|
|
self.width
|
|
}
|
|
|
|
pub fn height(&self) -> u32 {
|
|
self.height
|
|
}
|
|
}
|