From b0e29fe373368f9cd39859a7b428315fdd823005 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Wed, 11 Apr 2018 22:03:30 -0400 Subject: Clean up brot input and status --- bin/brot.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/bin/brot.c b/bin/brot.c index 3302ee9e..b12e4208 100644 --- a/bin/brot.c +++ b/bin/brot.c @@ -62,23 +62,25 @@ void draw(uint32_t *buf, size_t width, size_t height) { } } +static uint32_t depthDelta = 1; +static double translateDelta = 0.01; +static double rotateDelta = 0.01; +static double scaleFactor = 1.1; + bool input(char in) { const double PI = acos(-1.0); - double complex realTrans = 0.01 * scale * rotate; - double complex imagTrans = 0.01*I * scale * rotate; - double complex theta = cexp(0.01 * PI * I); switch (in) { case 'q': return false; - case '.': depth++; break; - case ',': if (depth) depth--; break; - case '+': scale *= 0.9; break; - case '-': scale *= 1.1; break; - case 'l': translate += realTrans; break; - case 'h': translate -= realTrans; break; - case 'j': translate += imagTrans; break; - case 'k': translate -= imagTrans; break; - case 'u': rotate *= theta; break; - case 'i': rotate /= theta; break; + case '.': depth += depthDelta; break; + case ',': if (depth > depthDelta) depth -= depthDelta; break; + case 'l': translate += translateDelta * scale * rotate; break; + case 'h': translate -= translateDelta * scale * rotate; break; + case 'j': translate += translateDelta * I * scale * rotate; break; + case 'k': translate -= translateDelta * I * scale * rotate; break; + case 'u': rotate *= cexp(rotateDelta * PI * I); break; + case 'i': rotate /= cexp(rotateDelta * PI * I); break; + case '+': scale /= scaleFactor; break; + case '-': scale *= scaleFactor; break; } return true; } @@ -87,7 +89,7 @@ const char *status(void) { static char buf[256]; snprintf( buf, sizeof(buf), - "%u %g+%gi %g+%gi %g", + "-d %u -t %g+%gi -r %g+%gi -z %g", depth, creal(translate), cimag(translate), creal(rotate), cimag(rotate), -- cgit 1.4.1 c/log/home/.config/nvim?id=cdbccb2098fce77c0a111b89485bf30f4bc4fa6a&follow=1'>nvim/init.vim (unfollow)
Commit message (Expand)Author
2018-09-07Add In for a World of HurtJune McEnroe
2018-09-05Use tabs in READMEJune McEnroe
2018-09-05Remove disown from READMEJune McEnroe
2018-09-05Factor out pixelBits, pixelSize in glitchJune McEnroe
2018-09-05Factor out pixelBits, pixelSize in pngoJune McEnroe
2018-09-05Zero after mirrorJune McEnroe
2018-09-05Simplify glitch -x -y to just zeroJune McEnroe
2018-09-05Add glitch -x and -yJune McEnroe
2018-09-04Add glitch -i to READMEJune McEnroe
2018-09-04Add -i invert option to glitchJune McEnroe
2018-09-02malloc IDAT chunks in pngo and glitchJune McEnroe
2018-09-02Use PascalCase for constants in gfxJune McEnroe
2018-09-02Use PascalCase for constantsJune McEnroe
2018-09-02Remove colorcolumn at 100June McEnroe
2018-09-02Install bc(1) on ArchJune McEnroe
2018-09-02SendEnv LANGJune McEnroe
2018-08-27Add New Order — TemptationJune McEnroe
2018-08-26Add NetBSD to install.shJune McEnroe
2018-08-24Show hostname in title over SSHJune McEnroe
2018-08-23Alias bc='bc -l'June McEnroe
2018-08-20Update usage of scheme in READMEJune McEnroe
2018-08-20Use scheme.h in fbatt and fbclockJune McEnroe
2018-08-20Generate scheme.hJune McEnroe
2018-08-20Add dependencies on gfx.hJune McEnroe
2018-08-18Add Blondie — Heart of GlassJune McEnroe
2018-08-18Set FCEDIT=$EDITORJune McEnroe
2018-08-18Only post commits with bodies to MastodonJune McEnroe
2018-08-18Run tf/cfg link script with /bin/shJune McEnroe
2018-08-18Run {,s,t}up with /bin/shJune McEnroe
2018-08-18Use whence instead of typeJune McEnroe
2018-08-18Cut off path components until right prompt fitsJune McEnroe
2018-08-17Add "private" alias to source encrypted fileJune McEnroe
2018-08-17Add vim mapping to add a #includeJune McEnroe