Mandelbrot set fractal rendering with simple color cycling effect. Colorizes values contained in the actual set for a water droplet skin effect animation.
c=document.getElementById('c');x=c.width=500;y=c.height=500;function p(x,y,c){var i=(x+y*500)*4;d[i]=c[0];d[i+1]=c[1];d[i+2]=c[2];d[i+3]=c[3];}function C(r,i){this.r=r;this.i=i;}function Cm(a,b){return new C((a.r*b.r)-(a.i*b.i),(a.r*b.i)+(a.i*b.r))}function Cs(a,b){return new C(a.r+b.r,a.i+b.i);}function Ca(c){return Math.sqrt(c.r*c.r+c.i*c.i);}function cy(){for(var i=0;i<d.length;i+=4){d[i]=(d[i]+1)%256;d[i+1]=(d[i+1]-1)%256;}ctx.putImageData(imgd,0,0);setTimeout(function(){cy();},25);}ctx=c.getContext('2d');imgd=ctx.getImageData(0,0,x,y);d=imgd.data;for(var i=0;i<x;i++){for(var j=0;j<y;j++){var zn=new C(0,0);var c=new C((2/x)*i-1,(2/y)*j-1);for(var n=1;n<=25;n++){zn=Cs(Cm(zn,zn),c);if(Ca(zn)>8){break;}}if(Ca(zn)<2){p(i,j,[Math.abs(Ca(zn)*512),0,255,255]);}else{p(i,j,[Math.log(Ca(zn))/Math.log(10)*127,255,0,255]);}}}ctx.putImageData(imgd,0,0);cy();
Yz1kb2N1bWVudC5nZXRFbGVtZW50QnlJZCgnYycpO3g9Yy53aWR0aD01MDA7eT1jLmhlaWdodD01MDA7ZnVuY3Rpb24gcCh4LHksYyl7dmFyIGk9KHgreSo1MDApKjQ7ZFtpXT1jWzBdO2RbaSsxXT1jWzFdO2RbaSsyXT1jWzJdO2RbaSszXT1jWzNdO31mdW5jdGlvbiBDKHIsaSl7dGhpcy5yPXI7dGhpcy5pPWk7fWZ1bmN0aW9uIENtKGEsYil7cmV0dXJuIG5ldyBDKChhLnIqYi5yKS0oYS5pKmIuaSksKGEucipiLmkpKyhhLmkqYi5yKSl9ZnVuY3Rpb24gQ3MoYSxiKXtyZXR1cm4gbmV3IEMoYS5yK2IucixhLmkrYi5pKTt9ZnVuY3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