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