home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Action 56
/
cdaction-56.iso
/
Bonus
/
C.exe
/
cz9
/
naCD
/
Julia2
/
Julia2.cpp
next >
Wrap
C/C++ Source or Header
|
2000-11-12
|
1KB
|
62 lines
# include <complex.h>
# include <conio.h>
# include <stdio.h>
# include <pc.h>
# include <allegro.h>
# include <time.h>
clock_t s,e;
BITMAP* bufor;
int cx=0, cy=0;
void RysujJulie()
{
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);
}
blit(bufor, screen, 0, 0, 0, 0, 640, 480);
}
int main()
{
int err;
allegro_init();
set_color_depth(16);
if ((err=set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0))<0)
{
printf("Error: %s\n",allegro_error);
return(1);
}
bufor = create_bitmap(640, 480);
s = clock();
RysujJulie();
e = clock();
getch();
destroy_bitmap(bufor);
textmode(3);
printf("Czas rysowania: %2.2f sec.\n", (double)(e-s)/CLOCKS_PER_SEC);
getch();
}