#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Rect {
pub x: f32,
pub y: f32,
pub width: f32,
pub height: f32,
}
impl Rect {
pub(crate) fn into_corners(self) -> (f32, f32, f32, f32) {
(self.x, self.y, self.x + self.width, self.y + self.height)
}
}
impl From<(f32, f32, f32, f32)> for Rect {
fn from(from: (f32, f32, f32, f32)) -> Self {
Rect {
x: from.0,
y: from.1,
width: from.2,
height: from.3,
}
}
}
impl From<(i32, i32, i32, i32)> for Rect {
fn from(from: (i32, i32, i32, i32)) -> Self {
Rect {
x: from.0 as f32,
y: from.1 as f32,
width: from.2 as f32,
height: from.3 as f32,
}
}
}
impl From<RectPx> for Rect {
fn from(from: RectPx) -> Self {
Rect {
x: from.x as f32,
y: from.y as f32,
width: from.width as f32,
height: from.height as f32,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub(crate) struct RectPx {
pub x: i32,
pub y: i32,
pub width: i32,
pub height: i32,
}
impl From<(i32, i32, i32, i32)> for RectPx {
fn from(from: (i32, i32, i32, i32)) -> Self {
RectPx {
x: from.0,
y: from.1,
width: from.2,
height: from.3,
}
}
}
impl From<RectPx> for (i32, i32, i32, i32) {
fn from(from: RectPx) -> Self {
(from.x, from.y, from.width, from.height)
}
}