Skip to main content

mandelbrot.ts

400">function 200">calculateGradient(x: 400">number, y: 400">number, iterations: 400">number) {
  400">let zx = 0;
  400">let zy = 0;
  
  400">for (400">let i = 0; i < iterations; i++) {
    400">const tempX = zx * zx - zy * zy + x;
    zy = 2 * zx * zy + y;
    zx = tempX;
    
    400">if (zx * zx + zy * zy > 4) {
      400">return i; 500 italic">// Escaped
    }
  }
  
  400">return iterations; 500 italic">// Bounded
}

TypeScript

UTF-8

Ln 15, Col 2