aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/turn2line.c
diff options
context:
space:
mode:
authorepochqwert <epoch@hacking.allowed.org>2015-04-24 03:56:26 -0500
committerepochqwert <epoch@hacking.allowed.org>2015-04-24 03:56:26 -0500
commit89b165504c98599839dfb8a8988f27e91db2dba2 (patch)
tree4a8d5c1e7939040f42910aa472eae6b20a351dda /src/bin/turn2line.c
parenta36652959e52e8c810b7d2d76a283b2ae9718d96 (diff)
downloadmisc-89b165504c98599839dfb8a8988f27e91db2dba2.tar.gz
misc-89b165504c98599839dfb8a8988f27e91db2dba2.zip
added three little programs for generating dragon curve ascii-art.
lineplot and turn2line can be used for other stuff, but some constants will need to be changed. also they were golfed. so have fun.
Diffstat (limited to 'src/bin/turn2line.c')
-rw-r--r--src/bin/turn2line.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/bin/turn2line.c b/src/bin/turn2line.c
new file mode 100644
index 0000000..3dc190a
--- /dev/null
+++ b/src/bin/turn2line.c
@@ -0,0 +1,16 @@
+#include <stdio.h>
+int main(int argc,char *argv[]) {
+ int in,x=0,dx,y=0,dy,h=0,dh=argc<2?-1:atoi(argv[1]);
+ for(;(in=fgetc(stdin)) != -1;dh=-1,x+=dx,y+=dy) {
+ if(dh == -1) {
+ dh=-4;
+ switch(in) { case'B':dh++;case'm':dh++;case'L':dh++;case'l':dh++;
+ case'F':dh++;case'r':dh++;case'R':dh++;case's':dh++;default:break; }
+ if(dh==-4) continue;
+ }
+ h=(h+8+dh)%8;
+ dx=(signed char)"\x01\x01\x00\xff\xff\xff\x00\x01"[h%8];
+ dy=(signed char)"\x00\x01\x01\x01\x00\xff\xff\xff"[h%8];
+ printf("%d %d %d %d\n",x,y,x+dx,y+dy);
+ }
+}