So I read up this article: http://www.wikihow.com/Plot-the-Mandelbrot-Set-By-Hand But I'm stuck at step 7. I'm drawing the set in javascript canvas.
All I need is basicly the C value I guess.
for (var y = 0; y < ImageHeight; y++) {
for (var x = 0; x < ImageWidth; x++) {
// Pixel-Position for ImageObject
var xy = (x + y * image.width) * 4;
// Convert Image-Dimension to a radius of 2
var xi = ((x / ImageWidth) * 4) - 2;
var yi = ((y / ImageHeight) * 4) - 2;
for (var n = 0; n < MaxIterations; n++) {
// Complex number stuff..?
z = (xi*xi) + (yi*yi) + c;
c = 0; // Somethig with z ..?
if (z < 4) {
image.data[xy] = inner_color[0];
image.data[xy+1] = inner_color[1];
image.data[xy+2] = inner_color[2];
image.data[xy+3] = Math.round(n * cdiff);
} else {
image.data[xy] = outer_color[0];
image.data[xy+1] = outer_color[1];
image.data[xy+2] = outer_color[2];
image.data[xy+3] = Math.round(n * cdiff);
break;
}
}
}
}
I also read up a lot about imaginary numbers and stuff, but I didn't quite understood how to calculate with them. And they seem somehow useless to me because you'd have to convert them back to real numbers anyways to do logic operations in javascript for example.
Here is what it looks like: [removed]
If you remove the 2 at the end of the url, you see another version where I just rewrote a little c++ snippit.
But zooming is somehow weird, which is why I want to write it all on my own..
I understood the basic concept of the mandelbrot set creation but as I said the complex part is troubling me. Is there maybe an even simpler explanation out there ?