var body=document.body;var width=window.innerWidth;var height=window.innerHeight;var r=Math.random;var tini=document.getElementById('tini');if(undefined==tini){tini=document.createElement('canvas');tini.innerHTML='Update your browser to FireFox, Chrome or Internet Explorer 9';body.appendChild(tini)}var tini_parent=tini.parentNode;var tini_width=850;var tini_height=580;var tini_top=height/2-tini_height/2;var tini_left=width/2-tini_width/2;var tini_margin=10;var tini_style=tini.style;tini_style.marginTop=tini_top+'px';tini_style.marginLeft=tini_left+'px';tini_style.borderRadius='25px';var ctx=tini.getContext('2d');ctx.canvas.width=tini_width;ctx.canvas.height=tini_height;ctx.font='bold 22px Verdana,Arial,sans-serif';ctx.fillStyle='rgba(255,255,255,0.75)';ctx.fillText('LOADING',tini_width/2-ctx.measureText('LOADING').width/2,tini_height/2);document.title='C H R I S T M A S 2 K 1 1 ~ M 4 T I N I';var body_style=body.style;body_style.margin=0;body_style.background='#000';var sini_wavelength=4.46;var sini_amplitude=20;var sini=[];var sin_pi=Math.floor(Math.PI*2*sini_wavelength);var i=sin_pi-1;do{sini[i]=Math.sin(i/sini_wavelength)*sini_amplitude+1}while(--i>=0);var sini_length=sini.length;var sini_index=0;var sin2_wavelength=20;var sin2_amplitude=20;var sin2=[];var sin_pi=Math.floor(Math.PI*2*sin2_wavelength);var i=sin_pi-1;do{sin2[i]=Math.sin(i/sin2_wavelength)*sin2_amplitude+1}while(--i>=0);var sin2_length=sin2.length;var sin2_index=0;var star_speed=3;var stars=[];var i=50;do{var clone=[];clone.x=r()*width;clone.y=r()*height;clone.s=r()*star_speed+1;clone.a=r()*2;if(r()>.5)clone.a*=-1;stars.push(clone)}while(--i);var tini_x=tini_width;var scroll_y=200;var delay=0;var scroller=[];var scroll_text='  "Christmas 2k11"   | a quick HTML5 demo to wish you a  Happy New Year !!  | ';scroll_text=scroll_text.replace(/ /g,'  ').toUpperCase();var scroll_speed=3;var scroll_spacing=5;var scroll_visible=0;var scroll_length=scroll_text.length;function addLetter(){if(scroll_visible==scroll_length)scroll_visible=0;var a=scroll_text.charAt(scroll_visible++);if(a=='|'){delay=75;return}scroller.push(a)}function removeLetter(){var a=scroller[0];scroller.shift();tini_x+=ctx.measureText(a).width+scroll_spacing}var nfo_x=25;var nfo_y=(tini_height-525)/2;var nfo=[' ________________________________________________________','|%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%|','|%%|""""""""""""""""""""""""""""""""""""""""""""""""""|%%|','|%%|                                                  |%%|','|%%|            ||||||||||||||||||||||||"|            |%%|','|%%|            ||||"|    |||| |    |||| |            |%%|','|%%|            |||| |    |||| |    |||| |            |%%|','|%%|            |||| |    |||| |    |||| |            |%%|','|%%|            |||| |    |||| |    |||| |            |%%|','|%%|            |||| |    |||| |    |||| |            |%%|','|%%|            |____|    |____|    |____|            |%%|','|%%|                                                  |%%|','|%%|              M4tini Proudly Presents             |%%|','|%%|_____""""""""""""""""""""""""""""""""""""""""_____|%%|','|%%%%%%|              Christmas 2k11              |%%%%%%|','|%%|"""""________________________________________"""""|%%|','|%%|             |##|                |##|             |%%|','|%%|    _""""""""""""""""""""""""""""""""""""""""_    |%%|','|%%|   |  Release Date............... 31-12-2011  |   |%%|','|%%|   |                                          |   |%%|','|%%|   |  Size............................. 8 Kb  |   |%%|','|%%|   |                                          |   |%%|','|%%|   |  Type.................. JavaScript Demo  |   |%%|','|%%|   |                                          |   |%%|','|%%|   |  Code........................... M4tini  |   |%%|','|%%|   |                                          |   |%%|','|%%|   |  Ascii.......................... M4tini  |   |%%|','|%%|   |                                          |   |%%|','|%%|   |  Music....................... FantomenK  |   |%%|','|%%|   |                                          |   |%%|','|%%|   |    www.martini4ever.nl/christmas2k11     |   |%%|','|%%|    "________________________________________"    |%%|','|%%|             |##|                |##|             |%%|','|%%|    _""""""""""""""""""""""""""""""""""""""""_    |%%|','|%%|   |  Greetz fly out to:           my family  |   |%%|','|%%|___|                          all my friends  |___|%%|','|%%%%%%|                       former Wzone crew  |%%%%%%|',' """"""|                       colleagues at TIG  |""""""','       |                              and you ;)  |','        "________________________________________"','                |##|                  |##|','               |##|                    |##|','               |#|                      |#|','              |#|                        |#|','              |"                          "|'];for(var i=0,l=nfo.length;i<l;i++){nfo[i]=nfo[i].replace(/%/g,'\u2591');nfo[i]=nfo[i].replace(/#/g,'\u2592');nfo[i]=nfo[i].replace(/\|/g,'\u2588');nfo[i]=nfo[i].replace(/_/g,'\u2584');nfo[i]=nfo[i].replace(/"/g,'\u2580')}var audio=document.createElement('audio');audio.volume='0';audio.loop='loop';audio.preload='auto';var source=document.createElement('source');source.src='293004_FantomenK___christmas_x_me.mp3';audio.appendChild(source);source=source.cloneNode(true);source.src='293004_FantomenK___christmas_x_me.ogg';audio.appendChild(source);body.appendChild(audio);var flash_beat=0.5;var flash_bpm=0.91;var fade=1;var fade_speed=0.005;function tiniLoop(){ctx.font='bold 18px Verdana,Arial,sans-serif';var a=audio.currentTime;if(a==0)return;if(a>87.27){audio.currentTime=0;flash_beat=0.5}if(a>=flash_beat){ctx.fillStyle='rgb(25,25,25)';flash_beat+=flash_bpm}else{ctx.fillStyle='rgb(30,30,30)'}ctx.fillRect(0,0,tini_width,tini_height);ctx.fillStyle='rgba(255,255,255,.75)';if(++sin2_index>=sin2_length)sin2_index=0;for(var i=0,l=stars.length;i<l;i++){var b=stars[i];b.y+=b.s;b.x+=movex;ctx.fillText('*',b.x+(sin2[sin2_index]*b.a),b.y);if(b.y>tini_height+tini_margin){b.x=r()*tini_width-(100*movex);b.y=0-tini_margin;b.s=r()*star_speed+1}}if(delay>0)delay--;else tini_x-=scroll_speed;if(++sini_index>=sini_length)sini_index=0;var c=sini_index;var d=tini_x;for(var i=0;(e=scroller[i]);i++){if(++c>=sini_length)c=0;var f=.75;if(d<450||d>820)f=.60;if(d<445||d>825)f=.45;if(d<440||d>830)f=.30;if(d<435||d>835)f=.15;if(d<430||d>840)f=0;ctx.fillStyle='rgba(0,0,0,'+f+')';ctx.fillText(e,d,(sini[c]*-1+scroll_y));ctx.fillStyle='rgba(255,255,255,'+f+')';ctx.fillText(e,d,(sini[c]+scroll_y));d+=ctx.measureText(e).width+scroll_spacing}if(d<=tini_width)addLetter();if(tini_x<420)removeLetter();var g=tini_width*.75;var h=tini_height-80;var j=sini[sini_index];var k=sini[sini_index]*.8;var m=Math.PI*2;ctx.fillStyle='rgba(255,255,255,.75)';ctx.beginPath();ctx.arc(g,h-80+j,50,0,m,true);ctx.arc(g,h+k,60,0,m,true);ctx.closePath();ctx.fill();ctx.fillStyle='rgb(0,0,0)';ctx.beginPath();ctx.arc(g-20,h-90+j,5,0,m,true);ctx.arc(g+20,h-90+j,5,0,m,true);ctx.closePath();ctx.fill();ctx.fillStyle='rgb(0,0,0)';ctx.beginPath();ctx.arc(g,h-25+k,5,0,m,true);ctx.arc(g,h+k,5,0,m,true);ctx.arc(g,h+25+k,5,0,m,true);ctx.closePath();ctx.fill();ctx.fillStyle='rgb(255,100,0)';ctx.beginPath();ctx.arc(g,h-70+j,7,0,m,true);ctx.closePath();ctx.fill();ctx.beginPath();ctx.moveTo(g,h-77+j);ctx.lineTo(g+30,h-70+j+(sini[sini_index]/4)*-1);ctx.lineTo(g,h-63+j);ctx.closePath();ctx.fill();ctx.font='bold 12px Courier,sans-serif';var n=nfo_y;var o=sini_index;for(var i=0,l=nfo.length;i<l;i++){if(++o>=sini_length)o=0;ctx.fillStyle='rgba(0,0,0,.5)';ctx.fillText(nfo[i],nfo_x+sini[o]/sini_wavelength/2-3,n+5);ctx.fillStyle='rgba(255,255,255,.5)';ctx.fillText(nfo[i],nfo_x+sini[o]/sini_wavelength/2,n);n+=12}if(fade>fade_speed){audio.volume+=fade_speed;ctx.fillStyle='rgba(0,0,0,'+fade+')';ctx.fillRect(0,0,tini_width,tini_height);fade-=fade_speed}}var movex=1;tini.onmousemove=function(e){var a=e.pageX;var b=e.pageY;a-=this.offsetLeft;b-=this.offsetTop;if(a<tini_width/4)movex=-2;else if(a<tini_width/2)movex=-.75;else if(a<tini_width/1.5)movex=.75;else movex=2};setInterval('tiniLoop()',1000/30);audio.play();
