mirror of
https://github.com/eRgo35/ascii.git
synced 2026-02-04 04:46:09 +01:00
camera read
This commit is contained in:
63
src/main.rs
63
src/main.rs
@@ -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}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user