-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcity.min.js
19 lines (15 loc) · 1.46 KB
/
city.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*!
City skyline generator
https://github.com/JLemmetti/Skyline
Jurkka lemmetti - 2012
*/
(function(l,n){var a=n.getElementById("city"),m=a.getContext("2d"),j,k,b=[],p=20,o,q=[200,220,240,260,280,300,320,340,360,380,400],d=[40,60,80],e,h=n.getElementById("regenerate"),g=0;
a.width=950;a.height=500;j=function(i,c){return Math.floor(Math.random()*(c-i)+i);};o=function(t){var c=q[j(0,q.length)],u=d[j(0,d.length)],s=[],i=c;if(!o.position){o.position=j(-40,0);
}m.fillStyle=t;m.fillRect(o.position,c,u,a.height-c);while(i>20){s.push(i-=20);}m.fillStyle="#ffe460";m.fillRect(o.position+5,c+s[j(0,s.length)],10,15);
m.fillRect(o.position+20,c+s[j(0,s.length)],10,15);o.position+=u;if(o.position<a.width){o(t);}else{o.position=0;}};k=m.createLinearGradient(0,0,0,a.height);
k.addColorStop(0,"#141752");k.addColorStop(0.2,"#141752");k.addColorStop(1,"#992f02");m.fillStyle=k;m.fillRect(0,0,a.width,a.height);(function f(){var c;
if(!f.previousStar){f.previousStar=0;}c={x:j(10,p)+f.previousStar,y:j(10,250),color:"rgba(255, 255, 255, ."+j(1,6)+")"};f.previousStar=c.x;b.push(c);if(f.previousStar<a.width){f();
}}());(function r(){for(g=0;g<b.length;g+=1){m.beginPath();m.arc(b[g].x,b[g].y,1.5,0,Math.PI*2,true);m.closePath();m.fillStyle=b[g].color;m.fill();}}());
o("#222");e=m.createLinearGradient(0,100,0,a.height);e.addColorStop(0,"#000");e.addColorStop(1,"#212b33");o(e);h.addEventListener("click",function(){l.location.reload();
},false);}(window,document));