Jony/assets/backdrop/backdrop4.js

3 lines
60 KiB
JavaScript
Raw Permalink Normal View History

2021-01-25 04:59:40 +00:00
if(!navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)){var stop,staticx,img=new Image;function Sakura(A,i,t,g,B){this.x=A,this.y=i,this.s=t,this.r=g,this.fn=B}function getRandom(A){var i,t;switch(A){case"x":i=Math.random()*window.innerWidth;break;case"y":i=Math.random()*window.innerHeight;break;case"s":i=Math.random();break;case"r":i=6*Math.random();break;case"fnx":t=1*Math.random()-.5,i=function(A,i){return A+.5*t-1.7};break;case"fny":t=1.5+.7*Math.random(),i=function(A,i){return i+t};break;case"fnr":t=.03*Math.random(),i=function(A){return A+t}}return i}function startSakura(){requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame;var A,i=document.createElement("canvas");staticx=!0,i.height=window.innerHeight,i.width=window.innerWidth,i.setAttribute("style","position: fixed;left: 0;top: 0;pointer-events: none;z-index:-510;"),i.setAttribute("id","canvas_sakura"),document.getElementsByTagName("body")[0].appendChild(i),A=i.getContext("2d");for(var t=new SakuraList,g=0;g<20;g++){var B,o,I,a,e,R,n;o=getRandom("x"),I=getRandom("y"),e=getRandom("r"),a=getRandom("s"),R=getRandom("fnx"),n=getRandom("fny"),randomFnR=getRandom("fnr"),B=new Sakura(o,I,a,e,{x:R,y:n,r:randomFnR}),B.draw(A),t.push(B)}stop=requestAnimationFrame(function(){A.clearRect(0,0,i.width,i.height),t.update(),t.draw(A),stop=requestAnimationFrame(arguments.callee)})}function stopp(){if(staticx){var A=document.getElementById("canvas_sakura");A.parentNode.removeChild(A),window.cancelAnimationFrame(stop),staticx=!1}else startSakura()}
2021-01-25 03:29:51 +00:00
img.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUgAAAEwCAYAAADVZeifAAAACXBIWXMAAACYAAAAmAGiyIKYAAAHG2lUWHRYTUw6Y29tLm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egHES/t///Q7HHfG/+/8JT0fABGQTzIEkYMyGf/0vBh8N3/99wv/rP/1/sDs6/i//+t8DZhCATOFwzPj4/R3/MhkOmPBz/47dB+CY8LZ/w/NnQh4cu88dppSRU4abQwbQCRPhdDx/PCGbI9f7JLXbRfHpYw+n4MOkPAAUSacBmfv30f/rf+f+8m+GpyPw8Zrhl0IMAmK5KgAOWCY4Ib6r8pO+/hiV/5c/LyyVe6g8TnH5P/3f/q8bwv2zA+TfZ7HtvKbY4ScCOxCU4EaYE04hxb0hOYgEATAJTsGYkP2IQQBocAkkAGMBQcdgA47HA3aMg0cQkhmOGRhEZAMoIpdDhiREQYzXJQBDSQwygFGLdwET2/3c2luLx9fXzjhKk4hs8QTmsd2OAiHkIR4wZmFKxNMRGI7C5xPxt3+Lv+0GvL47/r/fBgBCJpAcYPwVAICbsPsE/v0VSJl49if8+/C/IEMwCIQBcCQLUBeBlOOFi4K5wanyGcgAiPEe5XSApInJsllCQkAVQNFStpTcUjoakxtNZqJIwtIx2XigpUyaG2xSdvPj9/+aPy3zoORuorKVD7OCoZfLxAUgMhegrEBYf1p8x2pYdxUKITVEXIBhewFit21bG0D+HWoQDgJwiERSAF622CFNgpsh5YypHPck4S7YEEcjQQhAsoRj/ixARHiBOVpAhsthNkCKPZwCvNvTB1Ugi7/dnpunr9mQYJjoGGWLOooVUAcDbAWV6CleN9sxJwzOeE/lczgakQ4OkzCNhBuwOwo/n+M+u4Pwsbd4dQLc
2021-01-25 04:59:40 +00:00
Sakura.prototype.draw=function(A){A.save(),this.s,A.translate(this.x,this.y),A.rotate(this.r),A.drawImage(img,0,0,30*this.s,30*this.s),A.restore()},Sakura.prototype.update=function(){this.x=this.fn.x(this.x,this.y),this.y=this.fn.y(this.y,this.y),this.r=this.fn.r(this.r),(this.x>window.innerWidth||this.x<0||this.y>window.innerHeight||this.y<0)&&(this.r=getRandom("fnr"),Math.random()>.4?(this.x=getRandom("x"),this.y=0,this.s=getRandom("s"),this.r=getRandom("r")):(this.x=window.innerWidth,this.y=getRandom("y"),this.s=getRandom("s"),this.r=getRandom("r")))},SakuraList=function(){this.list=[]},SakuraList.prototype.push=function(A){this.list.push(A)},SakuraList.prototype.update=function(){for(var A=0,i=this.list.length;A<i;A++)this.list[A].update()},SakuraList.prototype.draw=function(A){for(var i=0,t=this.list.length;i<t;i++)this.list[i].draw(A)},SakuraList.prototype.get=function(A){return this.list[A]},SakuraList.prototype.size=function(){return this.list.length},window.onresize=function(){document.getElementById("canvas_snow")},img.onload=function(){startSakura()}}