UNPKG

@tsparticles/plugin-hex-color

Version:

tsParticles hex color plugin

2 lines 1.49 kB
/*! For license information please see tsparticles.plugin.hexColor.min.js.LICENSE.txt */ !function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var t=r();for(var o in t)("object"==typeof exports?exports:e)[o]=t[o]}}(this,(()=>(()=>{var e,r={d:(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};r.r(t),r.d(t,{loadHexColorPlugin:()=>i}),function(e){e[e.r=1]="r",e[e.g=2]="g",e[e.b=3]="b",e[e.a=4]="a"}(e||(e={}));const o=/^#?([a-f\d])([a-f\d])([a-f\d])([a-f\d])?$/i,n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i;class a{constructor(){this.key="hex",this.stringPrefix="#"}handleColor(e){return this._parseString(e.value)}handleRangeColor(e){return this._parseString(e.value)}parseString(e){return this._parseString(e)}_parseString(r){if("string"!=typeof r)return;if(!r?.startsWith(this.stringPrefix))return;const t=r.replace(o,((e,r,t,o,n)=>r+r+t+t+o+o+(void 0!==n?n+n:""))),a=n.exec(t);return a?{a:void 0!==a[e.a]?parseInt(a[e.a],16)/255:1,b:parseInt(a[e.b],16),g:parseInt(a[e.g],16),r:parseInt(a[e.r],16)}:void 0}}async function i(e,r=!0){e.checkVersion("3.9.1"),await e.addColorManager(new a,r)}return t})()));