use super::Vec2D;
#[derive(Debug, Clone, Copy)]
pub enum WrappingMode {
Wrap,
Ignore,
Panic,
}
impl WrappingMode {
#[must_use]
pub fn handle_bounds(&self, pos: Vec2D, bounds: Vec2D) -> Option<Vec2D> {
let in_bounds_pos = pos.rem_euclid(bounds);
match self {
Self::Wrap => Some(in_bounds_pos),
Self::Ignore => {
if pos == in_bounds_pos {
Some(pos)
} else {
None
}
}
Self::Panic => {
if pos == in_bounds_pos {
Some(pos)
} else {
panic!("{pos} is out of bounds");
}
}
}
}
}