fix: cleanup main()
This commit is contained in:
parent
43c53555d9
commit
75d1b93f7e
1 changed files with 15 additions and 19 deletions
30
src/main.rs
30
src/main.rs
|
@ -181,29 +181,21 @@ fn main() -> anyhow::Result<()> {
|
||||||
first_strand_index: 8,
|
first_strand_index: 8,
|
||||||
};
|
};
|
||||||
|
|
||||||
match args.action {
|
let image = match args.action {
|
||||||
Action::Solid { color } => {
|
Action::Solid { color } => {
|
||||||
let image = RgbImage::from_pixel(layout.width_px(), layout.height_px(), color.into());
|
RgbImage::from_pixel(layout.width_px(), layout.height_px(), color.into())
|
||||||
let frame_num: u32 = rand::thread_rng().gen();
|
|
||||||
send_frame(&socket, layout, frame_num, &image)?;
|
|
||||||
}
|
}
|
||||||
Action::Clear => {
|
Action::Clear => RgbImage::new(layout.width_px(), layout.height_px()),
|
||||||
let image = RgbImage::new(layout.width_px(), layout.height_px());
|
Action::Image { path } => ImageReader::open(path)?
|
||||||
let frame_num: u32 = rand::thread_rng().gen();
|
|
||||||
send_frame(&socket, layout, frame_num, &image)?;
|
|
||||||
}
|
|
||||||
Action::Image { path } => {
|
|
||||||
let image = ImageReader::open(path)?
|
|
||||||
.decode()?
|
.decode()?
|
||||||
.resize_to_fill(layout.width_px(), layout.height_px(), FilterType::Gaussian)
|
.resize_to_fill(layout.width_px(), layout.height_px(), FilterType::Gaussian)
|
||||||
.into_rgb8();
|
.into_rgb8(),
|
||||||
let frame_num: u32 = rand::thread_rng().gen();
|
|
||||||
send_frame(&socket, layout, frame_num, &image)?;
|
|
||||||
}
|
|
||||||
Action::Rainbow => {
|
Action::Rainbow => {
|
||||||
print!("{}", termion::clear::All);
|
print!("{}", termion::clear::All);
|
||||||
|
|
||||||
for frame in 0.. {
|
let mut frame = 0;
|
||||||
|
loop {
|
||||||
|
let start = Instant::now();
|
||||||
let image = rainbow(layout, frame);
|
let image = rainbow(layout, frame);
|
||||||
|
|
||||||
print_image(&image);
|
print_image(&image);
|
||||||
|
@ -212,9 +204,13 @@ fn main() -> anyhow::Result<()> {
|
||||||
send_frame(&socket, layout, frame_num, &image)?;
|
send_frame(&socket, layout, frame_num, &image)?;
|
||||||
|
|
||||||
sleep(Duration::from_millis(16));
|
sleep(Duration::from_millis(16));
|
||||||
|
frame += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
let frame_num: u32 = rand::thread_rng().gen();
|
||||||
|
send_frame(&socket, layout, frame_num, &image)?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue