home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
mandelc.zip
/
mandel.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-01
|
1KB
|
61 lines
#include <mem.h>
#include "dllFractal.h"
const char * _export getName(void)
{ return "simple Mandelbrot";
}
void _export calculateFractal(
unsigned int iSizeX,
unsigned int iMaxColors,
unsigned int iMaxIterations,
unsigned char *pData,
double dLimit,
double dxdx,
double dydx,
double dx,
double dy)
{ unsigned int ixi;
// You don't need to write the following stuff in assembler!
// Use a good compiler like EMX for OS/2!
for (ixi = 0,
memset(pData, 0, iSizeX*sizeof*pData),
iMaxColors -= 1;
ixi < iSizeX;
ixi++,
dy += dydx, dx += dxdx
)
{ double y2 = dy*dy;
double x_1_2 = dx + 1.0;
x_1_2 *= x_1_2;
if (y2 + x_1_2 > 1.0/16.0)
{ double r = dx*dx + y2;
double s = r - dx*0.5 + 1.0/16.0;
if ((r*16 - 5.0)*s + 4*dx > 1)
{ double xit = dx, yit = dy;
unsigned int it;
for (it = 0;
it < iMaxIterations;
it++)
{ double x2 = xit*xit;
double y2 = yit*yit;
double r = y2 + x2;
if (r > dLimit)
{ pData[ixi] = it
% iMaxColors + 1;
break;
}
r = 2*xit*yit + dy;
xit = x2 - y2 + dx;
yit = r;
}
}
}
}
}