I'm writing a Mandelbrot app in C# (and I'm testing with Python). I already have the continous coloring from the set to its borders. My current problem is to set the background color of the environment. My current code for getting the color now looks like this, it gets the color as double (the logarithm function is done before) and checks wether it's part or not and creates a quite smooth gradient (from black to orange).
private Color getColor(double i)
{
double ratio = i / (double)(iterations);
int col = (int)(i / iterations * 255);
int alpha = 255;
if (ratio >= 0 && ratio < 0.25)
return Color.FromArgb(alpha, col, col/5, 0);
if (ratio >= 0.25 && ratio < 0.50)
return Color.FromArgb(alpha, col, col/4, 0);
if (ratio >= 0.50 && ratio < 0.75)
return Color.FromArgb(alpha, col, col/3, 0);
if (ratio >= 0.75 && ratio < 1)
return Color.FromArgb(alpha, col, col/2, 0);
return Color.Black; //color of the set itself
}
How can I change the black environement (not the Mandelbrot set) to another color like the obfuscated Python script (http://preshing.com/20110926/high-resolution-mandelbrot-in-obfuscated-python) does? I already edited the script to a nicer form, but it doesn't fit my algorithm.
EDIT: Forgot to mention, I'm not using a class for the complex equotation, I compute the fractal with the algorithm that's shown on Wikipedia.