/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.jERD8UEiWJn/rev.29
*
* authors:
* GoToLoop
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
/**
* Mandelbrot Set, the (v3.22)
* by Daniel Shiffman
* mod Asimes & GoToLoop (2014/Aug)
*
* forum.processing.org/two/discussion/6841/zoom
* processing.org/examples/mandelbrot.html
*
* studio.processingtogether.com/sp/pad/export/ro.96P5CDnO6mAXt/latest
*/
// Increase this when you zoom in more:
final int MAX_ITERS = 300;
// Manipulate these to zoom in/out:
final float XMIN = -.65, YMIN = -.715, DIM = .2;
final float XMAX = XMIN + DIM, YMAX = YMIN + DIM;
size(800, 800, JAVA2D);
noLoop();
loadPixels();
final int w = width, h = height, dots[] = pixels;
final float dx = (XMAX - XMIN)/w, dy = (YMAX - YMIN)/h;
float x = XMIN, y = YMIN, a = x, b = y, aa, bb;
for (int i = 0; i != w; ++i, x += dx, b = y = YMIN)
for (int j = 0, n = 0; j != h; a = x, b = y += dy, n = 0) {
while (++n != MAX_ITERS & (aa = a*a) + (bb = b*b) < 16.0) {
b = 2.0*a*b + y;
a = aa - bb + x;
}
dots[j++*w + i] = MAX_ITERS==n? #000000 : color(n<<4 & 0xFF);
}
if (1/2 == 1/2.) pixels = dots;
updatePixels();