RiverTrail Mandelbrot Set Demo

FPS

The Mandelbrot Set Kernel in JavaScript using River Trail:

function computeSet(iv, scale) {
    var x = iv[1];
    var y = iv[0];
    var Cr = (x - 256) / scale + 0.407476;
    var Ci = (y - 256) / scale + 0.234204;
    var I = 0, R = 0, I2 = 0, R2 = 0;
    var n = 0;
    while ((R2+I2 < 2.0) && (n < 512)) {
       I = (R+R)*I+Ci;
       R = R2-I2+Cr;
       R2 = R*R;
       I2 = I*I;
       n++;
    } 
    return n;
}
Based on the Evgeny Demidov's WebCL example.