From 541acb83c081808dc2c19e2cb9a891792462999b Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 10 Jan 2017 07:36:48 +0100 Subject: vu-single-colour: add support for infinity repeat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/vu-single-colour.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/vu-single-colour.c b/src/vu-single-colour.c index af66b77..7448218 100644 --- a/src/vu-single-colour.c +++ b/src/vu-single-colour.c @@ -3,6 +3,7 @@ #include "util.h" #include +#include #include typedef double pixel_t[4]; @@ -10,7 +11,7 @@ typedef double pixel_t[4]; static void usage(void) { - eprintf("usage: %s [-f frames] -w width -h height (X Y Z | Y) [alpha]\n", argv0); + eprintf("usage: %s [-f frames | -f 'inf'] -w width -h height (X Y Z | Y) [alpha]\n", argv0); } int @@ -21,11 +22,16 @@ main(int argc, char *argv[]) size_t x, y, n; pixel_t buf[1024]; ssize_t r; + int inf = 0; + char *arg; ARGBEGIN { case 'f': - if (tozu(EARGF(usage()), 1, SIZE_MAX, &frames)) - eprintf("argument of -f must be an integer in [1, %zu]\n", SIZE_MAX); + arg = EARGF(usage()); + if (!strcmp(arg, "inf")) + inf = 1, frames = 0; + else if (tozu(arg, 1, SIZE_MAX, &frames)) + eprintf("argument of -f must be an integer in [1, %zu] or 'inf'\n", SIZE_MAX); break; case 'w': if (tozu(EARGF(usage()), 1, SIZE_MAX, &width)) @@ -64,7 +70,7 @@ main(int argc, char *argv[]) buf[x][2] = Z; buf[x][3] = alpha; } - while (frames--) { + while (inf || frames--) { for (y = height; y--;) { for (x = width; x;) { x -= n = ELEMENTSOF(buf) < x ? ELEMENTSOF(buf) : x; -- cgit v1.2.3-70-g09d2