summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-04-12 01:08:06 -0400
committerJune McEnroe <june@causal.agency>2018-04-12 01:08:06 -0400
commit8b0f4e577b7f70409e5d0250b21dc54fe6b9e13c (patch)
treeae6e98b435cf36055570faab809c342a94a829a8
parentClean up brot input and status (diff)
downloadsrc-8b0f4e577b7f70409e5d0250b21dc54fe6b9e13c.tar.gz
src-8b0f4e577b7f70409e5d0250b21dc54fe6b9e13c.zip
Combine brot rotate and scale
Diffstat (limited to '')
-rw-r--r--bin/brot.c26
1 files 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;
 }
r> 2020-09-12Move /opt/local behind /usr againJune McEnroe The reason I did this with pkgsrc was because I actually don't want the man(1) from mandoc, since it won't follow MANSECT. Same applies to MacPorts. I wish I could disable its man(1) with a variant or whatever. 2020-09-12Enable toc in cgit renderings of man pagesJune McEnroe But keep it disabled for READMEs since they always use non-standard sections and the TOC is just distracting there, I think. Also add the style so its h1 is the same size as the ones inside sections... 2020-09-11Install mandoc on macOSJune McEnroe 2020-09-11Rewrite install script yet againJune McEnroe 2020-09-11Remove NetBSD from install scriptJune McEnroe I never use it. 2020-09-11Use MacPorts rather than pkgsrcJune McEnroe My system is probably such a mess now... 2020-09-11Add debian VM name to sshJune McEnroe 2020-09-11Add influencer tweetJune McEnroe 2020-09-10Add The Kingdom of GodsJune McEnroe Reading has really slowed down :( 2020-09-07Add SunglassesJune McEnroe An IRC find. 2020-09-06Add Between the BreathsJune McEnroe One of those good songs from a soundtrack of a film that probably isn't? The summary sounds a lot more interesting than the title implies, at least. 2020-09-04Open /dev/tty in nudgeJune McEnroe This makes it work even when it's run connected to a pipe, i.e. as the notify command of catgirl... 2020-09-04Add nudgeJune McEnroe 2020-09-03Build fbclock with -lzJune McEnroe I guess this got lost somewhere, long ago... 2020-08-29Add tweets from retweetsJune McEnroe