aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/lineplot.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/lineplot.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/lineplot.c')
-rw-r--r--src/bin/lineplot.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/bin/lineplot.c b/src/bin/lineplot.c
new file mode 100644
index 0000000..781a85a
--- /dev/null
+++ b/src/bin/lineplot.c
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <string.h>
+#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)?'-':((x1<x2&&y1>y2)||(x1>x2&&y1<y2))?'/':'\\';
+ buff[(y2*WIDTH*2)+x2]='+';
+}
+int main(int argc,char *argv[]) {
+ int x1,y1,x2,y2,y;
+ memset(buff,' ',WIDTH*HEIGHT*4);
+ while(scanf("%d %d %d %d",&x1,&y1,&x2,&y2) == 4)
+ draw_line((x1+8)*2,(y1+8)*2,(x2+8)*2,(y2+8)*2);
+ for(y=0;y<HEIGHT*2;y++,write(1,"\n",1)) write(1,buff+(y*WIDTH*2),WIDTH*2);
+}