Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimbbp committed Apr 10, 2024
1 parent 61f5504 commit d6261f6
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions spritefire/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,39 @@ use std::path::{Path, PathBuf};
//fn simple_resize
// resizes every image in a folder to proper spritefire resolution

//TODO:
//struct or func for background removal

enum Aspect {
Horizontal,
Vertical,
Square,
}

struct Crop {
aspect: Aspect,
x: u16,
y: u16,
width: u16,
height: u16,
}
impl Crop {
fn simple(image_path: &PathBuf) -> Self {
let img = image::open(image_path);
//Q: How to handle errors in this sort of thing?
}
fn get_aspect(image_path: &PathBuf) -> Aspect {
let (rx, ry) = img.dimensions();
if rx > ry {
Aspect::Horizontal
} else if rx < ry {
Aspect::Horizontal
} else {
Aspect::Square
}
}
}

pub fn build_sprites(input: &str, save: &str) -> std::io::Result<()> {
let input_folder = Path::new(input);
if input_folder.is_dir() {
Expand Down Expand Up @@ -41,6 +74,11 @@ fn simple_resize(image_path: &PathBuf, save: &str) -> Result<(), ImageError> {
Ok(())
}

fn read_dimensions(image_path: &PathBuf) -> Result<(u32, u32), ImageError> {
let img = image::open(image_path)?;
Ok(img.dimensions())
}

//Advanced:
//fn alpha background
// detects background and replaces it with an alpha layer
Expand Down

0 comments on commit d6261f6

Please sign in to comment.