mirror of
https://github.com/simon987/the-rom.eu.git
synced 2025-04-10 14:06:42 +00:00
13 lines
4.9 KiB
JavaScript
13 lines
4.9 KiB
JavaScript
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Sprinkler=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
|
module.exports=function(n,r){var o,e,l,u,t,f,a;for(l=n.length,a=!1,f=!1,e=[],t=0,u=function(){if(!f){t+=1;var n=t===l;n&&(a=!0,r(null,e))}},onerror=function(n){return a||(f=!0,r(n,null)),!0},o=0;o<n.length;o+=1)e.push(new Image),e[o].onload=u,e[o].onerror=onerror,e[o].src=n[o]};
|
|
},{}],2:[function(require,module,exports){
|
|
var Particle=function(t,i,h,s,d,a,r,x,y,c,z,e,n,o,l,P,m,p){this.x=t,this.y=i,this.z=h,this.r=s,this.a=d,this.dx=a,this.dy=r,this.dz=x,this.dr=y,this.da=c,this.ddx=z,this.ddy=e,this.ddz=n,this.ddr=o,this.dda=l,this.img=P,this.w=m,this.h=p};Particle.prototype.tick=function(t){this.x+=this.dx*t,this.y+=this.dy*t,this.z+=this.dz*t,this.r+=this.dr*t,this.a=Math.min(1,Math.max(0,this.a+this.da*t)),this.dx+=this.ddx*t,this.dy+=this.ddy*t,this.dz+=this.ddz*t,this.dr+=this.ddr*t,this.da+=this.dda*t},exports.Particle=Particle;
|
|
},{}],3:[function(require,module,exports){
|
|
var loadImages=require("./loadimages"),Particle=require("./particle").Particle,stat=require("./stat"),randomIn=stat.randomIn,randomPick=stat.randomPick,samplePoisson=stat.samplePoisson,extendValid=function(n,a){var r;for(r in n)n.hasOwnProperty(r)&&a.hasOwnProperty(r)&&typeof n[r]==typeof a[r]&&(a[r]=n[r])},makeCanvasAutoFullwindow=function(n){var a=function(){n.width=window.innerWidth,n.height=window.innerHeight};window.addEventListener("resize",a,!1),a()},Sprinkler=function(n){var a={},r=[],t=!1,e=null,d=n.getContext("2d");makeCanvasAutoFullwindow(n);var i=function(a){var r,t,e;return r=n.width,t=n.height,e=randomPick(a.selectImages),new Particle(randomIn(0,r),-a.zMax*Math.max(e.width,e.height)/2,randomIn(a.zMin,a.zMax),randomIn(a.rMin,a.rMax),randomIn(a.aMin,a.aMax),randomIn(a.dxMin,a.dxMax),randomIn(a.dyMin,a.dyMax),randomIn(a.dzMin,a.dzMax),randomIn(a.drMin,a.drMax),randomIn(a.daMin,a.daMax),randomIn(a.ddxMin,a.ddxMax),randomIn(a.ddyMin,a.ddyMax),randomIn(a.ddzMin,a.ddzMax),randomIn(a.ddrMin,a.ddrMax),randomIn(a.ddaMin,a.ddaMax),e,e.width,e.height)},o=function(n,a){var t,e=n.imagesInSecond,d=a*e,o=samplePoisson(d);for(t=0;o>t;t+=1)r.push(i(n))},M=function(t){var e,d,i,M,s,l,m,x,h,c,f;if(.5>t){for(e=0;e<r.length;e+=1)r[e].tick(t);for(d in a)if(a.hasOwnProperty(d)){M=a[d];for(i in M)M.hasOwnProperty(i)&&(s=M[i],o(s,t))}}for(l=n.height,m=[],e=0;e<r.length;e+=1)h=r[e].w,c=r[e].h,f=r[e].z*Math.max(h,c)/2,x=r[e].y<l+f,x&&m.push(r[e]);r=m},s=function(){var a,t,e;for(d.clearRect(0,0,n.width,n.height),a=0;a<r.length;a+=1)d.globalAlpha=r[a].a,t=r[a].z*r[a].w,e=r[a].z*r[a].h,d.translate(r[a].x,r[a].y),d.rotate(r[a].r),d.drawImage(r[a].img,-Math.floor(t/2),-Math.floor(e/2),t,e),d.setTransform(1,0,0,1,0,0),d.globalAlpha=1},l=function x(){var n,a;n=Date.now(),a=null===e?0:n-e,e=n,M(a/1e3),s(),t&&window.requestAnimationFrame(x)},m=function(){t||(t=!0,l())};this.load=function(n,r){loadImages(n,function(n,t){if(n)return void r(n,null);var e=Math.random().toString();a[e]={};var d=function(n){var r,d;if("undefined"==typeof n&&(n={}),"[object Object]"!==Object.prototype.toString.call(n))throw"InvalidOptionsError";if(d={type:"default",selectImages:t,zMin:.38,zMax:1,rMin:0,rMax:2*Math.PI,aMin:1,aMax:1,dxMin:-1,dxMax:1,dyMin:100,dyMax:100,dzMin:0,dzMax:0,drMin:-1,drMax:1,daMin:0,daMax:0,ddxMin:0,ddxMax:0,ddyMin:0,ddyMax:0,ddzMin:0,ddzMax:0,ddrMin:0,ddrMax:0,ddaMin:0,ddaMax:0,imagesInSecond:7,stopAfter:1/0,onStop:function(){}},extendValid(n,d),n.hasOwnProperty("selectImages"))for(d.selectImages=[],r=0;r<n.selectImages.length;r+=1)d.selectImages[r]=t[n.selectImages[r]];n=d;var i=Math.random().toString();return a[e][i]=n,m(),function(){delete a[e][i]}};r(null,d)})}};exports.create=function(n,a){return new Sprinkler(n,a)},exports.extension=Sprinkler.prototype,exports.version="0.4.3";
|
|
},{"./loadimages":1,"./particle":2,"./stat":4}],4:[function(require,module,exports){
|
|
exports.randomIn=function(r,n){var o=n-r;return r+o*Math.random()},exports.randomPick=function(r){var n=0,o=r.length,t=exports.randomIn(n,o),a=Math.floor(t),e=a;return r[e]},exports.samplePoisson=function(r){var n,o,t,a;n=Math.exp(-r),o=0,t=1;do o+=1,a=Math.random(),t*=a;while(t>n);return o-1};
|
|
},{}]},{},[3])(3)
|
|
});
|
|
|
|
|
|
//# sourceMappingURL=sprinkler.min.js.map
|