#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct TilePos {
pub tx: u32,
pub ty: u32,
}
impl TilePos {
#[inline]
pub const fn new(tx: u32, ty: u32) -> Self {
Self { tx, ty }
}
#[inline]
pub const fn to_pixels(self) -> (u32, u32) {
(self.tx * 8, self.ty * 8)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[non_exhaustive]
pub struct TileRect {
pub tx: u32,
pub ty: u32,
pub tw: u32,
pub th: u32,
}
impl TileRect {
#[inline]
pub const fn new(tx: u32, ty: u32, tw: u32, th: u32) -> Self {
Self { tx, ty, tw, th }
}
#[inline]
pub const fn pos(&self) -> TilePos {
TilePos::new(self.tx, self.ty)
}
#[inline]
pub fn translated(&self, dx: u32, dy: u32) -> Self {
Self::new(self.tx + dx, self.ty + dy, self.tw, self.th)
}
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct BracketSides {
pub top: bool,
pub bottom: bool,
pub left: bool,
pub right: bool,
}
impl BracketSides {
pub const RIGHT_BOTTOM: Self = Self { top: false, bottom: true, left: false, right: true };
pub const ALL: Self = Self { top: true, bottom: true, left: true, right: true };
}