Skip to content

Commit

Permalink
progress indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherBiscardi committed Aug 26, 2023
1 parent 92be0fa commit f4e9a36
Show file tree
Hide file tree
Showing 3 changed files with 149 additions and 0 deletions.
144 changes: 144 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -6,4 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
indicatif = "0.17.6"
itertools = "0.11.0"
4 changes: 4 additions & 0 deletions src/main.rs
@@ -1,3 +1,4 @@
use indicatif::ProgressIterator;
use itertools::Itertools;
use std::{fs, io};

Expand All @@ -8,6 +9,9 @@ const MAX_VALUE: u8 = 255;
fn main() -> io::Result<()> {
let pixels = (0..IMAGE_HEIGHT)
.cartesian_product(0..IMAGE_WIDTH)
.progress_count(
IMAGE_HEIGHT as u64 * IMAGE_WIDTH as u64,
)
.map(|(y, x)| {
let r = x as f64 / (IMAGE_WIDTH - 1) as f64;
let g = y as f64 / (IMAGE_HEIGHT - 1) as f64;
Expand Down

0 comments on commit f4e9a36

Please sign in to comment.