Mandelbrot

Previous Next
Processing Sketches

Your browser does not support the canvas tag.

void setup() {
  size(1000, 1000);
  background(255);
}
int x = 900;

void draw() {
  translate(-700, 0);
  float r = 0.0;
  float i = 0.0;
    for(int k = 0; k < 25 && x < 1900; k++){
      r = 0.0003 * x;
      for(int y = -50; y < 950; y++){
        i = 0.0003 * y;
        stroke(150); // in the set
        float real = r;
        float complex = i;
        for (int t = 0; t < 500; t++){
          float tr = real * real - (complex * complex);
          float ti = 2 * real * complex;
          if (tr > 500 || tr < -500 || ti > 500 || ti < -500){
            stroke(abs(t)%255, 50, abs(255-t)%220);
            break;
          }
          real = tr;
          complex = ti;
          real = real + r;
          complex = complex + i
        }
        point(x, y);
      }
	  x++;
    }
  if (x > 1898){	
    exit();
  }
}