|
|
1.1 root 1: /*
2: psych - draw pretty pictures on 4014
3:
4: compile as cc psych.c -lm -l4014
5: could use other plot-type library
6:
7: */
8: #include "stdio.h"
9:
10: char obuf[BUFSIZ];
11:
12: main() {
13: int c;
14: float g, fact, d, z, b;
15: float x, y, limit = 0.25;
16: int xx, yy;
17: double sin(), cos();
18: int i, first;
19: long time(), t;
20:
21: setbuf(stdout, obuf);
22: time(&t);
23: srand(t&0177777);
24: top:
25: g = ((float)rand()/32767.) * 10;
26: fact = ((float)rand()/32767.) * 20;
27: erase();
28: d = 0.1;
29: z = 0;
30: first = 0;
31: for (i = 1; i <= 500; i++) {
32: b = (z-110) / 1.57;
33: z += g;
34: g = (0-g) * fact;
35: fact = 1 / fact;
36: d *= 1.01;
37: x = d * cos(b);
38: y = d * sin(b);
39: if (x*x > limit || y*y > limit)
40: break;
41: xx = (x+0.5) * 3120 + 500;
42: yy = (y+0.5) * 3120;
43: if (first == 0)
44: move(xx, yy);
45: cont(xx, yy);
46: first = 1;
47: }
48: printf("\015"); /* out of plot mode */
49: fflush(stdout);
50: while ((c=getchar()) != '\n' && c!=EOF)
51: ;
52: if(c == '\n')
53: goto top;
54: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.