An animated Julia set in rainbow colors. Use the scroll wheel to change the speed. Refresh for a new experience!
M=Math,I=28,u=255;class D{constructor(d,e){this.r=d,this.i=e}a(d){return new D(this.r+d.r,this.i+d.i)}m(d){var e=this;return new D(e.r*d.r-e.i*d.i,e.r*d.i+d.i*e.r)}f(){var d=this;return M.sqrt(d.r*d.r+d.i*d.i)}}a.width=w=520,a.height=h=w*(innerHeight/innerWidth),cd=c.getImageData(0,0,w,h),E=0,l=.03,H=1,W=.5-M.random(),L=.5-M.random(),setInterval(()=>{E+=l,n=new D(1.2*M.cos(E)-.6+W,.6*M.sin(E)+L),(()=>{for(x=0;x<w;++x)for(o=0;o<h;++o){for(var d=(x-3*(w/6))/(w/6),e=(o-1.5*(h/3))/(h/3),f=new D(d,e),g=0;2>=f.f()&&g<I;)f=f.m(f).a(n),++g;if(g==I)var i=I;else var i=g+1-M.log2(M.log(f.f()));c2=Y(i/10,1,i<I?.65:0),ix=4*(x+o*w),ct=cd.data,ct[ix]=c2[0],ct[ix+1]=c2[1],ct[ix+2]=c2[2],ct[ix+3]=u}c.putImageData(cd,0,0)})()}),b.addEventListener("wheel",d=>{wh=d.wheelDelta,l-=0>(wh?wh:-d.deltaY)?.005:-.005}),Y=(d,e,f)=>{d%=1;var g=(d,e,f)=>(a=e-d,f%=1,f<1/6?d+6*a*f:.5>f?e:f<2/3?d+6*(a*(2/3-f)):d);return q=.5>f?f*(1+e):f+e-f*e,p=2*f-q,[~~(g(p,q,d+1/3)*u),~~(g(p,q,d)*u),~~(g(p,q,d-1/3)*u)]};
TT1NYXRoLEk9MjgsdT0yNTU7Y2xhc3MgRHtjb25zdHJ1Y3RvcihkLGUpe3RoaXMucj1kLHRoaXMuaT1lfWEoZCl7cmV0dXJuIG5ldyBEKHRoaXMucitkLnIsdGhpcy5pK2QuaSl9bShkKXt2YXIgZT10aGlzO3JldHVybiBuZXcgRChlLnIqZC5yLWUuaSpkLmksZS5yKmQuaStkLmkqZS5yKX1mKCl7dmFyIGQ9dGhp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XX07
M=Math;
I=28;
u=255;
class C
{
constructor(r,i)
{
this.r = r;
this.i = i;
}
a(n)
{
return new C(this.r + n.r, this.i + n.i);
}
m(n)
{
var t = this;
return new C((t.r * n.r) - (t.i * n.i), (t.r * n.i) + (n.i * t.r));
}
f()
{
var t = this;
return M.sqrt(t.r*t.r + t.i*t.i)
}
}
a.width = w = 520;
a.height = h = w*(innerHeight/innerWidth);
cd=c.getImageData(0,0,w,h);
N=0;
S=.03;
P = 1;
W=.5-M.random();
L=.5-M.random();
setInterval(()=>{
N+=S;
Z=new C(M.cos(N)*1.2-.6+W,M.sin(N)*.6+L);
(()=>{
for(x=0;x<w;++x)for(y=0;y<h;++y){
var X=(x-((w/6)*3))/(w/6);
var Y=(y-((h/3)*1.5))/(h/3);
var z=new C(X,Y);
var n=0;
while(z.f() <= 2 && n < I)
{
z = (z.m(z)).a(Z);
++n;
}
if(n==I)var j=I;
else var j=n + 1 - M.log2(M.log(z.f()));
c2=Q(((j / 10)),1,(j < I ? .65 : 0));
ix = (x+y*w)*4;
ct = cd.data;
ct[ix] = c2[0];
ct[ix+1] = c2[1];
ct[ix+2] = c2[2];
ct[ix+3] = u;}
c.putImageData(cd,0,0);
})();
});
b.addEventListener('wheel',e=>{
wh = e.wheelDelta;
S -= (wh ? wh : -e.deltaY)<0 ? .005 : -.005;
});
Q=(h, s, l)=>{
h=h%1;
var Q2 = (p, q, t)=>{
a=(q - p), t=t%1;
return t<1/6 ? p+a*6*t : (t<.5 ? q : (t<2/3 ? p+a*(2/3-t)*6 : p));
};
q = l < 0.5 ? l * (1 + s) : l + s - l * s,p = 2 * l - q;
return [~~(Q2(p, q, h + 1/3) * u), ~~(Q2(p, q, h) * u), ~~(Q2(p, q, h - 1/3) * u)];
};