我已经走到这样的:着色Mandelbrot集
float MinRe = -2.0f; // real
float MaxRe = 1.0f;
float MinIm = -1.0f; // imaginary
float MaxIm = MinIm + (MaxRe - MinRe) * WindowData.Height/WindowData.Width;
float Re_factor = (MaxRe - MinRe)/(WindowData.Width - 1);
float Im_factor = (MaxIm - MinIm)/(WindowData.Height - 1);
int MaxIterations = 50;
int iter=0;
for (int y = 0; y < WindowData.Height; ++y)
{
double c_im = MaxIm - y * Im_factor; // complex imaginary
for (int x = 0; x < WindowData.Width; ++x)
{
double c_re = MinRe + x * Re_factor; // complex real
// calculate mandelbrot set
double Z_re = c_re, Z_im = c_im; // Set Z = c
bool isInside = true;
for (iter=0; iter < MaxIterations; ++iter)
{
double Z_re2 = Z_re * Z_re, Z_im2 = Z_im * Z_im;
if (Z_re2 + Z_im2 > 4)
{
isInside = false;
break;
}
Z_im = 2 * Z_re * Z_im + c_im;
Z_re = Z_re2 - Z_im2 + c_re;
}
if(isInside)
{
GL.Color3(0, 0, 0);
GL.Vertex2(x, y);
}
}
}
我曾在几个方面尝试过,但大部分的时间用单一颜色的周围设置,或整个屏幕搭配同色系的结束。
如何正确设置颜色?
http://en.wikipedia.org/wiki/Mandelbrot_set#Computer_drawings – Mat
您可能会发现一些有用的建议[here](http://stackoverflow.com/questions/369438/smooth-spectrum-for-mandelbrot-set-rendering) –