diff options
author | jacob janzen <jacob.a.s.janzen@gmail.com> | 2022-08-28 12:55:57 -0500 |
---|---|---|
committer | jacob janzen <jacob.a.s.janzen@gmail.com> | 2022-08-28 12:55:57 -0500 |
commit | a8cf2c052a457e743c2e9fc95ba3d4463f8511fa (patch) | |
tree | 476174344e44de7d2949808eefd2b265bebf8d13 /src/main.rs | |
parent | e8e391abb2789034138b430e6e129a20f6aa6d1a (diff) |
refactor
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 36 |
1 files changed, 7 insertions, 29 deletions
diff --git a/src/main.rs b/src/main.rs index b904808..49eee78 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,7 @@ +//! # Writhing Mass of Flesh +//! +//! This program procedurally generates a GIF that resembles a writhing mass +//! of flesh. Originally, it was intended to be bubbles, but so it goes. /* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -14,16 +18,12 @@ */ use std::fs::File; use std::process; -use std::sync::mpsc; -use std::thread; use bubbles::Args; use bubbles::Image; fn main() { - let args = Args::read(); - let (tx, rx) = mpsc::channel(); - let width = termsize::get().unwrap().cols; + let args = Args::read(); // the arguments passed into the program // create Gif data let mut data = Image::create_from_args(&args); @@ -37,28 +37,6 @@ fn main() { process::exit(1); } - thread::spawn(move || { - for received in rx { - let percent_done = received as f64 / data.frames as f64; - - for i in 0..(width as i32 - 5) as i32 { - if i < (percent_done * width as f64) as i32 { - print!("="); - } else { - print!("-"); - } - } - print!("[{}%]\r", (percent_done * 100.0) as i32); - } - }); - - for i in 0..data.frames { - tx.send(i).unwrap(); - // Create pixel array - data.fill_canvas(i); - let frame = gif::Frame::from_rgb(data.width, data.height, &mut data.pixels); - - // Write frame to file - encoder.write_frame(&frame).unwrap(); - } + // create the image + bubbles::create_image(&mut data, &mut encoder); } |