From 89b165504c98599839dfb8a8988f27e91db2dba2 Mon Sep 17 00:00:00 2001 From: epochqwert Date: Fri, 24 Apr 2015 03:56:26 -0500 Subject: 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. --- src/bin/dragonturn.c | 14 ++++++++++++++ src/bin/lineplot.c | 18 ++++++++++++++++++ src/bin/turn2line.c | 16 ++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 src/bin/dragonturn.c create mode 100644 src/bin/lineplot.c create mode 100644 src/bin/turn2line.c (limited to 'src/bin') diff --git a/src/bin/dragonturn.c b/src/bin/dragonturn.c new file mode 100644 index 0000000..a12bb97 --- /dev/null +++ b/src/bin/dragonturn.c @@ -0,0 +1,14 @@ +#include +#include +int main(int argc,char *argv[]) { + int i,j; + char turns[1024]="R",append[1024],tmp[1024]; + for(i=0;i +#include +#define WIDTH 39 +#define HEIGHT 24 +char buff[WIDTH*HEIGHT*4]; +void draw_line(x1,y1,x2,y2) { + buff[(y1*WIDTH*2)+x1]='+'; + buff[(((y1+y2)/2) * WIDTH *2)+((x1+x2)/2)]= + (x1==x2)?'|':(y1==y2)?'-':((x1y2)||(x1>x2&&y1 +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); + } +} -- cgit v1.2.3