for(_='c.|Style={,|z)z``fill{__"#^re(Zta(YColorX,vWba(V"rgVU)W.addXStop(T"T1,UQscale(P5zPvWO`qt(-N*v)LL+13)K*g)*vJ`l(I;v--;)HH|VGG`m(F0,EE48ED1+g%B255,A30@fill(E7_vz``P1.stroke50,-10^fff"+"%)"%,"+("hsl(save(Math.sin()*(arc(for(,1N801a.height/a.width g+v))W=)"`V`DI-400);||-99238.8,cos(-70+35+`v in c)c[v[0]+[v[6]]]=c[v];g=B1e3, -=b.bgX=E|Y /2,2max( /E@0`PvWg<213&&log(g/2+5)`Y3J,2JW=@0G`2*@L*31L,5L/3+.5,E7`);v=|cR(DED515TE"#37aQAAA060E^452"zV6;v-=1/32;)|l(v3L+517K*2+8Ev4L+418K+60|cR(E5,40E5,5TEUEEE0)QEEE.9515,`Y1@,@zB2/O`V70Ht=v*(91+g/0)/200I1/t)/t)`Z`V`m(E02926IE053`_@E*g/)+80)z),t=B@/E|Pt,t12F-05120254.803.3Z0/g-.O400F-70+@*v/152)W/16-@I-56Ev/2-246`{200>v?0590-.3L:195,25180-.375Lz(^111"W=5G)W?11.2):2.8,4.6`-9722.69.2.9,.956.6Z_U25536,34,.1)"W=Fqt(80+,N+9*12+3*,)';g=/[^ -?CMRS[\]a-y]/.exec(_);)with(_.split(g))_=join(shift());setInterval(_,40)
// See https://github.com/subzey/js1k2015 for details
var VIEWPORT_WIDTH = 500;
var VIEWPORT_HEIGHT = 300;
var DEBUG = false;
if (typeof __RegPack === 'undefined'){
g = null;
}
var v01, v02, v03;
setInterval(function(){
g=1+g%1000;
var __inline_bgcolorReset = b.bgColor=0;
a.width -= __inline_bgcolorReset; // Reset canvas
c.translate(a.width/2, a.height/2); // Center the context origin
v01 = Math.max(a.width / VIEWPORT_WIDTH, a.height / VIEWPORT_HEIGHT);
c.scale(v01, v01); // Make logical viewport cover physical one
// Camera shake
v01 = (g < 213) && Math.cos(Math.log(g/2+5));
c.translate(Math.cos(g*3) * v01, Math.sin(g*2) * v01);
if (DEBUG){
c.scale(0.9, 0.9);
c.save();
}
// Stars
c.fillStyle = '#fff';
for (v01=300; v01--; ){
c.beginPath();
c.arc(Math.cos(v01*30) * 250, Math.sin(v01*31) * 150, Math.sin(v01*5)/3 + 0.5, 0, 7);
c.fill();
}
// return;
// Planet
// Fill & atmosphere glow
v01 = c.createRadialGradient(0, 480, 500, 0, 480, 515);
v01.addColorStop(0, '#37a');
v01.addColorStop(1, 'rgba(255,255,255,0)');
c.beginPath();
c.arc(0, 480, 600, 0, 7);
c.fillStyle=v01;
c.fill();
c.fillStyle='#452';
// Continent
c.beginPath();
for (v01=6; v01-=1/32; ){
c.lineTo(
Math.cos(v01) * (Math.sin(v01 * 3) + 5) * (Math.sin(v01 * 17) + 13) * 2 + 80,
Math.sin(v01) * (Math.sin(v01 * 4) + 4) * (Math.sin(v01 * 18) + 13) + 60
);
}
c.fill();
// Shadow
v01 = c.createRadialGradient(100, 550, 450, 100, 550, 550);
v01.addColorStop(0, 'rgba(0,0,0,0)');
v01.addColorStop(1, 'rgba(0,0,0,.9)');
c.beginPath();
c.arc(0, 480, 515, 0, 7);
c.fillStyle = v01;
c.fill();
// Blinking landing point
c.translate(130, 30);
c.fillStyle = '#fff';
c.save();
v01 = 1 + g %2 / 5;
c.scale(v01, v01);
c.beginPath();
for (v01=70; v01--; ){
v02 = v01 * (91 + Math.sin(g/100) / 200);
c.lineTo(1/Math.sin(v02), 1/Math.cos(v02));
}
c.fill();
c.restore();
// LAZOR RAILS!
c.beginPath();
c.moveTo(0,0);
c.lineTo(-400, -29);
c.lineTo(-400, -26);
c.lineTo(0,0);
c.lineTo(-400, -53);
c.lineTo(-400, -50);
c.fill();
c.fillStyle = 'hsl(300,50%,'+(Math.cos(g/10) * 10 + 80)+'%)';
c.save();
v02 = 1+g%30/100;
c.scale(v02, v02);
for (v01=12; v01--;){
c.beginPath();
c.moveTo(-10, 10);
c.quadraticCurveTo(
-80, -15,
-120, -25
);
c.quadraticCurveTo(
-80, -14.8,
-10, 10
);
c.fill();
c.scale(1.3, 1.3);
}
c.restore();
// c.globalAlpha = 1;
// Train
v01 = (500 / g) - .5;
// v01 = 5;
c.scale(v01, v01);
for (v01 = 400; v01-- ; ){
c.beginPath();
c.moveTo(-70 + Math.sin(v01/152) * 30, v01/16-30);
c.lineTo(-560, v01/2-246);
if (v01<200){
c.strokeStyle = 'hsl(0,15%,' + (90-v01*0.3) + '%)';
} else {
c.strokeStyle = 'hsl(195,25%,' + (180-v01*0.375) + '%)';
}
c.stroke();
}
// Stripes and the rear
c.save();
c.fillStyle = '#111';
for (v01=5;v01--;){
c.beginPath();
if (v01){
c.arc(-99, -23.0, 18.8, 1, -1.2, 1);
} else {
c.arc(-99, -23.0, 18.8, 2.8, 4.6);
}
c.arc(-97, -22.6, 19.2, -0.9, 0.95);
c.fill();
c.scale(1.6, 1.6);
}
c.restore();
// Flames
// c.fillStyle = '#f82';
// c.globalAlpha = 0.1;
c.fillStyle = 'rgba(255,136,34,.1)';
for (v01=10; v01--; ){
c.beginPath();
c.moveTo(-70 + Math.sin(g + v01), -35 + Math.cos(g + v01));
c.quadraticCurveTo(
10, -10,
-80 + Math.sin(g + v01), Math.cos(g + v01)
);
c.quadraticCurveTo(
-10 + Math.sin(g + v01) * 9, -12 + Math.cos(g + v01) * 3,
-70 + Math.sin(g + v01), -35 + Math.cos(g + v01)
);
c.fill();
}
if (DEBUG){
c.restore();
c.strokeStyle = '#fff';
c.strokeRect(-VIEWPORT_WIDTH / 2, -VIEWPORT_HEIGHT / 2, VIEWPORT_WIDTH, VIEWPORT_HEIGHT);
}
}, 40);