3 * gcc -lm aclox.c -o aclox; ./aclox
5 * CFLAGS='-lm' make aclox; ./aclox
15 #define HOUR_NUMBERS 1
16 #define HI_PRECISION 1
19 #define SMOOTH_MOTION 1
23 #define max(a,b) ((a)>=(b)?(a):(b))
24 #define min(a,b) ((a)<=(b)?(a):(b))
25 #define PI 3.141592654
26 #define deg2rad(a) (((a)/180)*PI)
27 //phi = angle, r = length
28 #define polar2x(phi, r) ((r) * cos(deg2rad(phi)))
29 #define polar2y(phi, r) ((r) * sin(deg2rad(phi)))
30 #define cls() printf("\033[2J")
31 #define top() printf("\033[0;0H")
33 int llines
= -1, lcols
= -1;
34 void render_clock(double a
) {
36 char color_empty
= ' ';
38 char color_center
= 'o';
40 //get size of terminal
41 static int lines
= -1;
43 if(lines
< 7 || cols
< 7) {
45 p
= popen("stty size", "r");
46 fscanf(p
, "%d %d", &lines
, &cols
);
52 size
= min(lines
,cols
/zoom
);
53 size
= ((size
%2)==0?size
-1:size
); //make size odd
54 //printf("%d\n", size);
57 char cifernik
[size
*zoom
][size
];
60 for(y
=0;y
<size
;y
++) for(x
=0;x
<(size
*zoom
);x
++) cifernik
[x
][y
] = color_empty
;
63 //phi = -90+(s*(360/60));
65 for(i
=0;i
<360;i
+=28) {
67 for(r
=0;r
<(size
/2);r
+=inc
) {
68 x
= round((size
/2+polar2x(a
+i
,r
))*zoom
);
69 y
= round(size
/2+polar2y(a
+i
,r
));
70 cifernik
[x
][y
] = color_s
;
77 cifernik
[(size
/2)*zoom
][size
/2] = color_center
;
79 //cls when terminal size changes
80 if(lines
!= llines
|| cols
!= lcols
) {
89 for(r
=0;r
<=((cols
-(size
*zoom
))/2);r
++) putchar(' ');
90 for(x
=0;x
<((size
*zoom
)-(zoom
-1));x
++) {
91 putchar(cifernik
[x
][y
]);
93 if(y
!=(size
-1)) putchar('\n');
101 render_clock(a
=(a
+5)%360);
This page took 0.392393 seconds and 4 git commands to generate.