8 lines
4.2 KiB
JavaScript
8 lines
4.2 KiB
JavaScript
/**
|
|
* Minified by jsDelivr using Terser v3.14.1.
|
|
* Original file: /npm/canvas-confetti@0.4.0/dist/confetti.browser.js
|
|
*
|
|
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
|
|
*/
|
|
!function(t,e){!function(){var n,o;t.requestAnimationFrame&&t.cancelAnimationFrame?(n=t.requestAnimationFrame,o=t.cancelAnimationFrame):["webkit","moz","o","ms"].forEach(function(e){if(!n||!o){var i=e+"RequestAnimationFrame",r=e+"CancelAnimationFrame";t[i]&&t[r]&&(n=t[i],o=t[r])}}),n&&o||(n=function(e){return t.setTimeout(e,1e3/60)},o=function(e){return t.clearTimeout(e)});var i={particleCount:50,angle:90,spread:45,startVelocity:45,decay:.9,ticks:200,x:.5,y:.5,shapes:["square","circle"],zIndex:100,colors:["#26ccff","#a25afd","#ff5e7e","#88ff5a","#fcff42","#ffa62d","#ff36ff"]};function r(){}function a(t,e,n){return function(t,e){return e?e(t):t}(t&&null!=t[e]?t[e]:i[e],n)}function l(t){return parseInt(t,16)}function c(t){t.width=document.documentElement.clientWidth,t.height=document.documentElement.clientHeight}function s(t){var e=t.getBoundingClientRect();t.width=e.width,t.height=e.height}function u(i,a,l,u,h){var f,d,m=a.slice(),b=i.getContext("2d"),g=i.width,y=i.height,p=l?c:s;function M(){g=y=null}var v,x=(v=function(e){function o(){f=d=null,u&&t.removeEventListener("resize",M),b.clearRect(0,0,g,y),h(),e()}f=n(function t(){g||y||(p(i),g=i.width,y=i.height),b.clearRect(0,0,g,y),(m=m.filter(function(t){return function(t,e){e.x+=Math.cos(e.angle2D)*e.velocity,e.y+=Math.sin(e.angle2D)*e.velocity+3,e.wobble+=.1,e.velocity*=e.decay,e.tiltAngle+=.1,e.tiltSin=Math.sin(e.tiltAngle),e.tiltCos=Math.cos(e.tiltAngle),e.random=Math.random()+5,e.wobbleX=e.x+10*Math.cos(e.wobble),e.wobbleY=e.y+10*Math.sin(e.wobble);var n=e.tick++/e.totalTicks,o=e.x+e.random*e.tiltCos,i=e.y+e.random*e.tiltSin,r=e.wobbleX+e.random*e.tiltCos,a=e.wobbleY+e.random*e.tiltSin;return t.fillStyle="rgba("+e.color.r+", "+e.color.g+", "+e.color.b+", "+(1-n)+")",t.beginPath(),"circle"===e.shape?t.ellipse(e.x,e.y,.6*Math.abs(r-o),.6*Math.abs(a-i),Math.PI/10*e.wobble,0,2*Math.PI):(t.moveTo(Math.floor(e.x),Math.floor(e.y)),t.lineTo(Math.floor(e.wobbleX),Math.floor(i)),t.lineTo(Math.floor(r),Math.floor(a)),t.lineTo(Math.floor(o),Math.floor(e.wobbleY))),t.closePath(),t.fill(),e.tick<e.totalTicks}(b,t)})).length?f=n(t):o()}),d=o},e.exports.Promise?new e.exports.Promise(v):(v(r,r),null));return u&&t.addEventListener("resize",M,!1),{addFettis:function(t){return m=m.concat(t),x},canvas:i,promise:x,reset:function(){f&&o(f),d&&d()}}}function h(t,e){var n,o=!t,i=!!a(e||{},"resize"),r=!1;function h(e){var h=a(e,"particleCount",Math.floor),f=a(e,"angle",Number),d=a(e,"spread",Number),m=a(e,"startVelocity",Number),b=a(e,"decay",Number),g=a(e,"colors"),y=a(e,"ticks",Number),p=a(e,"zIndex",Number),M=a(e,"shapes"),v=function(t){var e=a(t,"origin",Object);return e.x=a(e,"x",Number),e.y=a(e,"y",Number),e}(e),x=h,w=[];o?t=n?n.canvas:function(t){var e=document.createElement("canvas");return c(e),e.style.position="fixed",e.style.top="0px",e.style.left="0px",e.style.pointerEvents="none",e.style.zIndex=t,e}(p):i&&!r&&(s(t),r=!0);for(var k,C,P,A,I,T,F,N=t.width*v.x,z=t.height*v.y;x--;)w.push((k={x:N,y:z,angle:f,spread:d,startVelocity:m,color:g[x%g.length],shape:M[(T=0,F=M.length,Math.floor(Math.random()*(F-T))+T)],ticks:y,decay:b},C=void 0,P=void 0,A=void 0,I=void 0,A=k.angle*(Math.PI/180),I=k.spread*(Math.PI/180),{x:k.x,y:k.y,wobble:10*Math.random(),velocity:.5*k.startVelocity+Math.random()*k.startVelocity,angle2D:-A+(.5*I-Math.random()*I),tiltAngle:Math.random()*Math.PI,color:(C=k.color,P=String(C).replace(/[^0-9a-f]/gi,""),P.length<6&&(P=P[0]+P[0]+P[1]+P[1]+P[2]+P[2]),{r:l(P.substring(0,2)),g:l(P.substring(2,4)),b:l(P.substring(4,6))}),shape:k.shape,tick:0,totalTicks:k.ticks,decay:k.decay,random:Math.random()+5,tiltSin:0,tiltCos:0,wobbleX:0,wobbleY:0}));return n?n.addFettis(w):(o&&document.body.appendChild(t),(n=u(t,w,o,o||i,function(){n=null,o&&document.body.removeChild(t)})).promise)}return h.reset=function(){n&&n.reset()},h}e.exports=h(),e.exports.create=h,e.exports.Promise=t.Promise||null}(),t.confetti=e.exports}(window,{});
|
|
//# sourceMappingURL=/sm/bf47ebc07e6c6098c39b6e8d68bf830f3f6f1fbf710de77e3981b8b8bc4e9315.map
|