UNPKG

tsparticles

Version:

Easily create highly customizable particle, confetti and fireworks animations and use them as animated backgrounds for your website. Ready to use components available also for React, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Riot.js, Inferno.

2 lines 6.21 kB
/*! tsParticles v1.42.2 by Matteo Bruni */ !function(e,o){if("object"==typeof exports&&"object"==typeof module)module.exports=o();else if("function"==typeof define&&define.amd)define([],o);else{var n=o();for(var t in n)("object"==typeof exports?exports:e)[t]=n[t]}}(window,(function(){return function(){"use strict";var e={d:function(o,n){for(var t in n)e.o(n,t)&&!e.o(o,t)&&Object.defineProperty(o,t,{enumerable:!0,get:n[t]})},o:function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},o={};e.r(o),e.d(o,{loadColorUpdater:function(){return y}});class n{}n.generatedAttribute="generated",n.randomColorValue="random",n.midColorValue="mid",n.touchEndEvent="touchend",n.mouseDownEvent="mousedown",n.mouseUpEvent="mouseup",n.mouseMoveEvent="mousemove",n.touchStartEvent="touchstart",n.touchMoveEvent="touchmove",n.mouseLeaveEvent="mouseleave",n.mouseOutEvent="mouseout",n.touchCancelEvent="touchcancel",n.resizeEvent="resize",n.visibilityChangeEvent="visibilitychange",n.noPolygonDataLoaded="No polygon data loaded.",n.noPolygonFound="No polygon found, you need to specify SVG url in config.";new WeakMap;new WeakMap;new WeakMap,new WeakSet;new WeakMap;new WeakMap;new WeakMap;function t(e){const o=l(e);let n=a(e);return o===n&&(n=0),Math.random()*(o-n)+n}function r(e){return"number"==typeof e?e:t(e)}function a(e){return"number"==typeof e?e:e.min}function l(e){return"number"==typeof e?e:e.max}function s(e,o){if(e===o||void 0===o&&"number"==typeof e)return e;const n=a(e),t=l(e);return void 0!==o?{min:Math.min(n,o),max:Math.max(t,o)}:s(n,t)}function i(e,o,n=!0){return e[void 0!==o&&n?o%e.length:function(e){return Math.floor(Math.random()*e.length)}(e)]}function u(e,o,n){let t=n;return t<0&&(t+=1),t>1&&(t-=1),t<1/6?e+6*(o-e)*t:t<.5?o:t<2/3?e+(o-e)*(2/3-t)*6:e}function c(e){if(e.startsWith("rgb")){const o=/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([\d.]+)\s*)?\)/i.exec(e);return o?{a:o.length>4?parseFloat(o[5]):1,b:parseInt(o[3],10),g:parseInt(o[2],10),r:parseInt(o[1],10)}:void 0}if(e.startsWith("hsl")){const o=/hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([\d.]+)\s*)?\)/i.exec(e);return o?function(e){const o=f(e);return{a:e.a,b:o.b,g:o.g,r:o.r}}({a:o.length>4?parseFloat(o[5]):1,h:parseInt(o[1],10),l:parseInt(o[3],10),s:parseInt(o[2],10)}):void 0}if(e.startsWith("hsv")){const o=/hsva?\(\s*(\d+)°\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([\d.]+)\s*)?\)/i.exec(e);return o?function(e){const o=h(e);return{a:e.a,b:o.b,g:o.g,r:o.r}}({a:o.length>4?parseFloat(o[5]):1,h:parseInt(o[1],10),s:parseInt(o[2],10),v:parseInt(o[3],10)}):void 0}{const o=/^#?([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i,n=e.replace(o,((e,o,n,t,r)=>o+o+n+n+t+t+(void 0!==r?r+r:""))),t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i.exec(n);return t?{a:void 0!==t[4]?parseInt(t[4],16)/255:1,b:parseInt(t[3],16),g:parseInt(t[2],16),r:parseInt(t[1],16)}:void 0}}function d(e,o,t=!0){var r,a,l;if(void 0===e)return;const s="string"==typeof e?{value:e}:e;let u;if("string"==typeof s.value)u=s.value===n.randomColorValue?p():function(e){return c(e)}(s.value);else if(s.value instanceof Array){u=d({value:i(s.value,o,t)})}else{const e=s.value,o=null!==(r=e.rgb)&&void 0!==r?r:s.value;if(void 0!==o.r)u=o;else{const o=null!==(a=e.hsl)&&void 0!==a?a:s.value;if(void 0!==o.h&&void 0!==o.l)u=f(o);else{const o=null!==(l=e.hsv)&&void 0!==l?l:s.value;void 0!==o.h&&void 0!==o.v&&(u=h(o))}}}return u}function v(e,o,n=!0){const t=d(e,o,n);return void 0!==t?function(e){const o=e.r/255,n=e.g/255,t=e.b/255,r=Math.max(o,n,t),a=Math.min(o,n,t),l={h:0,l:(r+a)/2,s:0};r!=a&&(l.s=l.l<.5?(r-a)/(r+a):(r-a)/(2-r-a),l.h=o===r?(n-t)/(r-a):l.h=n===r?2+(t-o)/(r-a):4+(o-n)/(r-a));l.l*=100,l.s*=100,l.h*=60,l.h<0&&(l.h+=360);return l}(t):void 0}function f(e){const o={b:0,g:0,r:0},n={h:e.h/360,l:e.l/100,s:e.s/100};if(0===n.s)o.b=n.l,o.g=n.l,o.r=n.l;else{const e=n.l<.5?n.l*(1+n.s):n.l+n.s-n.l*n.s,t=2*n.l-e;o.r=u(t,e,n.h+1/3),o.g=u(t,e,n.h),o.b=u(t,e,n.h-1/3)}return o.r=Math.floor(255*o.r),o.g=Math.floor(255*o.g),o.b=Math.floor(255*o.b),o}function h(e){const o={b:0,g:0,r:0},n=e.h/60,t=e.s/100,r=e.v/100,a=r*t,l=a*(1-Math.abs(n%2-1));let s;if(n>=0&&n<=1?s={r:a,g:l,b:0}:n>1&&n<=2?s={r:l,g:a,b:0}:n>2&&n<=3?s={r:0,g:a,b:l}:n>3&&n<=4?s={r:0,g:l,b:a}:n>4&&n<=5?s={r:l,g:0,b:a}:n>5&&n<=6&&(s={r:a,g:0,b:l}),s){const e=r-a;o.r=Math.floor(255*(s.r+e)),o.g=Math.floor(255*(s.g+e)),o.b=Math.floor(255*(s.b+e))}return o}function p(e){const o=null!=e?e:0;return{b:Math.floor(t(s(o,256))),g:Math.floor(t(s(o,256))),r:Math.floor(t(s(o,256)))}}function b(e,o,n){if(e.enable=o.enable,e.enable){if(e.velocity=r(o.speed)/100*n,o.sync)return;e.status=0,e.velocity*=Math.random(),e.value&&(e.value*=Math.random())}else e.velocity=0}function g(e,o,n,r,a){var l;const s=o;if(!s||!n.enable)return;const i=t(n.offset),u=(null!==(l=o.velocity)&&void 0!==l?l:0)*e.factor+3.6*i;a&&0!==s.status?(s.value-=u,s.value<0&&(s.status=0,s.value+=s.value)):(s.value+=u,a&&s.value>r&&(s.status=1,s.value-=s.value%r)),s.value>r&&(s.value%=r)}new WeakMap;class m{constructor(e){this.container=e}init(e){const o=v(e.options.color,e.id,e.options.reduceDuplicates);o&&(e.color=function(e,o,n){const t={h:{enable:!1,value:e.h},s:{enable:!1,value:e.s},l:{enable:!1,value:e.l}};return o&&(b(t.h,o.h,n),b(t.s,o.s,n),b(t.l,o.l,n)),t}(o,e.options.color.animation,this.container.retina.reduceFactor))}isEnabled(e){var o,n,t;const r=e.options.color.animation;return!e.destroyed&&!e.spawning&&(void 0!==(null===(o=e.color)||void 0===o?void 0:o.h.value)&&r.h.enable||void 0!==(null===(n=e.color)||void 0===n?void 0:n.s.value)&&r.s.enable||void 0!==(null===(t=e.color)||void 0===t?void 0:t.l.value)&&r.l.enable)}update(e,o){!function(e,o){var n,t,r;const a=e.options.color.animation;void 0!==(null===(n=e.color)||void 0===n?void 0:n.h)&&g(o,e.color.h,a.h,360,!1),void 0!==(null===(t=e.color)||void 0===t?void 0:t.s)&&g(o,e.color.s,a.s,100,!0),void 0!==(null===(r=e.color)||void 0===r?void 0:r.l)&&g(o,e.color.l,a.l,100,!0)}(e,o)}}async function y(e){await e.addParticleUpdater("color",(e=>new m(e)))}return o}()}));