-
Notifications
You must be signed in to change notification settings - Fork 0
/
easter.min.js
6 lines (6 loc) · 2.48 KB
/
easter.min.js
1
2
3
4
5
6
var Konami=function(b){var a={addEvent:function(a,b,c,f){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&(a["e"+b+c]=c,a[b+c]=function(){a["e"+b+c](window.event,f)},a.attachEvent("on"+b,a[b+c]))},input:"",pattern:"38384040373937396665",load:function(b){this.addEvent(document,"keydown",function(d,c){c&&(a=c);a.input+=d?d.keyCode:event.keyCode;a.input.length>a.pattern.length&&(a.input=a.input.substr(a.input.length-a.pattern.length));if(a.input==a.pattern)return a.code(b),a.input="",d.preventDefault(),
!1},this)},code:function(a){window.location=a}};"string"===typeof b&&a.load(b);"function"===typeof b&&(a.code=b,a.load());return a};Math.easeInSine=function(b,a,e,d){return-e*Math.cos(b/d*(Math.PI/2))+e+a};
var Easter=function(){({canvas:null,img:null,ctx:null,msStart:null,aframe:null,pic:"/assets/images/easter.gif",init:function(){this.setCanvas();var b=!0,a=this;(function d(){(b=!b)?a.aframe=requestAnimationFrame(d):a.noise(a.ctx)?a.aframe=requestAnimationFrame(d):a.bam()})()},bam:function(){this.img=document.createElement("div");this.img.style.backgroundImage="url("+this.pic+")";this.img.style.backgroundPosition="center center";this.img.style.backgroundRepeat="no-repeat";this.img.style.position="fixed";
this.img.style.top=0;this.img.style.zIndex=1002;this.img.style.height="100vh";this.img.style.width="100vw";document.body.insertBefore(this.img,document.body.firstChild);var b=this;document.onkeypress=function(a){b.cleanup();a.target.removeEventListener(a.type,listener)};document.onmouseover=function(a){b.cleanup();a.target.removeEventListener(a.type,listener)}},cleanup:function(){cancelAnimationFrame(this.afram);this.img.parentNode.removeChild(this.img);this.canvas.parentNode.removeChild(this.canvas)},
setCanvas:function(){this.canvas=document.createElement("canvas");document.body.insertBefore(this.canvas,document.body.firstChild);this.canvas.style.position="fixed";this.canvas.style.zIndex=1001;this.canvas.style.top=0;this.canvas.style.width=window.innerWidth+"px";this.canvas.style.height=window.innerHeight+"px";this.ctx=this.canvas.getContext("2d")},noise:function(b){for(var a=b.createImageData(b.canvas.width,b.canvas.height),e=new Uint32Array(a.data.buffer),d=e.length,c=0,f=0;c<d;c++)f=this.getNoiseThreshold(),
Math.random()<f&&(e[c]=4278190080);b.putImageData(a,0,0);return.99<f?(b.fillStyle="#000000",b.rect(0,0,2E3,2E3),b.fill(),!1):!0},getNoiseThreshold:function(){this.msStart=this.msStart?this.msStart:Date.now();return(Date.now()-this.msStart)%4E3/4E3}}).init()};Konami(Easter);