Interactive particle system with three setups. Click to repel, press a key to see something new
U=W=c.width=700;H=c.height=600;M=Math;c.style.background="#000";R=10032148;S=13;D=0;V=255;P=[];E=[[250,200],[450,200]];F=[[150,350],[550,350],[350,500,600]];onkeypress=function(){P=[];(D=!D)?(S=13,R=1153433,E=[[350,300]],F=[[250,300,100],[450,300,100]]):(S=1,R=3381555,E=[[200,250]],F=[[300,300,140]])};onmousedown=function(){F.push(U=[0,0,-120])};onmouseup=function(){U&&F.splice(F.indexOf(U),1)};onmousemove=function(d){U&&(U[0]=d.offsetX||d.layerX,U[1]=d.offsetY||d.layerY)};g();
function g(){T=[];c.width=W;I=a.getImageData(0,0,W,H);X=I.data;for(i=0;e=E[i++];)for(j=15;j--;)A=M.random()*S,P.push([[e[0],e[1]],[M.cos(A),M.sin(A)]]);for(;p=P.pop();){i=F.length;for(q=p[0];f=F[--i];)x=f[0]-q[0],y=f[1]-q[1],s=f[2]||-30,A=s/M.pow(x*x+s/2+y*y+s/2,1.5),p[1][0]+=x*A,p[1][1]+=y*A;q[0]+=p[1][0];q[1]+=p[1][1];0<q[0]&&q[0]<W&&0<q[1]&&q[1]<H&&(T.push(p),b=4*(~~q[1]*W+~~q[0]),X[b]+=R>>16&V,X[b+1]+=R>>8&V,X[b+2]+=R&V,X[b+3]=V)}a.putImageData(I,0,0);P=T;setTimeout(g,15)};
VT1XPWMud2lkdGg9NzAwO0g9Yy5oZWlnaHQ9NjAwO009TWF0aDtjLnN0eWxlLmJhY2tncm91bmQ9IiMwMDAiO1I9MTAwMzIxNDg7Uz0xMztEPTA7Vj0yNTU7UD1bXTtFPVtbMjUwLDIwMF0sWzQ1MCwyMDBdXTtGPVtbMTUwLDM1MF0sWzU1MCwzNTBdLFszNTAsNTAwLDYwMF1dO29ua2V5cHJlc3M9ZnVuY3Rpb24oKXtQPVtdOyhEPSFEKT8oUz0xMyxSPTExNTM0MzMsRT1bWzM1MCwzMDBdXSxGPVtbMjUwLDMwMCwxMDBdLFs0NTAsMzAwLDEwMF1dKTooUz0xLFI9MzM4MTU1NSxFPVtbMjAwLDI1MF1dLEY9W1szMDAsMzAwLDE0MF1dKX07b25tb3VzZWRvd249ZnVuY3Rpb24oKXtGLnB1c2goVT1bMCwwLC0xMjBdKX07b25tb3VzZXVwPWZ1bmN0aW9uKCl7VSYmRi5zcGxpY2UoRi5pbmRleE9mKFUpLDEpfTtvbm1vdXNlbW92ZT1mdW5jdGlvbihkKXtVJiYoVVswXT1kLm9mZnNldFh8fGQubGF5ZXJYLFVbMV09ZC5vZmZzZXRZfHxkLmxheWVyWSl9O2coKTsNCmZ1bmN0aW9uIGcoKXtUPVtdO2Mud2lkdGg9VztJPWEuZ2V0SW1hZ2VEYXRhKDAsMCxXLEgpO1g9SS5kYXRhO2ZvcihpPTA7ZT1FW2krK107KWZvcihqPTE1O2otLTspQT1NLnJhbmRvbSgpKlMsUC5wdXNoKFtbZVswXSxlWzFdXSxbTS5jb3MoQSksTS5zaW4oQSldXSk7Zm9yKDtwPVAucG9wKCk7KXtpPUYubGVuZ3RoO2ZvcihxPXBbMF07Zj1GWy0taV07KXg9ZlswXS1xWzBdLHk9ZlsxXS1xWzFdLHM9ZlsyXXx8LTMwLEE9cy9NLnBvdyh4Kngrcy8yK3kqeStzLzIsMS41KSxwWzFdWzBdKz14KkEscFsxXVsxXSs9eSpBO3FbMF0rPXBbMV1bMF07cVsxXSs9cFsxXVsxXTswPHFbMF0mJnFbMF08VyYmMDxxWzFdJiZxWzFdPEgmJihULnB1c2gocCksYj00Kih+fnFbMV0qVyt+fnFbMF0pLFhbYl0rPVI+PjE2JlYsWFtiKzFdKz1SPj44JlYsWFtiKzJdKz1SJlYsWFtiKzNdPVYpfWEucHV0SW1hZ2VEYXRhKEksMCwwKTtQPVQ7c2V0VGltZW91dChnLDE1KX07
//https://github.com/jsoverson/JavaScript-Particle-System
//http://jarrodoverson.com/static/demos/particleSystem/
//Manually golfed, then closure compiled