blind-spiral-gradient: add -t - blind - suckless command-line video editing utility
 (HTM) git clone git://git.suckless.org/blind
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit e7f1780c5c05840ec3eca54b83d76c2658bf5de8
 (DIR) parent d91c5e12a53a33d50a5a0cef41255ae5b39bd55e
 (HTM) Author: Mattias Andrée <maandree@kth.se>
       Date:   Tue, 11 Jul 2017 21:40:43 +0200
       
       blind-spiral-gradient: add -t
       
       Signed-off-by: Mattias Andrée <maandree@kth.se>
       
       Diffstat:
         M man/blind-spiral-gradient.1         |      23 ++++++++++++++++++++++-
         M src/blind-spiral-gradient.c         |      13 ++++++++++---
       
       2 files changed, 32 insertions(+), 4 deletions(-)
       ---
 (DIR) diff --git a/man/blind-spiral-gradient.1 b/man/blind-spiral-gradient.1
       @@ -4,7 +4,8 @@ blind-spiral-gradient - Generate a video with a spiral gradient
        .SH SYNOPSIS
        .B blind-spiral-gradient
        [-s
       -.IR spirals ]
       +.I spirals
       +| -t]
        [-al]
        -w
        .I width
       @@ -112,11 +113,31 @@ distributed.
        .I spirals
        can be any non-zero real number.
        .TP
       +.B -t
       +Base the resulting values only on the angle
       +in the spiral formula rather than then both
       +the angle and radius. This is useful for
       +creating transitions with spiral effects.
       +.TP
        .BR -w " "\fIwidth\fP
        The width of the video, in pixels.
        .TP
        .BR -h " "\fIheight\fP
        The height of the video, in pixels.
       +.SH NOTES
       +Because
       +.B -s
       +has no affect when
       +.B -t
       +is applied,
       +.B -s
       +and
       +.B -t
       +cannot be combined unless
       +.I spirals
       +is 1. This will change in the future
       +if a way to meaningfully combined the
       +two flags is found.
        .SH SEE ALSO
        .BR blind (7),
        .BR blind-from-text (7),
 (DIR) diff --git a/src/blind-spiral-gradient.c b/src/blind-spiral-gradient.c
       @@ -1,10 +1,11 @@
        /* See LICENSE file for copyright and license details. */
        #include "common.h"
        
       -USAGE("[-s spirals] [-al] -w width -h height")
       +USAGE("[-s spirals | t] [-al] -w width -h height")
        
        static int anticlockwise = 0;
        static int logarithmic = 0;
       +static int angle = 0;
        static double spirals = 1;
        static size_t width = 0;
        static size_t height = 0;
       @@ -98,7 +99,10 @@ static int with_vector;
                                                        r = pow(r / b, ep);\
                                                        r = (r - v) / (2 * (TYPE)M_PI);\
                                                }\
       -                                        r = mod(r, 1 / (TYPE)spirals) * (TYPE)spirals + r - mod(r, (TYPE)1);\
       +                                        if (angle)\
       +                                                r = (int)(r + 1) + v / (2 * (TYPE)M_PI);\
       +                                        else\
       +                                                r = mod(r, 1 / (TYPE)spirals) * (TYPE)spirals + r - mod(r, (TYPE)1);\
                                                buf[ptr][0] = buf[ptr][1] = buf[ptr][2] = buf[ptr][3] = r;\
                                                if (++ptr == ELEMENTSOF(buf)) {\
                                                        ewriteall(STDOUT_FILENO, buf, sizeof(buf), "<stdout>");\
       @@ -131,6 +135,9 @@ main(int argc, char *argv[])
                        if (!spirals)
                                eprintf("the value of -s must not be 0");
                        break;
       +        case 't':
       +                angle = 1;
       +                break;
                case 'w':
                        width = etozu_flag('w', UARGF(), 1, SIZE_MAX);
                        break;
       @@ -141,7 +148,7 @@ main(int argc, char *argv[])
                        usage();
                } ARGEND;
        
       -        if (!width || !height || argc)
       +        if (!width || !height || argc || (spirals != 1 && angle))
                        usage();
        
                eopen_stream(&stream, NULL);