From 8b0f4e577b7f70409e5d0250b21dc54fe6b9e13c Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Thu, 12 Apr 2018 01:08:06 -0400 Subject: Combine brot rotate and scale --- bin/brot.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/bin/brot.c b/bin/brot.c index b12e4208..c8922465 100644 --- a/bin/brot.c +++ b/bin/brot.c @@ -46,8 +46,7 @@ static uint32_t color(uint32_t n) { } static double complex translate = -0.75; -static double complex rotate = 1.0; -static double scale = 2.5; +static double complex transform = 2.5; void draw(uint32_t *buf, size_t width, size_t height) { double yRatio = (height > width) ? (double)height / (double)width : 1.0; @@ -56,7 +55,7 @@ void draw(uint32_t *buf, size_t width, size_t height) { for (size_t x = 0; x < width; ++x) { double zx = ((double)x / (double)width - 0.5) * xRatio; double zy = ((double)y / (double)height - 0.5) * yRatio; - uint32_t n = mandelbrot((zx + zy * I) * scale * rotate + translate); + uint32_t n = mandelbrot((zx + zy * I) * transform + translate); buf[y * width + x] = color(n); } } @@ -73,14 +72,14 @@ bool input(char in) { case 'q': return false; 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; + case 'l': translate += translateDelta * transform; break; + case 'h': translate -= translateDelta * transform; break; + case 'j': translate += translateDelta * I * transform; break; + case 'k': translate -= translateDelta * I * transform; break; + case 'u': transform *= cexp(rotateDelta * PI * I); break; + case 'i': transform /= cexp(rotateDelta * PI * I); break; + case '+': transform /= scaleFactor; break; + case '-': transform *= scaleFactor; break; } return true; } @@ -89,11 +88,10 @@ const char *status(void) { static char buf[256]; snprintf( buf, sizeof(buf), - "-d %u -t %g+%gi -r %g+%gi -z %g", + "-i %u -t %g+%gi -f %g+%gi", depth, creal(translate), cimag(translate), - creal(rotate), cimag(rotate), - scale + creal(transform), cimag(transform) ); return buf; } -- cgit 1.4.1 an>Add more URL schemesJune McEnroe 2018-10-22Rework status lineJune McEnroe 2018-10-22Rename status and verbose tagsJune McEnroe 2018-09-16Revert "Race parallel connects"June McEnroe 2018-09-16Race parallel connectsJune McEnroe 2018-09-15Call tls_error when tls_connect_socket failsJune McEnroe 2018-09-15Try successive getaddrinfo resultsJune McEnroe 2018-09-15Render README from chatte.7June McEnroe 2018-09-14Factor out uiPrompt to call on nick changeJune McEnroe 2018-09-14Run test binaries with set -e and semicolonsJune McEnroe 2018-09-14Fail target when any test binary failsJune McEnroe 2018-09-14Run tests in default targetJune McEnroe 2018-09-14Add termEvent testsJune McEnroe 2018-09-14Check width of entire next word including codesJune McEnroe 2018-09-14Remove word handling from formatParseJune McEnroe 2018-09-14Apply consecutive formatting codes at onceJune McEnroe 2018-09-14Add tests for formatParseJune McEnroe 2018-09-13Preview with nick in input windowJune McEnroe 2018-09-13Never send PRIVMSG to TagStatus or TagVerboseJune McEnroe 2018-09-13Move color selection to format.cJune McEnroe 2018-09-13Fix len for format->split at end of stringJune McEnroe 2018-09-13Avoid uninitialized x in uiReadJune McEnroe 2018-09-13Add IRCDefault to colors enumJune McEnroe 2018-09-13Return a format->split even at the end of the stringJune McEnroe 2018-09-13Fix weird tab-complete after commaJune McEnroe 2018-09-13Rewrite UI againJune McEnroe 2018-09-12Add note about C-oJune McEnroe 2018-09-12Use formatParse split to position input cursorJune McEnroe 2018-09-12Factor out IRC formatting parsingJune McEnroe 2018-09-11Add /help equivalent to /manJune McEnroe 2018-09-11Don't render every PM as a pingJune McEnroe 2018-09-11Add urlOpenMatchJune McEnroe 2018-09-10Depend on man.sh for chroot.tar targetJune McEnroe 2018-09-10Set LESSSECURE=1 in man.shJune McEnroe 2018-09-10Add /man commandJune McEnroe 2018-09-10Install man page in chrootJune McEnroe 2018-09-10Install man pageJune McEnroe 2018-09-10Split keys into subsections and document colorsJune McEnroe 2018-09-10Add "blank" lines to chatte.1June McEnroe 2018-09-10Document key bindings in chatte.1June McEnroe 2018-09-08Document slash commands in chatte.1June McEnroe