delete toml/intermediate palettes
This commit is contained in:
parent
e35a453f76
commit
d66da61f70
|
@ -11,7 +11,6 @@ mod room;
|
|||
|
||||
pub use colour::Colour;
|
||||
pub use palette::Palette;
|
||||
pub use palette::IntermediatePalette;
|
||||
use crate::config::Config;
|
||||
|
||||
#[derive(Eq, Hash, PartialEq)]
|
||||
|
|
13
src/mock.rs
13
src/mock.rs
|
@ -67,18 +67,7 @@
|
|||
// }
|
||||
|
||||
pub(crate) mod palette {
|
||||
use crate::{Palette, Colour, IntermediatePalette};
|
||||
|
||||
pub(crate) fn intermediate() -> IntermediatePalette {
|
||||
IntermediatePalette {
|
||||
colours: vec![
|
||||
vec![0,0,0,0],
|
||||
vec![0,81,104,255],
|
||||
vec![118,159,155,255],
|
||||
vec![155,155,155,255],
|
||||
]
|
||||
}
|
||||
}
|
||||
use crate::{Palette, Colour};
|
||||
|
||||
pub(crate) fn default() -> Palette {
|
||||
Palette {
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::fs::read_to_string;
|
|||
use std::path::PathBuf;
|
||||
use serde_derive::{Serialize, Deserialize};
|
||||
use crate::colour::Colour;
|
||||
use image::{GenericImageView, Rgba, DynamicImage, Rgb, GenericImage};
|
||||
use image::{GenericImageView, Rgba, DynamicImage, GenericImage};
|
||||
use image::io::Reader as ImageReader;
|
||||
|
||||
/// todo enumerate original format
|
||||
|
@ -13,23 +13,6 @@ pub struct Palette {
|
|||
}
|
||||
|
||||
impl Palette {
|
||||
pub fn from(name: &str, toml: &str) -> Self {
|
||||
let intermediate: IntermediatePalette = toml::from_str(toml).unwrap();
|
||||
|
||||
println!("palette name: {}", name);
|
||||
|
||||
for colour in &intermediate.colours {
|
||||
println!("palette colour: {}{}{}", colour[0], colour[1], colour[2]);
|
||||
}
|
||||
|
||||
Palette {
|
||||
name: name.to_string(),
|
||||
colours: intermediate.colours.iter().map(|vec| {
|
||||
Colour::from(vec.clone())
|
||||
}).collect(),
|
||||
}
|
||||
}
|
||||
|
||||
/// todo result
|
||||
pub fn from_file(path: PathBuf) -> Self {
|
||||
match path.extension().unwrap().to_str().unwrap() {
|
||||
|
@ -38,10 +21,6 @@ impl Palette {
|
|||
"pal" => Self::from_jasc(path),
|
||||
"png" => Self::from_png(path),
|
||||
"txt" => Self::from_txt(path),
|
||||
"toml" => Self::from(
|
||||
path.file_stem().as_ref().unwrap().to_str().unwrap(),
|
||||
&read_to_string(&path).unwrap()
|
||||
),
|
||||
_ => panic!("Bad palette")
|
||||
}
|
||||
}
|
||||
|
@ -191,27 +170,6 @@ impl Palette {
|
|||
}
|
||||
}
|
||||
|
||||
/// for toml purposes
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct IntermediatePalette {
|
||||
pub colours: Vec<Vec<u8>>,
|
||||
}
|
||||
|
||||
/// for toml purposes
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct IntermediatePalettes {
|
||||
/// singular so each palette section is named "palette" instead of "palettes" in toml
|
||||
palette: Vec<IntermediatePalette>,
|
||||
}
|
||||
|
||||
// impl IntermediatePalettes {
|
||||
// pub fn from_dir() -> Self {
|
||||
// Self {
|
||||
// palette: vec![]
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::path::PathBuf;
|
||||
|
|
Loading…
Reference in New Issue