home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD Action 56
/
cdaction-56.iso
/
Bonus
/
C.exe
/
cz9
/
naCD
/
Mandelbrot
/
Mand.cpp
next >
Wrap
C/C++ Source or Header
|
2000-11-13
|
960b
|
52 lines
# include <complex.h>
# include <stdio.h>
# include <pc.h>
# include <allegro.h>
BITMAP* bufor;
complex<double> c;
void RysujMand()
{
int i,j;
double px,py;
complex<double> x;
unsigned char iter;
clear(bufor);
for (j=0,py=-2.1;j<480;j++,py+=0.00875)
for (i=0,px=-2.5;i<640;i++,px+=0.00625)
{
iter=0;
c=complex<double>(px, py);
x=complex<double>(0, 0);
while ((abs(x)<4.0) && (iter<255))
{
iter++;
x=x*x+c;
}
((short int *)bufor->line[j])[i]=makecol16(iter,iter,255-iter);
blit(bufor, screen, i, j, i, j, 1, 1);
}
}
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);
RysujMand();
while (!kbhit());
destroy_bitmap(bufor);
}