flip/mirror/rotate functions for tiles

This commit is contained in:
2020-07-20 19:52:31 +01:00
parent 226292dcac
commit 9081c157d6
2 changed files with 29 additions and 3 deletions

View File

@@ -40,6 +40,32 @@ impl Tile {
"".to_string()
}
}
// todo refactor
pub fn flip(&mut self) {
self.animation_frames = self.animation_frames.iter().map(|frame: &Image| {
let mut image = frame.clone();
image.flip();
image
}).collect()
}
pub fn mirror(&mut self) {
self.animation_frames = self.animation_frames.iter().map(|frame: &Image| {
let mut image = frame.clone();
image.mirror();
image
}).collect()
}
pub fn rotate(&mut self) {
self.animation_frames = self.animation_frames.iter().map(|frame: &Image| {
let mut image = frame.clone();
image.rotate();
image
}).collect()
}
}
impl From<String> for Tile {