You're setting the color inside the loop, which is different from any Mandelbrot code I have seen. It also sets the color for the same pixel many times, which is very inefficient. Another aspect of the logic problem is that you set isInside
, but then never use it.
The way this is typically done is that you set the color after the loop terminated. If isInside
is true, you set the color to black (or leave it untouched if the image was cleared to black). Otherwise you set the color. If you look at the origin of the code you use, they suggest to determine the color in the "outside" case based on the number of iterations, which would be n
in your case. The code you posted is using the value of Z_re/Z_im
to determine the color.
Edit: Ok, your formula uses both n
and Z_re/Z_im
. In any case, unless you know exactly what forumula were used for the reference image, and you use the same, you can't expect exactly the same coloring. If you fix what I pointed out above, you should at least get black for the inside.