home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Action 56
/
cdaction-56.iso
/
Bonus
/
C.exe
/
cz9
/
naCD
/
Julia3
/
JuliaAnim.c
next >
Wrap
C/C++ Source or Header
|
2000-11-12
|
989b
|
56 lines
# include <stdio.h>
# include <math.h>
# include <allegro.h>
void julia(int cx, int cy, BITMAP* bufor)
{
int i,j,px,py;
int xn,yn,x2,y2,x,y;
unsigned char c;
for (i=-1920,px=0;i<1920;i+=6,px++)
for (j=-1920,py=0;j<1920;j+=8,py++)
{
c=0;
x=i;y=j;
x2=x*x;
y2=y*y;
while (((x2+y2)<4000000) && (c<31))
{
c++;
y=((x*y)>>9)+cy;
x=((x2-y2)>>10)+cx;
x2=x*x;
y2=y*y;
}
((short int *)bufor->line[py])[px]=makecol16(8*c,8*c,255-c);
}
}
BITMAP* bufor;
int main()
{
float kat1=0,kat2=1;
int cx,cy;
allegro_init();
set_color_depth(16);
set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0);
bufor=create_bitmap(640, 480);
clear(bufor);
while (!kbhit())
{
kat1+=0.01;
kat2+=0.015;
cx=900*sin(kat1);
cy=900*cos(kat2);
julia(cx, cy, bufor);
blit(bufor, screen, 0, 0, 0, 0, 640, 480);
}
return 0;
}