computeMandelbrotAt method

double computeMandelbrotAt(
  1. double cx,
  2. double cy
)

CPU-computed Mandelbrot iteration count for a single point. Used by NeomFractalFallbackPainter when shaders aren't available.

Implementation

double computeMandelbrotAt(double cx, double cy) {
  double zx = 0, zy = 0;
  final maxIter = _config.platformIterations;
  double i = 0;
  while (i < maxIter && zx * zx + zy * zy <= 4.0) {
    final tmp = zx * zx - zy * zy + cx;
    zy = 2.0 * zx * zy + cy;
    zx = tmp;
    i++;
  }
  if (i >= maxIter) return -1;
  // Smooth iteration count
  return i - log(log(sqrt(zx * zx + zy * zy))) / log(2);
}