summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-04-11 22:03:30 -0400
committerJune McEnroe <june@causal.agency>2018-04-11 22:03:30 -0400
commit3743e8f24f7c6e5226b8b405d2e5903e1572cb2c (patch)
tree76beffde6efa83e92fd2d7b68321769d05ede4d3
parentFix brot scaling for window aspect ratio (diff)
downloadsrc-3743e8f24f7c6e5226b8b405d2e5903e1572cb2c.tar.gz
src-3743e8f24f7c6e5226b8b405d2e5903e1572cb2c.zip
Clean up brot input and status
-rw-r--r--bin/brot.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/bin/brot.c b/bin/brot.c
index 56dd04f5..69734c77 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),