for(_='+3~+=`),_,c.^)^Z511YH/YX6*FV,H=U15T 20T"ReightQ,CNN-L/2K0,GerE^mo(ANDglobalB()@in$Math.#,#PIK*3--;)Zarc(A,q=17G,1if(%)"else _A`,2,0,02for(tion1023c.fic(A,N,#s$(q++)~*,2*FC+V~*llStyle="hsl("+q+", 55%,2Zli(Ac[&H]_C+,5^BAlpha=_+48*N1*#s$(XDi $ c)c[i[0]+i[1]+[i[6]]]=c[i];(u=func@{requestAnimaFrame(u_a.width=x=,a.hQ=h=x*$nEHQ/$nEWidth|1UpEformance.now@/T|1^textAlign="centE"^font="2em cursive" 20%,55,c(GG,h_w=555;xs=x%3?1&H++||-1:G=x&&||8+#random@*hKN=48-3*3))+s*+hK,A=-x+(Y-x)*C/h1s)q`31&C,00,H%Y){1&C&&(0_!(H%(9~/3)|1)))F=T&C,F`6L=V.3;Fc.bea(N-+_@}x(["Cross browsE","1kb demos","FebruaryR,"JS1kR][X&3],AN);1,5)5)N`25_x==w)A-=102G-10_Y>x)NG-TT2,-T_00.3,q=H,F=9;FC-VF,F);w-=T;c.BCompositeOpEa="dest$a-$"U31K+10)~1U3>H?9:H*H^tra(Y,hKZro(X+.1Zsc(H,H_A=C=-3^bea@-2N~N`4L1L3,03-2L5DL63-1L2K,0Zst@})@';g=/[^ -"%-?ACFH-JMOPSW[\]a-}]/.exec(_);)with(_.split(g))_=join(shift());eval(_)
// Compresses down to 1019 bytes with Uglify RegPack
// See https://gist.github.com/p01/c66d209fdb74514a2f00 for the depository
// and http://www.p01.org/releases/JS1K_2015_invit/ for a post-mortem and development notes
(u=function(){
requestAnimationFrame(u);
a.width=x=1023;
a.height=h=x*innerHeight/innerWidth|1;
H=performance.now()/15|1;
c.textAlign='center';
c.font='2em cursive';
q=170;
c.fillStyle='hsl(' q ',20%,55%)';
c.fillRect(0,0,1023,h);
w=555;
for(;x--;){
s=x%3?H &1||-1:0;
// exisiting || new portion of tracks distance of the "particle"
c[H&1023]=x&&c[H&1023]||8 Math.random()*h/2;
// Y coordinate & parallax
Y=Math.sin(H/511-Math.sin(H/511*3)*3)*48 s*c[H&1023] h/2;
X=1023-x (511-x)*Y/h;
c.globalAlpha=1;
q=170;
// "particles"
if (s) {
// Adjust the color based on the Y coordinate
q =Y&31;
c.fillStyle='hsl(' q ',55%,200%)';
if (H%511) {
// GRASS "particle"
// Adjust the color based on the Y coordinate, again
if (Y&1)
c.fillStyle='hsl(' q ',55%,20%)';
// vertical strands of grass
c.fillRect(X Math.sin(q )*3,Y Math.sin(q ),1,5);
c.fillRect(X Math.sin(q )*3,Y Math.sin(q ),1,5);
c.fillRect(X Math.sin(q )*3,Y Math.sin(q ),1,5);
// little bits of grass
c.fillRect(X Math.sin(q )*48,Y Math.sin(q )*3,1,1);
c.fillRect(X Math.sin(q )*48,Y Math.sin(q )*3,1,1);
c.fillRect(X Math.sin(q )*48,Y Math.sin(q )*3,1,1);
// TREE "particle"
// wih varying intensity of the forest
if (!(H%(9 Math.sin(H/511/3)*3|1))) {
// Get the height of the tree
z=Y&15;
z =6;
Y-=z*6;
c.globalAlpha=.3;
// Draw multiple triangles to make up a pine tree
for (;z--;) {
c.beginPath();
c.lineTo(X,Y);
c.lineTo(X-2*z Math.sin(q )*3,Y 6*z Math.sin(q )*3);
c.lineTo(X 2*z Math.sin(q )*3,Y 6*z Math.sin(q )*3);
c.fill();
}
}
} else {
// TEXT "particle"
c.fillText(['Cross browser','1kb demos','February 2015','JS1k 2015'][H/511&3],X,Y);
}
} else {
// tracks
c.fillStyle='hsl(' q ',55%,2%)';
c.fillRect(X,Y,1,5);
c.fillRect(X,Y,5,1);Y =2;
c.fillRect(X,Y,5,1);
// TRAIN
if(x==w){
// wagons
X-=10;
c.fillRect(X,Y,20,-10);
// locomotive
if(x<511){
c.fillRect(X,Y,10,-15);X =15;
c.fillRect(X,Y,2,-15);
// steam
c.fillStyle='hsl(' q ',55%,200%)';
c.globalAlpha=.3;
q=H;
z=9;
for(;z--;){
c.fillRect(X Math.sin(q )*3,Y-6*z Math.sin(q )*3,z,z);
}
} else {
w-=15;
}
}
}
}
// Cut out JS1k typography
c.globalCompositeOperation='destination-in';
H=Math.sin(H/511/2 10)*31 31;
H=H<3?9:H*H;
c.translate(511,h/2);
c.rotate(H/511 .1);
c.scale(H,H);
X=Y=-3;
c.beginPath();
// J
c.moveTo(X,Y);
c.arc(X-2,Y 3,2,0,Math.PI/2,0);
// S
X =2;
Y =4;
c.moveTo(X,Y);
c.arc(X,Y-1,1,Math.PI/2,Math.PI/2*3,1);
c.arc(X,Y-3,1,Math.PI/2,Math.PI/2*3,0);
// 1
X =3;
c.moveTo(X,Y);
c.arc(X-2,Y-5,2,0,Math.PI/2,0);
// k
X =2;
c.moveTo(X,Y);
c.lineTo(X,Y-6);
X =3;
c.moveTo(X,Y);
c.arc(X-1,Y-2,1,Math.PI/2*3/2,Math.PI/2*3,0);
c.stroke();
})()