Add PathFinder trait

This commit is contained in:
hal8174 2025-01-28 21:54:20 +01:00
parent 5c8010c23b
commit 08eb0a8e11
8 changed files with 688 additions and 373 deletions

View file

@ -67,12 +67,6 @@ impl std::ops::Sub for Position {
}
}
impl From<(i32, i32)> for Position {
fn from(value: (i32, i32)) -> Self {
Position::new(value.0, value.1)
}
}
impl std::ops::Mul<i32> for Position {
type Output = Position;
@ -91,3 +85,9 @@ impl std::ops::Mul<Position> for i32 {
rhs
}
}
impl From<(PositionType, PositionType)> for Position {
fn from(value: (PositionType, PositionType)) -> Self {
Self::new(value.0, value.1)
}
}

View file

@ -26,6 +26,7 @@ pub trait Visualize {
}
}
#[derive(Debug, Clone, Copy)]
pub enum Symbol {
Arrow(Direction),
ArrowEnter(Direction),
@ -131,6 +132,16 @@ impl Visualization {
}
}
pub fn overlay_visualization(&mut self, other: &Self) {
self.size = Position::new(
PositionType::max(self.size.x, other.size.x),
PositionType::max(self.size.y, other.size.y),
);
self.symbols
.extend(other.symbols.iter().map(|(&k, &v)| (k, v)));
}
pub fn size(&self) -> Position {
self.size
}