SHOW:
|
|
- or go back to the newest paste.
1 | #define Windows | |
2 | ||
3 | #include <stdio.h> | |
4 | #include <string.h> | |
5 | #ifdef Windows | |
6 | - | void Ansi_ClearScreen() { system("cls"); } |
6 | + | |
7 | - | void Ansi_MoveHome() { COORD tHome = { .X=1 , .Y=1 }; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), tHome ); } |
7 | + | HANDLE hCon; |
8 | void Ansi_ClearScreen() { | |
9 | hCon=GetStdHandle(STD_OUTPUT_HANDLE); system("cls"); | |
10 | CONSOLE_CURSOR_INFO tCur = {.dwSize=8 , .bVisible = FALSE }; | |
11 | SetConsoleCursorInfo( hCon , &tCur ); | |
12 | } | |
13 | - | int k;double sin() |
13 | + | void Ansi_MoveHome() { COORD tHome = { .X=1 , .Y=1 }; SetConsoleCursorPosition(hCon,tHome); } |
14 | - | ,cos();int main(){ float |
14 | + | |
15 | - | A=0,B=0,i,j,z[1760];char b[ |
15 | + | |
16 | - | 1760];Ansi_ClearScreen();for(;; |
16 | + | |
17 | - | ){memset(b,32,1760);memset(z,0,7040) |
17 | + | |
18 | - | ;for(j=0;6.28>j;j+=0.07)for(i=0;6.28 |
18 | + | |
19 | - | >i;i+=0.02){float c=sin(i),d=cos(j),e= |
19 | + | int k; |
20 | - | sin(A),f=sin(j),g=cos(A),h=d+2,D=1/(c* |
20 | + | double sin(),cos(); |
21 | - | h*e+f*g+5),l=cos (i),m=cos(B),n=s\ |
21 | + | int main(){ |
22 | - | in(B),t=c*h*g-f* e;int x=40+30*D* |
22 | + | float A=0,B=0,i,j,z[1760]; |
23 | - | (l*h*m-t*n),y= 12+15*D*(l*h*n |
23 | + | char buffer[1761]; buffer[1760]=0; |
24 | - | +t*m),o=x+80*y, N=8*((f*e-c*d*g |
24 | + | |
25 | - | )*m-c*d*e-f*g-l *d*n);if(22>y&& |
25 | + | Ansi_ClearScreen(); |
26 | - | y>0&&x>0&&80>x&&D>z[o]){z[o]=D;;;b[o]= |
26 | + | |
27 | - | ".,-~:;=!*#$@"[N>0?N:0];}}/*#****!!-*/ |
27 | + | for(;;) { |
28 | - | Ansi_MoveHome();for(k=0;1761>k;k++){ |
28 | + | |
29 | - | putchar(k%80?b[k]:10);};A+=.04;B+= |
29 | + | memset(buffer,32,1760); |
30 | - | 0.02;}}/*****####*******!!=;:~ |
30 | + | memset(z,0,1760*sizeof(float)); |
31 | - | ~::==!!!**********!!!==::- |
31 | + | |
32 | - | .,~~;;;========;;;:~-. |
32 | + | for( j=0 ; j<6.28 ; j+=0.07 ) { |
33 | - | ..,--------,*/ |
33 | + | for( i=0 ; i<6.28 ; i+=0.02 ) { |
34 | ||
35 | //calc pixel | |
36 | float c=sin(i) , d=cos(j) , e=sin(A) , f=sin(j) , g=cos(A); | |
37 | float h=d+2 , D=1/(c*h*e+f*g+5) , l=cos(i); | |
38 | float m=cos(B) , n=sin(B) , t=c*h*g-f*e; | |
39 | int x=40+30*D*(l*h*m-t*n) , y=12+15*D*(l*h*n+t*m); | |
40 | int o=x+80*y , N=8*((f*e-c*d*g)*m-c*d*e-f*g-l*d*n); | |
41 | ||
42 | //plot pixel and Z order | |
43 | if ( ((unsigned)y)<22 && ((unsigned)x)<80 && D>z[o] ) { | |
44 | z[o] = D ; buffer[o] = ".,-~:;=!*#$@"[ N>0 ? N : 0 ]; | |
45 | } | |
46 | ||
47 | } | |
48 | } | |
49 | ||
50 | //rotate donut | |
51 | A+=.04 ; B+= 0.02; | |
52 | ||
53 | //display buffer | |
54 | Ansi_MoveHome(); | |
55 | for( k=0; k<1761 ; k+= 80 ) { buffer[k] = 10; } | |
56 | puts(buffer); | |
57 | ||
58 | } | |
59 | } |