Epic Cycles

February 2018

A JS1K 2018 entry allowing to trace any shape using epicycloids, golfed with BalintCsala

Thanks to romancortes, eljj, antimatter15, brettcvz, paul bourke, and kuvos for their help, individual work and ideas!

Click to add a point, use keyboard arrows up and down to change the number of circles, arrow left to toggle intermediate paths and arrow right to clear the screen.

- Github

- Demo

- Commented source code

- making-of

<body id=b>
<canvas id=a style="position:absolute;top:0;left:0"></canvas>
<script>
d = document;
c = a.getContext("2d");
a.width = innerWidth;
a.height = innerHeight;
for(_='[i44]:f(?/2Ja.heightJL,e.y-LYa.widthje.x-jJqc[c.zzsS]=`~e=>Fdown=FE+P4+1]Oc.arc(N+=V0,UMath.hypot(for( in C,H);].length-p[p-1]](*sin*cos;i of&&P[k][0](i*T+i[2=[]Ponmouse	 G){zbac.stroke(50*(i.charCodeAt().push([Z[g][1]P[(I+J)%][(k*-2*PI*i/)ic)c4+4[6]]]=i;p;m=0`@DGCBCGDPHIRSKWTQTW[XZ]Z_Z[SRIHDD`)p>>2)-95U&3)-90	Em=1;	move=Fm?e	up=F(m=U?e)onkeyE[FD^=1,FQ++,F(p,G,?)),FQ--][e.which-37f=F{e(!p||qY)>9)pqYP=p.map(F[...eZb.bgColor=i=D=T=0;>2**(log2()|0iV2)P.splice(i+1,U[(P:O)J,(P:O)J_iP){_:=[U0]kP)_:V(-),_:V(+}P=_;i?)I=,G;I--;)GI+J-,0],1])/,atan2(1],0])G.sort((i,B)=>B-iQ=-1};?setInterval(F{TV.007;j^=C=H=g=0;ztajJ,L~#fff` p)zba),Ni,i,1,U7),)N,i,U7zmCViHVizlg<=Q=||[];<999g++}g=0zld]=5,~hsl(${(Q-g)*9},50%,50%`,zm,)K of )(g==min(Q,-1)||Dgg<=Qg%8<1)zlK,Kg++}},9)';G=/[-UVNOEF~zqjYLJ?:4]/.exec(_);)with(_.split(G))_=join(shift());eval(_)
</script>