I am trying to understand superficially the syntax in this pretty piece of coding posted here:
t=0,draw=e=>{for(t++||createCanvas(w=400,w,WEBGL),background(w),fill(x=0),rotateX(d=t/120),rotateY(d),rotateZ(d);x<1331;)push(r=r=>(r-5)*(10+w*(o=1-sin(t%120/240*PI)))),translate(r(a=x%11),r(b=x%121/11|0),r(c=x++/121|0)),pop(box(10+o*(666==x?90:-10)))};//
I think that because of Twitter's constraints in number of characters it was posted as one single line, and using some shortcuts for loops. The part I am asking about may be a loop. I tried unfolding the code into something more readable as follows:
t=0,draw=e=>{for(t++||
createCanvas(w = windowWidth,w,WEBGL), background(w), fill(x=0),
rotateX(d=t/120),
rotateY(d),
rotateZ(d);
x<1331;)
push(r=r=>(r-5) * (10 + w * (z = 1 - sin(t%120/240*PI)))),
translate(r(a=x%11),
r(b=x%121/11|0),
r(c=x++/121|0)),
pop(box(10+z*(666==x?90:-10)))};//
What is r=r=>(r-5)
purpose? I have looked up push()
and pop()
, and I have a vague idea, but that expression is confusing.