A random infinite star field! You can drag the map using the mouse! Should work on touch screens as well!
for(_='touchB)>>0;V||0>_UStyle7s[i6is%c.$,$lineO(_x,_yNt.KKyJ};IthH$strokepage=ri(c[f]movefillb.*bfunction(Kxl(H%)}m.=*(){+=.:0,=0;random()d-ba= );="#fff";=b,dreturn r.=Bes[0].for(i200>i;i++);a.onmouseH%.a.addEventL%tener("Br=MaH;rifloor(r.+1))+bIrf)+bIf="7";g="Rect";s=[];w=a.widH;h=a.height;m={Ixyadet={xyhifg:0I=y e(e.prototype={a:_x=j=x-*b;_y=k=y-J*b;c08%-cif(A=6-1])$beginPaH(),$ToN)OWidH=kOTo(A.j,A.k),(c[g]N,c,c(_x>w||_y>hUxUy)&&I l(bb=rf(.1,1x,w+yJ,h+Jc%1,4)}6]=new e;o=w/2;p=h/2;k n(="#222";$globalAlpha=.8;c[g](0,0,w,h$Text("DRAG",o-,p-Ja?(Kf=Kh-2x-d),Kg=Ki-2y-e),k10-k)):(Kh=Kf,Ki=Kg,dx,ey,k005.5-k)2Kf-VJ2Kg-JV7u=6],u.a(requestAnimationFrame(n)}n()down= 1}up= 0}=bx=X;y=YI q(bxX;yY}start",b 1;q(bdx;ey}end", 0}",q';g=/[-H-KNO$%67UVB]/.exec(_);)with(_.split(g))_=join(shift());eval(_)
Zm9yKF89J3RvdWNoQik+PjA7Vnx8MD5fVVN0eWxlN3NbaTZpcyVjLiQsJGxpbmVPKF94LF95TnQuS0t5Sn07SXRoSCRzdHJva2UfcGFnZR49cmkoHWNbZl0cbW92ZRtmaWxsGmIuGSoZYhhmdW5jdGlvbhcXKBZLeBVsKEglKX0UbS4TPRMSKigRKXsQKz0uDzowLA49MDsMcmFuZG9tKCkRZC1iCxATYT0JKTsIPSIjZmZmIjsHPRZiLGQQcmV0dXJuIHIuBj0ZQmVzWzBdLh4FZm9yKGkMMjAwPmk7aSsrKQQ7YS5vbm1vdXNlA0glLgJhLmFkZEV2ZW50TCV0ZW5lcigiQgFyPU1hSDtyaQZmbG9vcihyLgsrMSkpK2JJcmYGCykrYklmPSIaNyI7Zz0iGlJlY3QiO3M9W107dz1hLndpZEg7aD1hLmhlaWdodDttPXtJE3gSeRJhEmQSZQx0PXt4DnkOaA5pDmYOZzowSRU9eQwXIGUoEBRlLnByb3RvdHlwZT17YToWEF94PQJqPQJ4LRUqAmI7X3k9Ams9AnktSioCYjsCYw8wOBECJS0CYwhpZihBPTYtMV0pJGJlZ2luUGFIKCksJBtUb04pT1dpZEg9a09UbyhBLmosQS5rKSwfKAgcB2NbZ11OLAJjLAJjCChfeD53fHxfeT5oVXhVeSkmJhRJFyBsKGIQGWI9cmYoLjEsMQgZeB0VGCx3KxUYCBl5HUoYLGgrShgIGWMMGSUdMSw0KX0ENl09bmV3IGU7bz13LzI7cD1oLzI7awwXIG4oEBw9IiMyMjIiOyRnbG9iYWxBbHBoYT0uODtjW2ddKDAsMCx3LGgIHAckGlRleHQoIkRSQUciLG8tFSxwLUoIE2E/KEtmPUtoLTIRE3gtE2QpLEtnPUtpLTIRE3ktE2UpLGsPMREwLWspKTooS2g9S2YsS2k9S2csE2QSeCwTZRJ5LGsPMDA1ES41LWspCBUPMhFLZi0VVkoPMhFLZy1KVh83BwR1PTZdLHUuYSgIcmVxdWVzdEFuaW1hdGlvbkZyYW1lKG4pfW4oKQNkb3duPRYJMX0DdXA9FgkwfQMbPRZiEBN4PRkeWDsTeT0ZHllJFyBxKGIQE3gFWDsTeQVZfQFzdGFydCIsFmIJMTtxKGIIE2QSeDsTZRJ5fQgBZW5kIiwWCTB9CAEbIixxCCc7Zz0vWwEtH0gtS05PJCU2N1VWQl0vLmV4ZWMoXyk7KXdpdGgoXy5zcGxpdChnKSlfPWpvaW4oc2hpZnQoKSk7ZXZhbChfKQ==
r = Math;
//random int
ri = function (min, max) {
return r.floor(r.random() * (max - min + 1)) + min;
}
//random float
rf = function (min, max) {
return r.random() * (max - min) + min;
}
f = 'fillStyle';
g = 'fillRect';
//start array
s = [];
//colors
w = a.width;
h = a.height;
//mouse
m = {};
// x position x
// y position y
// d mouse is down? 0 = no; 1 = yes;
// cx mouse postion x on click, used for drag the map
// cy mouse postion y on click, used for drag the map
m.x = m.y = m.d = m.cx = m.cy = 0;
//camera
t = {
x: 0, //x position
y: 0, //y position
lx: 0, // position x of the camera when start to drag
ly: 0, // position y of the camera when start to drag
fx: 0, // used to smooth movement, it's the x coordinate that the camera will follow
fy: 0 // used to smooth movement, it's the y coordinate that the camera will follow
};
t.x = y = 0
//STARS
function S(){
this.r()
};
S.prototype = {
//reset
r: function(){
//scroll factor (parallax)
this.p = rf(.1,1)
//position x
this.x = ri(t.x * this.p, w + (t.x * this.p))
//position y
this.y = ri(t.y * this.p, h + (t.y * this.p))
//size
this.s = 0;
//Initial size
this.is = ri(1, 4)
//color
this.l = 0
},
//draw and update
d: function(){
//camera position x
_x = this.px = this.x - (t.x * this.p)
//camera position y
_y = this.py = this.y - (t.y * this.p)
//smoothly increace the size
this.s += (this.is - this.s) * .08;
//previous star
O = s[i - 1]
//if previous star exists
if(O){
//white color
c.beginPath()
c.moveTo(_x, _y)
c.lineWidth = k;
c.lineTo(O.px, O.py)
c.stroke()
}
//fill style
c[f] = '#fff';
//fill rect
c[g](_x, _y, this.s, this.s)
if(_x > w || _y > h || _x < 0 || _y < 0) this.r()
}
}
//instantiate 200 stars
for (i = 0; i < 200; i++) s[i] = new S;
//drag text x
o = w / 2;
//drag text y
p = h / 2;
//line width
k = 0;
//loop
function l() {
//fill style
c[f] = '#222'
c.globalAlpha = .8;
//fill rect
c[g](0,0,w, h)
//fill style // white color
c[f] = '#fff';
//fill rect
c.fillText('DRAG', o - t.x, p - t.y)
//if mouse is down
if(m.d) {
//set the coordinate that the camera should follow
t.fx = t.lx - (m.x - m.cx) * 2;
t.fy = t.ly - (m.y - m.cy) * 2;
k += (0 - k) * .1
//if the mouse is up
} else {
//set the last coordinate of the camera, stop when mouse is down
t.lx = t.fx;
t.ly = t.fy;
//set the coordinate of the mouse when start to drag
m.cx = m.x;
m.cy = m.y;
k += (0.5 - k) * .005
}
//camera smooth movement
t.x += (t.fx - t.x) * 0.2 >> 0;
t.y += (t.fy - t.y) * 0.2 >> 0;
c.strokeStyle = '#fff';
//interate over all stars
for (i = 0; i < 200; i++) {
u = s[i]
//draw each start
u.d();
}
requestAnimationFrame( l );
}
l()
//mouse events
function e(n, f){
a['onmouse'+n] = f
}
e('down', function(){
m.d = 1;
})
e('up', function(){
m.d = 0;
})
e('move', function(e){
m.x = e.pageX;
m.y = e.pageY;
})
//touch events
function T(n, f){
a.addEventListener('touch'+n, f);
}
//set touch coordinate
function st(e){
m.x = e.touches[0].pageX;
m.y = e.touches[0].pageY;
}
T('start', function(e){
m.d = 1;
st(e);
m.cx = m.x;
m.cy = m.y;
})
T('end', function(e){
m.d = 0;
})
T('move', st);