camera read

This commit is contained in:
2024-07-07 23:58:15 +02:00
parent 2e87792a7f
commit a75c300692
9 changed files with 1244 additions and 99 deletions

View File

@@ -1,34 +1,49 @@
use clap::Parser;
mod libs;
fn main() {
println!("ASCII Generator\n----------------");
eprintln!("ASCII Generator\n----------------");
let args = libs::args::Args::parse();
let path = args.image.clone();
let mut img = if !path.is_empty() {
libs::image::load_image(&path)
} else {
match libs::image::load_image_from_stdin() {
Ok(img) => img,
Err(e) => {
eprintln!("Error: {e}");
std::process::exit(1);
}
match args.command {
Some(libs::args::Subcommands::Gen {
image,
invert,
colorful,
width,
height,
pixel,
noresize,
matrix,
nofill,
output,
lightmap,
}) => {
libs::gen_handler::generator(
image, invert, colorful, width, height, pixel, noresize, matrix, nofill, output,
lightmap,
);
}
Some(libs::args::Subcommands::Cam {
invert,
colorful,
width,
height,
pixel,
noresize,
matrix,
nofill,
lightmap,
}) => {
libs::cam_handler::video(
invert, colorful, width, height, pixel, noresize, matrix, nofill, lightmap,
);
}
None => {
eprintln!("No subcommand provided. Available subcommands: `gen`, `cam`");
std::process::exit(1);
}
};
libs::image::print_size(&img);
if !args.noresize {
img = libs::image::resize_image(&img, args.width, args.height);
println!("Image resized");
libs::image::print_size(&img);
}
let ascii_img = libs::ascii::to_ascii(&img, &args);
println!("ASCII image created");
println!("{ascii_img}");
}