/*! * Animify jQuery Plugin v0.48 * http://animify.com/ * * Copyright 2017, Luke Snopkiewicz * Licensed under the MIT license. * http://animify.com/license.html * * Date: 2017-11-22 16:12:37 */ (function(a){a.fn.Animify=function(b){var d={effect:"blurbubbles","background-color":"detect","item-colours":"match",delay:40,"item-opacity":.4,"item-quantity":55,overlay:"fade",underlay:false,x:false,"y-direction":"default",fps:false,intro:true,posterize:false,age:false};return this.each(function(){function N(){canvas=a("#canvas");t=canvas[0].getContext("2d");switch(d["effect"]){case"blurbubbles":for(i=0;i3){g=Math.floor(f*20)}else{g=Math.floor(f*30)}w=Math.floor(Math.random()*g)+1}h=Math.floor(Math.random()*51)+50;vy=Math.floor(Math.random()*9)-4;if(vy==0)vy=.5;switch(d["item-colours"]){case"match":c=G(u,i);break}item=new I(x,y,w,h,vy,c);z.push(item)}break;case"squares":var j=0;for(i=0;ix){if(current_x-x<85)x+=30}if(current_xr){o=o+p;m=0}switch(D){case 1:underlay_context.fillStyle=q;break;case 2:underlay_context.fillStyle=v;break;case 3:underlay_context.fillStyle=A;break;case 4:D=1;underlay_context.fillStyle=q;break}underlay_context.fill();underlay_context.closePath()}break;case"film-noir":if(a("#overlay").css("background-image")){var E=new Image;C=a("#underlay");underlay_context=C[0].getContext("2d");var F=a("#overlay").css("background-image").replace(/url\(|\)$/ig,"").replace("http://"+window.location.host,"").replace('"',"").replace('"',"");E.src=""+F;a("#overlay").css({background:"none","background-color":"transparent"});E.onload=function(){underlay_context.drawImage(E,0,0);if(d["posterize"]==true){B=underlay_context.getImageData(0,0,r,s);var a=17.5;for(var b=0;br+z[i].h)z[i].x=-z[i].h;else if(z[i].x<-z[i].h)z[i].x=r+z[i].h}if(z[i].y>s+z[i].w)z[i].y=-z[i].w;else if(z[i].y<-z[i].w)z[i].y=s+z[i].w}break;case"squares":t.clearRect(0,0,r,s);var c=0;t.restore();for(i in z){t.fillStyle=z[i].c;t.beginPath();c++;t.shadowOffsetX=4;t.shadowOffsetY=4;t.shadowBlur=5;t.shadowColor=G(u,i-40);switch(c){case 1:t.rect(z[i].left_x,z[i].left_y,z[i].width,z[i].height);t.rect(z[i].left_x+42,z[i].left_y,z[i].width,z[i].height);t.rect(z[i].left_x,z[i].left_y+42,z[i].width,z[i].height);t.rect(z[i].left_x+42,z[i].left_y+42,z[i].width,z[i].height);break;case 2:t.rect(z[i].left_x,z[i].left_y,z[i].width,z[i].height);t.rect(z[i].left_x,z[i].left_y+42,z[i].width,z[i].height);t.rect(z[i].left_x+42,z[i].left_y+42,z[i].width,z[i].height);t.rect(z[i].left_x+42,z[i].left_y+84,z[i].width,z[i].height);break;case 3:t.rect(z[i].left_x,z[i].left_y,z[i].width,z[i].height);t.rect(z[i].left_x+42,z[i].left_y,z[i].width,z[i].height);t.rect(z[i].left_x+84,z[i].left_y,z[i].width,z[i].height);t.rect(z[i].left_x+126,z[i].left_y,z[i].width,z[i].height);break;case 4:t.rect(z[i].left_x,z[i].left_y,z[i].width,z[i].height);t.rect(z[i].left_x,z[i].left_y+42,z[i].width,z[i].height);t.rect(z[i].left_x,z[i].left_y+84,z[i].width,z[i].height);t.rect(z[i].left_x-42,z[i].left_y+84,z[i].width,z[i].height);break;case 5:t.rect(z[i].left_x,z[i].left_y,z[i].width,z[i].height);t.rect(z[i].left_x+42,z[i].left_y,z[i].width,z[i].height);t.rect(z[i].left_x+84,z[i].left_y,z[i].width,z[i].height);t.rect(z[i].left_x+42,z[i].left_y+42,z[i].width,z[i].height);c=0;break}t.fill();var g=Math.floor(Math.random()*20)+1;if(g==7){z[i].left_y=z[i].left_y+10}if(g==16){z[i].left_y=z[i].left_y+20}if(z[i].left_y>s)z[i].left_y=0}break;case"film-noir":t.clearRect(0,0,r,s);t.restore();A++;for(i in z){t.strokeStyle=z[i].c;t.fillStyle=z[i].c;t.beginPath();t.moveTo(z[i].x,z[i].y);t.lineTo(z[i].x,z[i].y+s);t.rect(Math.floor(Math.random()*(r+1)),Math.floor(Math.random()*(s+1)),1,1);t.rect(Math.floor(Math.random()*(r+1)),Math.floor(Math.random()*(s+1)),5,1);t.stroke();t.fill();var g=Math.floor(Math.random()*20)+1;if(g<12){z[i].x--}else{z[i].x++}if(z[i].x>r||z[i].x<0)z[i].x=Math.floor(Math.random()*(r+1))}break;case"grunge":break}if(d["intro"]==true&&a("#canvas").css("opacity")<1){o+=.01;a("canvas").css({opacity:""+o})}var h=new Date;var p=Math.ceil(h.getTime()-j.getTime());if(p>=1e3){f=e;e=0;j=h}if(d["fps"]==true){a("#fps_counter").html(""+Math.round(f))}e++;k++;m+=Math.round(f);if(k==300){l++;var v=l*300;if(d["fps"]==true){a("#average_fps").html(""+Math.round(m/v))}k=0;if(m/v<15){clearInterval(n);if(d["fps"]==true){a("#fps_stats").append(' Script terminated - could not achieve 15 fps average.')}q.css({background:""+a("#canvas").css("background")});a("canvas").fadeOut(1500)}}}function L(a,b,c){this.x=a;this.y=b;this.c=c}function K(a,b,c,d,e){this.left_x=a;this.left_y=b;this.width=c;this.height=d;this.c=e}function J(a){var b=a[0].getContext("2d");var c=document.createElement("canvas");var d=c.getContext("2d");var e=b.globalAlpha;c.width=r;c.height=s;var f=b.getImageData(0,0,r,s);var g=f.data;d.putImageData(f,0,0);for(var h=40;h<=c.width;h*=2){var i=Math.floor(Math.random()*(c.width-h));var j=Math.floor(Math.random()*(c.height-h));b.globalAlpha=4/h;b.drawImage(c,i,j,h,h)}b.globalAlpha=e}function I(a,b,c,d,e,f){this.x=a;this.y=b;this.w=c;this.h=d;this.vy=e;this.c=f}function H(b,c){var d=b.toString().split(",");var e=d[0].split("(");var f=parseInt(a.trim(e[1]));var g=parseInt(a.trim(d[1]));var h=d[2].split(")");var i=parseInt(a.trim(h[0]));var j="rgba("+f+","+g+","+i+","+c+")";return j}function G(b,c){var e=b.toString().split(",");var f=e[0].split("(");var g=parseInt(a.trim(f[1]));var h=parseInt(a.trim(e[1]));var i=e[2].split(")");var j=parseInt(a.trim(i[0]));g=g+c;h=h+c;j=j+c;var k="rgba("+g+", "+h+", "+j+", "+d["item-opacity"]+")";return k}function F(a){var b=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/;var c;if(a.match(b)){c=a}else{if(a.length==3){var d=""+a.charAt(0)+""+a.charAt(0)+""+a.charAt(1)+""+a.charAt(1)+""+a.charAt(2)+""+a.charAt(2);a=d}var e=parseInt(a.substring(0,2),16);var f=parseInt(a.substring(2,4),16);var g=parseInt(a.substring(4,6),16);c="rgb("+e+","+f+","+g+")"}return c}function E(b,c,e){q.append('');overlay=a("#overlay");overlay_context=overlay[0].getContext("2d");switch(d["overlay"]){case"fade":if(b*c<184321){alpha=1;for(i=0;i<100;i++){alpha-=.01;colour=H(u,alpha);overlay_context.fillStyle=colour;overlay_context.fillRect(0,i,b,1)}alpha=1;overlay_height=c;for(i=0;i<100;i++){alpha-=.01;colour=H(u,alpha);overlay_height--;overlay_context.fillStyle=colour;overlay_context.fillRect(0,overlay_height,b,1)}}else{var f=b*c;var g=Math.floor(f/6144);var h=Math.floor(g/30);var j=100*h;alpha=1;tick=0;for(i=0;i');if(d["overlay"]!="none"){E(r,s,overlay_z_index)}if(b){a("#overlay").css({"background-image":""+b})}if(c){}if(C!="none"){q.append('');a("#canvas").remove();q.append('')}}if(b){a.extend(d,b)}var e=0;var f=0;var g=1/(d["delay"]/1e3);var j=new Date;var k=0;var l=0;var m=0;if(d["fps"]==true){a("body").append('

Assumed Max FPS: '+Math.round(g)+' | Average FPS: ... | Current FPS: ...

');a("#animify_debug").css({position:"fixed",left:"0px",top:"0px",width:"100%",height:"30px","background-color":"#000","z-index":"10000",opacity:"0.75","border-bottom":"5px solid #666"});a("#animify_debug p").css({color:"#fff","font-size":"14px",position:"relative",top:"5px",left:"10px"})}var n;if(d["intro"]==true){var o=0;var p=0}var q=a(this);var r=a(this).width();var s=a(this).height();var t;var u;var v;d["background-color"]=="detect"?u=q.css("background-color"):u=F(a.trim(d["background-color"].toString().replace("#","")));var z=new Array;var A=0;var B;var C;d["underlay"]==false?C="none":C=d["underlay"];switch(d["effect"]){case"squares":if(d["underlay"]==false){C="squares"}break;case"film-noir":if(d["underlay"]==false){C="film-noir"}break;case"grunge":if(d["underlay"]==false){C="grunge"}break}D();if(d["intro"]==true){a("canvas").css({opacity:0})}N()})}})(jQuery)