mirror of
https://github.com/eRgo35/ascii.git
synced 2026-02-04 04:46:09 +01:00
more params
This commit is contained in:
@@ -20,4 +20,10 @@ pub struct Args {
|
||||
|
||||
#[arg(long, default_value_t = 2)]
|
||||
pub pixel: usize,
|
||||
|
||||
#[arg(long, default_value_t = false)]
|
||||
pub noresize: bool,
|
||||
|
||||
#[arg(long, default_value_t = false)]
|
||||
pub matrix: bool,
|
||||
}
|
||||
@@ -55,6 +55,10 @@ pub fn to_ascii(img: &image::DynamicImage, args: &args::Args) -> String {
|
||||
char_pixel = select_dominant_color((red, green, blue), char_pixel);
|
||||
}
|
||||
|
||||
if args.matrix {
|
||||
char_pixel = char_pixel.bright_green().to_string();
|
||||
}
|
||||
|
||||
ascii_img.push_str(&char_pixel);
|
||||
}
|
||||
ascii_img.push('\n');
|
||||
|
||||
10
src/main.rs
10
src/main.rs
@@ -6,14 +6,16 @@ fn main() {
|
||||
|
||||
let args = libs::args::Args::parse();
|
||||
|
||||
let img = libs::image::load_image(&args.image);
|
||||
let mut img = libs::image::load_image(&args.image);
|
||||
libs::image::print_size(&img);
|
||||
|
||||
let resized_img = libs::image::resize_image(&img, args.width, args.height);
|
||||
if !args.noresize {
|
||||
img = libs::image::resize_image(&img, args.width, args.height);
|
||||
println!("Image resized");
|
||||
libs::image::print_size(&resized_img);
|
||||
libs::image::print_size(&img);
|
||||
}
|
||||
|
||||
let ascii_img = libs::ascii::to_ascii(&resized_img, &args);
|
||||
let ascii_img = libs::ascii::to_ascii(&img, &args);
|
||||
println!("ASCII image created");
|
||||
|
||||
println!("{ascii_img}");
|
||||
|
||||
Reference in New Issue
Block a user