generic from_file for palettes
This commit is contained in:
parent
a8792744e1
commit
3e2c24db8a
|
@ -28,6 +28,19 @@ impl Palette {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// todo result
|
||||||
|
pub fn from_file(path: PathBuf) -> Self {
|
||||||
|
match path.extension().unwrap().to_str().unwrap() {
|
||||||
|
"pal" => Self::from_jasc(path),
|
||||||
|
"gpl" => Self::from_gpl(path),
|
||||||
|
"toml" => Self::from(
|
||||||
|
path.file_stem().as_ref().unwrap().to_str().unwrap(),
|
||||||
|
&read_to_string(&path).unwrap()
|
||||||
|
),
|
||||||
|
_ => panic!("Bad palette")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// JASC .pal format (Paint Shop Pro)
|
/// JASC .pal format (Paint Shop Pro)
|
||||||
pub fn from_jasc(path: PathBuf) -> Self {
|
pub fn from_jasc(path: PathBuf) -> Self {
|
||||||
let name = path.file_stem().unwrap().to_str().unwrap().into();
|
let name = path.file_stem().unwrap().to_str().unwrap().into();
|
||||||
|
|
Loading…
Reference in New Issue