From 781b46dcd48735bf2c31f5c5cae7561f9704afdb Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 30 Jun 2010 16:05:42 +0000 Subject: [PATCH] display percent of image complete on command line git-svn-id: svn://anubis/fart/trunk@265 7f9b0f55-74a9-4bce-be96-3c2cd072584d --- main/fart.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/main/fart.cc b/main/fart.cc index 320131e..a660e79 100644 --- a/main/fart.cc +++ b/main/fart.cc @@ -256,6 +256,11 @@ int main(int argc, char * argv[]) } else { + int total_pixels = height * width; + int total_pixels_1000 = total_pixels / 1000; + if (total_pixels_1000 < 1) + total_pixels_1000 = 1; + int pixel_num = 0; /* "sequential" version */ for (int i = 0; i < height; i++) { @@ -263,8 +268,15 @@ int main(int argc, char * argv[]) { int pixel = i * width + j; scene.renderPixel(j, i, &data[3 * pixel]); + pixel_num++; + if (pixel_num % total_pixels_1000 == 0) + { + double pct = 100.0 * pixel_num / (double) total_pixels; + printf("\e[8D%2.1f%%", pct); + } } } + printf("\e[8D"); } gettimeofday(&after, NULL); /* stop timing */