dedupe animation frames handling

This commit is contained in:
2020-04-29 08:27:35 +01:00
parent 8d8515bb8a
commit 8bd323b8a0
7 changed files with 127 additions and 24 deletions

View File

@@ -1,4 +1,5 @@
use crate::{from_base36, optional_data_line, AnimationFrames, Image, ToBase36};
use crate::image::animation_frames_from_string;
#[derive(Debug, Eq, PartialEq)]
pub struct Tile {
@@ -60,12 +61,9 @@ impl From<String> for Tile {
}
}
let animation_frames = lines[1..].join("");
let animation_frames: Vec<&str> = animation_frames.split(">").collect();
let animation_frames: Vec<Image> = animation_frames
.iter()
.map(|&frame| Image::from(frame.to_string()))
.collect();
let animation_frames = animation_frames_from_string(
lines[1..].join("\n")
);
Tile {
id,