@tsparticles/plugin-polygon-mask 3.9.1 → 4.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/409.min.js +2 -0
  2. package/409.min.js.LICENSE.txt +1 -0
  3. package/browser/PolygonMaskInstance.js +40 -24
  4. package/browser/index.js +6 -5
  5. package/browser/pathseg.js +1 -1
  6. package/browser/utils.js +8 -5
  7. package/cjs/Enums/PolygonMaskInlineArrangement.js +2 -5
  8. package/cjs/Enums/PolygonMaskMoveType.js +2 -5
  9. package/cjs/Enums/PolygonMaskType.js +2 -5
  10. package/cjs/Interfaces/ISvgPath.js +1 -2
  11. package/cjs/Options/Classes/PolygonMask.js +16 -20
  12. package/cjs/Options/Classes/PolygonMaskDraw.js +5 -9
  13. package/cjs/Options/Classes/PolygonMaskDrawStroke.js +7 -11
  14. package/cjs/Options/Classes/PolygonMaskInline.js +5 -9
  15. package/cjs/Options/Classes/PolygonMaskLocalSvg.js +3 -7
  16. package/cjs/Options/Classes/PolygonMaskMove.js +5 -9
  17. package/cjs/Options/Interfaces/IPolygonMask.js +1 -2
  18. package/cjs/Options/Interfaces/IPolygonMaskDraw.js +1 -2
  19. package/cjs/Options/Interfaces/IPolygonMaskDrawStroke.js +1 -2
  20. package/cjs/Options/Interfaces/IPolygonMaskInline.js +1 -2
  21. package/cjs/Options/Interfaces/IPolygonMaskLocalSvg.js +1 -2
  22. package/cjs/Options/Interfaces/IPolygonMaskMove.js +1 -2
  23. package/cjs/PolygonMaskInstance.js +73 -61
  24. package/cjs/PolygonMaskPlugin.js +7 -11
  25. package/cjs/index.js +9 -25
  26. package/cjs/pathseg.js +2 -3
  27. package/cjs/types.js +1 -2
  28. package/cjs/utils.js +16 -20
  29. package/dist_browser_PolygonMaskPlugin_js.js +120 -0
  30. package/esm/PolygonMaskInstance.js +40 -24
  31. package/esm/index.js +6 -5
  32. package/esm/pathseg.js +1 -1
  33. package/esm/utils.js +8 -5
  34. package/package.json +4 -3
  35. package/report.html +5 -4
  36. package/tsparticles.plugin.polygon-mask.js +218 -129
  37. package/tsparticles.plugin.polygon-mask.min.js +1 -1
  38. package/tsparticles.plugin.polygon-mask.min.js.LICENSE.txt +1 -1
  39. package/types/PolygonMaskInstance.d.ts +1 -0
  40. package/types/index.d.ts +1 -2
  41. package/types/utils.d.ts +2 -2
  42. package/umd/PolygonMaskInstance.js +40 -24
  43. package/umd/index.js +30 -6
  44. package/umd/pathseg.js +1 -1
  45. package/umd/utils.js +8 -5
package/409.min.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 409.min.js.LICENSE.txt */
2
+ (this.webpackChunk_tsparticles_plugin_polygon_mask=this.webpackChunk_tsparticles_plugin_polygon_mask||[]).push([[409],{790(t,e,n){n.d(e,{PolygonMaskPlugin:()=>f});var i=n(303);class o{constructor(t){this._engine=t,this.color=new i.OptionsColor,this.width=.5,this.opacity=1}load(t){(0,i.isNull)(t)||(this.color=i.OptionsColor.create(this.color,t.color),(0,i.isString)(this.color.value)&&(this.opacity=(0,i.stringToAlpha)(this._engine,this.color.value)??this.opacity),void 0!==t.opacity&&(this.opacity=t.opacity),void 0!==t.width&&(this.width=t.width))}}class r{constructor(t){this.enable=!1,this.stroke=new o(t)}load(t){if((0,i.isNull)(t))return;void 0!==t.enable&&(this.enable=t.enable);const e=t.stroke;this.stroke.load(e)}}var s=n(999);class h{constructor(){this.arrangement=s.G.onePerPoint}load(t){(0,i.isNull)(t)||void 0!==t.arrangement&&(this.arrangement=t.arrangement)}}class a{constructor(){this.path=[],this.size={height:0,width:0}}load(t){(0,i.isNull)(t)||(void 0!==t.path&&(this.path=t.path),void 0!==t.size&&(void 0!==t.size.width&&(this.size.width=t.size.width),void 0!==t.size.height&&(this.size.height=t.size.height)))}}var S=n(155);class c{constructor(){this.radius=10,this.type=S.O.path}load(t){(0,i.isNull)(t)||(void 0!==t.radius&&(this.radius=t.radius),void 0!==t.type&&(this.type=t.type))}}var u=n(990);class _{constructor(t){this.draw=new r(t),this.enable=!1,this.inline=new h,this.move=new c,this.scale=1,this.type=u.T.none}load(t){(0,i.isNull)(t)||(this.draw.load(t.draw),this.inline.load(t.inline),this.move.load(t.move),void 0!==t.scale&&(this.scale=t.scale),void 0!==t.type&&(this.type=t.type),void 0!==t.enable?this.enable=t.enable:this.enable=this.type!==u.T.none,void 0!==t.url&&(this.url=t.url),void 0!==t.data&&((0,i.isString)(t.data)?this.data=t.data:(this.data=new a,this.data.load(t.data))),void 0!==t.position&&(this.position=(0,i.deepExtend)({},t.position)))}}!function(){try{if("undefined"==typeof window)return;"SVGPathSeg"in window||(window.SVGPathSeg=function(t,e,n){this.pathSegType=t,this.pathSegTypeAsLetter=e,this._owningPathSegList=n},window.SVGPathSeg.prototype.classname="SVGPathSeg",window.SVGPathSeg.PATHSEG_UNKNOWN=0,window.SVGPathSeg.PATHSEG_CLOSEPATH=1,window.SVGPathSeg.PATHSEG_MOVETO_ABS=2,window.SVGPathSeg.PATHSEG_MOVETO_REL=3,window.SVGPathSeg.PATHSEG_LINETO_ABS=4,window.SVGPathSeg.PATHSEG_LINETO_REL=5,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS=6,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL=7,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS=8,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL=9,window.SVGPathSeg.PATHSEG_ARC_ABS=10,window.SVGPathSeg.PATHSEG_ARC_REL=11,window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS=12,window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL=13,window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS=14,window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL=15,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS=16,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL=17,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS=18,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL=19,window.SVGPathSeg.prototype._segmentChanged=function(){this._owningPathSegList&&this._owningPathSegList.segmentChanged(this)},window.SVGPathSegClosePath=function(t){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CLOSEPATH,"z",t)},window.SVGPathSegClosePath.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegClosePath.prototype.toString=function(){return"[object SVGPathSegClosePath]"},window.SVGPathSegClosePath.prototype._asPathString=function(){return this.pathSegTypeAsLetter},window.SVGPathSegClosePath.prototype.clone=function(){return new window.SVGPathSegClosePath(void 0)},window.SVGPathSegMovetoAbs=function(t,e,n){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_MOVETO_ABS,"M",t),this._x=e,this._y=n},window.SVGPathSegMovetoAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegMovetoAbs.prototype.toString=function(){return"[object SVGPathSegMovetoAbs]"},window.SVGPathSegMovetoAbs.prototype._asPathString=function(){return`${this.pathSegTypeAsLetter} ${this._x} ${this._y}`},window.SVGPathSegMovetoAbs.prototype.clone=function(){return new window.SVGPathSegMovetoAbs(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegMovetoAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegMovetoAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegMovetoRel=function(t,e,n){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_MOVETO_REL,"m",t),this._x=e,this._y=n},window.SVGPathSegMovetoRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegMovetoRel.prototype.toString=function(){return"[object SVGPathSegMovetoRel]"},window.SVGPathSegMovetoRel.prototype._asPathString=function(){return`${this.pathSegTypeAsLetter} ${this._x} ${this._y}`},window.SVGPathSegMovetoRel.prototype.clone=function(){return new window.SVGPathSegMovetoRel(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegMovetoRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegMovetoRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoAbs=function(t,e,n){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_ABS,"L",t),this._x=e,this._y=n},window.SVGPathSegLinetoAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoAbs.prototype.toString=function(){return"[object SVGPathSegLinetoAbs]"},window.SVGPathSegLinetoAbs.prototype._asPathString=function(){return`${this.pathSegTypeAsLetter} ${this._x} ${this._y}`},window.SVGPathSegLinetoAbs.prototype.clone=function(){return new window.SVGPathSegLinetoAbs(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegLinetoAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegLinetoAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoRel=function(t,e,n){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_REL,"l",t),this._x=e,this._y=n},window.SVGPathSegLinetoRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoRel.prototype.toString=function(){return"[object SVGPathSegLinetoRel]"},window.SVGPathSegLinetoRel.prototype._asPathString=function(){return`${this.pathSegTypeAsLetter} ${this._x} ${this._y}`},window.SVGPathSegLinetoRel.prototype.clone=function(){return new window.SVGPathSegLinetoRel(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegLinetoRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegLinetoRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoCubicAbs=function(t,e,n,i,o,r,s){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS,"C",t),this._x=e,this._y=n,this._x1=i,this._y1=o,this._x2=r,this._y2=s},window.SVGPathSegCurvetoCubicAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoCubicAbs.prototype.toString=function(){return"[object SVGPathSegCurvetoCubicAbs]"},window.SVGPathSegCurvetoCubicAbs.prototype._asPathString=function(){return`${this.pathSegTypeAsLetter} ${this._x1} ${this._y1} ${this._x2} ${this._y2} ${this._x} ${this._y}`},window.SVGPathSegCurvetoCubicAbs.prototype.clone=function(){return new window.SVGPathSegCurvetoCubicAbs(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)},Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"x1",{get:function(){return this._x1},set:function(t){this._x1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"y1",{get:function(){return this._y1},set:function(t){this._y1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"x2",{get:function(){return this._x2},set:function(t){this._x2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicAbs.prototype,"y2",{get:function(){return this._y2},set:function(t){this._y2=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoCubicRel=function(t,e,n,i,o,r,s){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL,"c",t),this._x=e,this._y=n,this._x1=i,this._y1=o,this._x2=r,this._y2=s},window.SVGPathSegCurvetoCubicRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoCubicRel.prototype.toString=function(){return"[object SVGPathSegCurvetoCubicRel]"},window.SVGPathSegCurvetoCubicRel.prototype._asPathString=function(){return`${this.pathSegTypeAsLetter} ${this._x1} ${this._y1} ${this._x2} ${this._y2} ${this._x} ${this._y}`},window.SVGPathSegCurvetoCubicRel.prototype.clone=function(){return new window.SVGPathSegCurvetoCubicRel(void 0,this._x,this._y,this._x1,this._y1,this._x2,this._y2)},Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"x1",{get:function(){return this._x1},set:function(t){this._x1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"y1",{get:function(){return this._y1},set:function(t){this._y1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"x2",{get:function(){return this._x2},set:function(t){this._x2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicRel.prototype,"y2",{get:function(){return this._y2},set:function(t){this._y2=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoQuadraticAbs=function(t,e,n,i,o){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS,"Q",t),this._x=e,this._y=n,this._x1=i,this._y1=o},window.SVGPathSegCurvetoQuadraticAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoQuadraticAbs.prototype.toString=function(){return"[object SVGPathSegCurvetoQuadraticAbs]"},window.SVGPathSegCurvetoQuadraticAbs.prototype._asPathString=function(){return`${this.pathSegTypeAsLetter} ${this._x1} ${this._y1} ${this._x} ${this._y}`},window.SVGPathSegCurvetoQuadraticAbs.prototype.clone=function(){return new window.SVGPathSegCurvetoQuadraticAbs(void 0,this._x,this._y,this._x1,this._y1)},Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype,"x1",{get:function(){return this._x1},set:function(t){this._x1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticAbs.prototype,"y1",{get:function(){return this._y1},set:function(t){this._y1=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoQuadraticRel=function(t,e,n,i,o){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL,"q",t),this._x=e,this._y=n,this._x1=i,this._y1=o},window.SVGPathSegCurvetoQuadraticRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoQuadraticRel.prototype.toString=function(){return"[object SVGPathSegCurvetoQuadraticRel]"},window.SVGPathSegCurvetoQuadraticRel.prototype._asPathString=function(){return`${this.pathSegTypeAsLetter} ${this._x1} ${this._y1} ${this._x} ${this._y}`},window.SVGPathSegCurvetoQuadraticRel.prototype.clone=function(){return new window.SVGPathSegCurvetoQuadraticRel(void 0,this._x,this._y,this._x1,this._y1)},Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype,"x1",{get:function(){return this._x1},set:function(t){this._x1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticRel.prototype,"y1",{get:function(){return this._y1},set:function(t){this._y1=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegArcAbs=function(t,e,n,i,o,r,s,h){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_ARC_ABS,"A",t),this._x=e,this._y=n,this._r1=i,this._r2=o,this._angle=r,this._largeArcFlag=s,this._sweepFlag=h},window.SVGPathSegArcAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegArcAbs.prototype.toString=function(){return"[object SVGPathSegArcAbs]"},window.SVGPathSegArcAbs.prototype._asPathString=function(){return`${this.pathSegTypeAsLetter} ${this._r1} ${this._r2} ${this._angle} ${this._largeArcFlag?"1":"0"} ${this._sweepFlag?"1":"0"} ${this._x} ${this._y}`},window.SVGPathSegArcAbs.prototype.clone=function(){return new window.SVGPathSegArcAbs(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)},Object.defineProperty(window.SVGPathSegArcAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"r1",{get:function(){return this._r1},set:function(t){this._r1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"r2",{get:function(){return this._r2},set:function(t){this._r2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"angle",{get:function(){return this._angle},set:function(t){this._angle=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"largeArcFlag",{get:function(){return this._largeArcFlag},set:function(t){this._largeArcFlag=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcAbs.prototype,"sweepFlag",{get:function(){return this._sweepFlag},set:function(t){this._sweepFlag=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegArcRel=function(t,e,n,i,o,r,s,h){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_ARC_REL,"a",t),this._x=e,this._y=n,this._r1=i,this._r2=o,this._angle=r,this._largeArcFlag=s,this._sweepFlag=h},window.SVGPathSegArcRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegArcRel.prototype.toString=function(){return"[object SVGPathSegArcRel]"},window.SVGPathSegArcRel.prototype._asPathString=function(){return`${this.pathSegTypeAsLetter} ${this._r1} ${this._r2} ${this._angle} ${this._largeArcFlag?"1":"0"} ${this._sweepFlag?"1":"0"} ${this._x} ${this._y}`},window.SVGPathSegArcRel.prototype.clone=function(){return new window.SVGPathSegArcRel(void 0,this._x,this._y,this._r1,this._r2,this._angle,this._largeArcFlag,this._sweepFlag)},Object.defineProperty(window.SVGPathSegArcRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"r1",{get:function(){return this._r1},set:function(t){this._r1=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"r2",{get:function(){return this._r2},set:function(t){this._r2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"angle",{get:function(){return this._angle},set:function(t){this._angle=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"largeArcFlag",{get:function(){return this._largeArcFlag},set:function(t){this._largeArcFlag=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegArcRel.prototype,"sweepFlag",{get:function(){return this._sweepFlag},set:function(t){this._sweepFlag=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoHorizontalAbs=function(t,e){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS,"H",t),this._x=e},window.SVGPathSegLinetoHorizontalAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoHorizontalAbs.prototype.toString=function(){return"[object SVGPathSegLinetoHorizontalAbs]"},window.SVGPathSegLinetoHorizontalAbs.prototype._asPathString=function(){return`${this.pathSegTypeAsLetter} ${this._x}`},window.SVGPathSegLinetoHorizontalAbs.prototype.clone=function(){return new window.SVGPathSegLinetoHorizontalAbs(void 0,this._x)},Object.defineProperty(window.SVGPathSegLinetoHorizontalAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoHorizontalRel=function(t,e){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL,"h",t),this._x=e},window.SVGPathSegLinetoHorizontalRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoHorizontalRel.prototype.toString=function(){return"[object SVGPathSegLinetoHorizontalRel]"},window.SVGPathSegLinetoHorizontalRel.prototype._asPathString=function(){return`${this.pathSegTypeAsLetter} ${this._x}`},window.SVGPathSegLinetoHorizontalRel.prototype.clone=function(){return new window.SVGPathSegLinetoHorizontalRel(void 0,this._x)},Object.defineProperty(window.SVGPathSegLinetoHorizontalRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoVerticalAbs=function(t,e){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS,"V",t),this._y=e},window.SVGPathSegLinetoVerticalAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoVerticalAbs.prototype.toString=function(){return"[object SVGPathSegLinetoVerticalAbs]"},window.SVGPathSegLinetoVerticalAbs.prototype._asPathString=function(){return`${this.pathSegTypeAsLetter} ${this._y}`},window.SVGPathSegLinetoVerticalAbs.prototype.clone=function(){return new window.SVGPathSegLinetoVerticalAbs(void 0,this._y)},Object.defineProperty(window.SVGPathSegLinetoVerticalAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegLinetoVerticalRel=function(t,e){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL,"v",t),this._y=e},window.SVGPathSegLinetoVerticalRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegLinetoVerticalRel.prototype.toString=function(){return"[object SVGPathSegLinetoVerticalRel]"},window.SVGPathSegLinetoVerticalRel.prototype._asPathString=function(){return`${this.pathSegTypeAsLetter} ${this._y}`},window.SVGPathSegLinetoVerticalRel.prototype.clone=function(){return new window.SVGPathSegLinetoVerticalRel(void 0,this._y)},Object.defineProperty(window.SVGPathSegLinetoVerticalRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoCubicSmoothAbs=function(t,e,n,i,o){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS,"S",t),this._x=e,this._y=n,this._x2=i,this._y2=o},window.SVGPathSegCurvetoCubicSmoothAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoCubicSmoothAbs.prototype.toString=function(){return"[object SVGPathSegCurvetoCubicSmoothAbs]"},window.SVGPathSegCurvetoCubicSmoothAbs.prototype._asPathString=function(){return`${this.pathSegTypeAsLetter} ${this._x2} ${this._y2} ${this._x} ${this._y}`},window.SVGPathSegCurvetoCubicSmoothAbs.prototype.clone=function(){return new window.SVGPathSegCurvetoCubicSmoothAbs(void 0,this._x,this._y,this._x2,this._y2)},Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype,"x2",{get:function(){return this._x2},set:function(t){this._x2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothAbs.prototype,"y2",{get:function(){return this._y2},set:function(t){this._y2=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoCubicSmoothRel=function(t,e,n,i,o){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL,"s",t),this._x=e,this._y=n,this._x2=i,this._y2=o},window.SVGPathSegCurvetoCubicSmoothRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoCubicSmoothRel.prototype.toString=function(){return"[object SVGPathSegCurvetoCubicSmoothRel]"},window.SVGPathSegCurvetoCubicSmoothRel.prototype._asPathString=function(){return`${this.pathSegTypeAsLetter} ${this._x2} ${this._y2} ${this._x} ${this._y}`},window.SVGPathSegCurvetoCubicSmoothRel.prototype.clone=function(){return new window.SVGPathSegCurvetoCubicSmoothRel(void 0,this._x,this._y,this._x2,this._y2)},Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype,"x2",{get:function(){return this._x2},set:function(t){this._x2=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoCubicSmoothRel.prototype,"y2",{get:function(){return this._y2},set:function(t){this._y2=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoQuadraticSmoothAbs=function(t,e,n){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS,"T",t),this._x=e,this._y=n},window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype.toString=function(){return"[object SVGPathSegCurvetoQuadraticSmoothAbs]"},window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype._asPathString=function(){return`${this.pathSegTypeAsLetter} ${this._x} ${this._y}`},window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype.clone=function(){return new window.SVGPathSegCurvetoQuadraticSmoothAbs(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothAbs.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathSegCurvetoQuadraticSmoothRel=function(t,e,n){window.SVGPathSeg.call(this,window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL,"t",t),this._x=e,this._y=n},window.SVGPathSegCurvetoQuadraticSmoothRel.prototype=Object.create(window.SVGPathSeg.prototype),window.SVGPathSegCurvetoQuadraticSmoothRel.prototype.toString=function(){return"[object SVGPathSegCurvetoQuadraticSmoothRel]"},window.SVGPathSegCurvetoQuadraticSmoothRel.prototype._asPathString=function(){return`${this.pathSegTypeAsLetter} ${this._x} ${this._y}`},window.SVGPathSegCurvetoQuadraticSmoothRel.prototype.clone=function(){return new window.SVGPathSegCurvetoQuadraticSmoothRel(void 0,this._x,this._y)},Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothRel.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._segmentChanged()},enumerable:!0}),Object.defineProperty(window.SVGPathSegCurvetoQuadraticSmoothRel.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._segmentChanged()},enumerable:!0}),window.SVGPathElement.prototype.createSVGPathSegClosePath=function(){return new window.SVGPathSegClosePath(void 0)},window.SVGPathElement.prototype.createSVGPathSegMovetoAbs=function(t,e){return new window.SVGPathSegMovetoAbs(void 0,t,e)},window.SVGPathElement.prototype.createSVGPathSegMovetoRel=function(t,e){return new window.SVGPathSegMovetoRel(void 0,t,e)},window.SVGPathElement.prototype.createSVGPathSegLinetoAbs=function(t,e){return new window.SVGPathSegLinetoAbs(void 0,t,e)},window.SVGPathElement.prototype.createSVGPathSegLinetoRel=function(t,e){return new window.SVGPathSegLinetoRel(void 0,t,e)},window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicAbs=function(t,e,n,i,o,r){return new window.SVGPathSegCurvetoCubicAbs(void 0,t,e,n,i,o,r)},window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicRel=function(t,e,n,i,o,r){return new window.SVGPathSegCurvetoCubicRel(void 0,t,e,n,i,o,r)},window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticAbs=function(t,e,n,i){return new window.SVGPathSegCurvetoQuadraticAbs(void 0,t,e,n,i)},window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticRel=function(t,e,n,i){return new window.SVGPathSegCurvetoQuadraticRel(void 0,t,e,n,i)},window.SVGPathElement.prototype.createSVGPathSegArcAbs=function(t,e,n,i,o,r,s){return new window.SVGPathSegArcAbs(void 0,t,e,n,i,o,r,s)},window.SVGPathElement.prototype.createSVGPathSegArcRel=function(t,e,n,i,o,r,s){return new window.SVGPathSegArcRel(void 0,t,e,n,i,o,r,s)},window.SVGPathElement.prototype.createSVGPathSegLinetoHorizontalAbs=function(t){return new window.SVGPathSegLinetoHorizontalAbs(void 0,t)},window.SVGPathElement.prototype.createSVGPathSegLinetoHorizontalRel=function(t){return new window.SVGPathSegLinetoHorizontalRel(void 0,t)},window.SVGPathElement.prototype.createSVGPathSegLinetoVerticalAbs=function(t){return new window.SVGPathSegLinetoVerticalAbs(void 0,t)},window.SVGPathElement.prototype.createSVGPathSegLinetoVerticalRel=function(t){return new window.SVGPathSegLinetoVerticalRel(void 0,t)},window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothAbs=function(t,e,n,i){return new window.SVGPathSegCurvetoCubicSmoothAbs(void 0,t,e,n,i)},window.SVGPathElement.prototype.createSVGPathSegCurvetoCubicSmoothRel=function(t,e,n,i){return new window.SVGPathSegCurvetoCubicSmoothRel(void 0,t,e,n,i)},window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothAbs=function(t,e){return new window.SVGPathSegCurvetoQuadraticSmoothAbs(void 0,t,e)},window.SVGPathElement.prototype.createSVGPathSegCurvetoQuadraticSmoothRel=function(t,e){return new window.SVGPathSegCurvetoQuadraticSmoothRel(void 0,t,e)},"getPathSegAtLength"in window.SVGPathElement.prototype||(window.SVGPathElement.prototype.getPathSegAtLength=function(t){if(void 0===t||!isFinite(t))throw"Invalid arguments.";const e=document.createElementNS("http://www.w3.org/2000/svg","path");e.setAttribute("d",this.getAttribute("d"));let n=e.pathSegList.numberOfItems-1;if(n<=0)return 0;do{if(e.pathSegList.removeItem(n),t>e.getTotalLength())break;n--}while(n>0);return n})),"SVGPathSegList"in window&&"appendItem"in window.SVGPathSegList.prototype||(window.SVGPathSegList=function(t){this._pathElement=t,this._list=this._parsePath(this._pathElement.getAttribute("d")),this._mutationObserverConfig={attributes:!0,attributeFilter:["d"]},this._pathElementMutationObserver=new MutationObserver(this._updateListFromPathMutations.bind(this)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)},window.SVGPathSegList.prototype.classname="SVGPathSegList",Object.defineProperty(window.SVGPathSegList.prototype,"numberOfItems",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),Object.defineProperty(window.SVGPathSegList.prototype,"length",{get:function(){return this._checkPathSynchronizedToList(),this._list.length},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"pathSegList",{get:function(){return this._pathSegList||(this._pathSegList=new window.SVGPathSegList(this)),this._pathSegList},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"normalizedPathSegList",{get:function(){return this.pathSegList},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"animatedPathSegList",{get:function(){return this.pathSegList},enumerable:!0}),Object.defineProperty(window.SVGPathElement.prototype,"animatedNormalizedPathSegList",{get:function(){return this.pathSegList},enumerable:!0}),window.SVGPathSegList.prototype._checkPathSynchronizedToList=function(){this._updateListFromPathMutations(this._pathElementMutationObserver.takeRecords())},window.SVGPathSegList.prototype._updateListFromPathMutations=function(t){if(!this._pathElement)return;let e=!1;t.forEach((function(t){"d"==t.attributeName&&(e=!0)})),e&&(this._list=this._parsePath(this._pathElement.getAttribute("d")))},window.SVGPathSegList.prototype._writeListToPath=function(){this._pathElementMutationObserver.disconnect(),this._pathElement.setAttribute("d",window.SVGPathSegList._pathSegArrayAsString(this._list)),this._pathElementMutationObserver.observe(this._pathElement,this._mutationObserverConfig)},window.SVGPathSegList.prototype.segmentChanged=function(){this._writeListToPath()},window.SVGPathSegList.prototype.clear=function(){this._checkPathSynchronizedToList(),this._list.forEach((function(t){t._owningPathSegList=null})),this._list=[],this._writeListToPath()},window.SVGPathSegList.prototype.initialize=function(t){return this._checkPathSynchronizedToList(),this._list=[t],t._owningPathSegList=this,this._writeListToPath(),t},window.SVGPathSegList.prototype._checkValidIndex=function(t){if(isNaN(t)||t<0||t>=this.numberOfItems)throw"INDEX_SIZE_ERR"},window.SVGPathSegList.prototype.getItem=function(t){return this._checkPathSynchronizedToList(),this._checkValidIndex(t),this._list[t]},window.SVGPathSegList.prototype.insertItemBefore=function(t,e){return this._checkPathSynchronizedToList(),e>this.numberOfItems&&(e=this.numberOfItems),t._owningPathSegList&&(t=t.clone()),this._list.splice(e,0,t),t._owningPathSegList=this,this._writeListToPath(),t},window.SVGPathSegList.prototype.replaceItem=function(t,e){return this._checkPathSynchronizedToList(),t._owningPathSegList&&(t=t.clone()),this._checkValidIndex(e),this._list[e]=t,t._owningPathSegList=this,this._writeListToPath(),t},window.SVGPathSegList.prototype.removeItem=function(t){this._checkPathSynchronizedToList(),this._checkValidIndex(t);const e=this._list[t];return this._list.splice(t,1),this._writeListToPath(),e},window.SVGPathSegList.prototype.appendItem=function(t){return this._checkPathSynchronizedToList(),t._owningPathSegList&&(t=t.clone()),this._list.push(t),t._owningPathSegList=this,this._writeListToPath(),t},window.SVGPathSegList._pathSegArrayAsString=function(t){let e="",n=!0;return t.forEach((function(t){n?(n=!1,e+=t._asPathString()):e+=` ${t._asPathString()}`})),e},window.SVGPathSegList.prototype._parsePath=function(t){if(!t?.length)return[];const e=this,n=function(){this.pathSegList=[]};n.prototype.appendSegment=function(t){this.pathSegList.push(t)};const i=function(t){this._string=t,this._currentIndex=0,this._endIndex=this._string.length,this._previousCommand=window.SVGPathSeg.PATHSEG_UNKNOWN,this._skipOptionalSpaces()};i.prototype._isCurrentSpace=function(){const t=this._string[this._currentIndex];return t<=" "&&(" "==t||"\n"==t||"\t"==t||"\r"==t||"\f"==t)},i.prototype._skipOptionalSpaces=function(){for(;this._currentIndex<this._endIndex&&this._isCurrentSpace();)this._currentIndex++;return this._currentIndex<this._endIndex},i.prototype._skipOptionalSpacesOrDelimiter=function(){return!(this._currentIndex<this._endIndex&&!this._isCurrentSpace()&&","!=this._string.charAt(this._currentIndex))&&(this._skipOptionalSpaces()&&this._currentIndex<this._endIndex&&","==this._string.charAt(this._currentIndex)&&(this._currentIndex++,this._skipOptionalSpaces()),this._currentIndex<this._endIndex)},i.prototype.hasMoreData=function(){return this._currentIndex<this._endIndex},i.prototype.peekSegmentType=function(){const t=this._string[this._currentIndex];return this._pathSegTypeFromChar(t)},i.prototype._pathSegTypeFromChar=function(t){switch(t){case"Z":case"z":return window.SVGPathSeg.PATHSEG_CLOSEPATH;case"M":return window.SVGPathSeg.PATHSEG_MOVETO_ABS;case"m":return window.SVGPathSeg.PATHSEG_MOVETO_REL;case"L":return window.SVGPathSeg.PATHSEG_LINETO_ABS;case"l":return window.SVGPathSeg.PATHSEG_LINETO_REL;case"C":return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS;case"c":return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL;case"Q":return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS;case"q":return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL;case"A":return window.SVGPathSeg.PATHSEG_ARC_ABS;case"a":return window.SVGPathSeg.PATHSEG_ARC_REL;case"H":return window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS;case"h":return window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL;case"V":return window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS;case"v":return window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL;case"S":return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;case"s":return window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;case"T":return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;case"t":return window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;default:return window.SVGPathSeg.PATHSEG_UNKNOWN}},i.prototype._nextCommandHelper=function(t,e){return("+"==t||"-"==t||"."==t||t>="0"&&t<="9")&&e!=window.SVGPathSeg.PATHSEG_CLOSEPATH?e==window.SVGPathSeg.PATHSEG_MOVETO_ABS?window.SVGPathSeg.PATHSEG_LINETO_ABS:e==window.SVGPathSeg.PATHSEG_MOVETO_REL?window.SVGPathSeg.PATHSEG_LINETO_REL:e:window.SVGPathSeg.PATHSEG_UNKNOWN},i.prototype.initialCommandIsMoveTo=function(){if(!this.hasMoreData())return!0;const t=this.peekSegmentType();return t==window.SVGPathSeg.PATHSEG_MOVETO_ABS||t==window.SVGPathSeg.PATHSEG_MOVETO_REL},i.prototype._parseNumber=function(){let t=0,e=0,n=1,i=0,o=1,r=1;const s=this._currentIndex;if(this._skipOptionalSpaces(),this._currentIndex<this._endIndex&&"+"==this._string.charAt(this._currentIndex)?this._currentIndex++:this._currentIndex<this._endIndex&&"-"==this._string.charAt(this._currentIndex)&&(this._currentIndex++,o=-1),this._currentIndex==this._endIndex||(this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")&&"."!=this._string.charAt(this._currentIndex))return;const h=this._currentIndex;for(;this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)>="0"&&this._string.charAt(this._currentIndex)<="9";)this._currentIndex++;if(this._currentIndex!=h){let t=this._currentIndex-1,n=1;for(;t>=h;)e+=n*(this._string.charAt(t--)-"0"),n*=10}if(this._currentIndex<this._endIndex&&"."==this._string.charAt(this._currentIndex)){if(this._currentIndex++,this._currentIndex>=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)>="0"&&this._string.charAt(this._currentIndex)<="9";)n*=10,i+=(this._string.charAt(this._currentIndex)-"0")/n,this._currentIndex+=1}if(this._currentIndex!=s&&this._currentIndex+1<this._endIndex&&("e"==this._string.charAt(this._currentIndex)||"E"==this._string.charAt(this._currentIndex))&&"x"!=this._string.charAt(this._currentIndex+1)&&"m"!=this._string.charAt(this._currentIndex+1)){if(this._currentIndex++,"+"==this._string.charAt(this._currentIndex)?this._currentIndex++:"-"==this._string.charAt(this._currentIndex)&&(this._currentIndex++,r=-1),this._currentIndex>=this._endIndex||this._string.charAt(this._currentIndex)<"0"||this._string.charAt(this._currentIndex)>"9")return;for(;this._currentIndex<this._endIndex&&this._string.charAt(this._currentIndex)>="0"&&this._string.charAt(this._currentIndex)<="9";)t*=10,t+=this._string.charAt(this._currentIndex)-"0",this._currentIndex++}let a=e+i;return a*=o,t&&(a*=Math.pow(10,r*t)),s!=this._currentIndex?(this._skipOptionalSpacesOrDelimiter(),a):void 0},i.prototype._parseArcFlag=function(){if(this._currentIndex>=this._endIndex)return;let t=!1;const e=this._string.charAt(this._currentIndex++);if("0"==e)t=!1;else{if("1"!=e)return;t=!0}return this._skipOptionalSpacesOrDelimiter(),t},i.prototype.parseSegment=function(){const t=this._string[this._currentIndex];let n,i=this._pathSegTypeFromChar(t);if(i==window.SVGPathSeg.PATHSEG_UNKNOWN){if(this._previousCommand==window.SVGPathSeg.PATHSEG_UNKNOWN)return null;if(i=this._nextCommandHelper(t,this._previousCommand),i==window.SVGPathSeg.PATHSEG_UNKNOWN)return null}else this._currentIndex++;switch(this._previousCommand=i,i){case window.SVGPathSeg.PATHSEG_MOVETO_REL:return new window.SVGPathSegMovetoRel(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_MOVETO_ABS:return new window.SVGPathSegMovetoAbs(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_REL:return new window.SVGPathSegLinetoRel(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_ABS:return new window.SVGPathSegLinetoAbs(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:return new window.SVGPathSegLinetoHorizontalRel(e,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:return new window.SVGPathSegLinetoHorizontalAbs(e,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:return new window.SVGPathSegLinetoVerticalRel(e,this._parseNumber());case window.SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:return new window.SVGPathSegLinetoVerticalAbs(e,this._parseNumber());case window.SVGPathSeg.PATHSEG_CLOSEPATH:return this._skipOptionalSpaces(),new window.SVGPathSegClosePath(e);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:return n={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoCubicRel(e,n.x,n.y,n.x1,n.y1,n.x2,n.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:return n={x1:this._parseNumber(),y1:this._parseNumber(),x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoCubicAbs(e,n.x,n.y,n.x1,n.y1,n.x2,n.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:return n={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoCubicSmoothRel(e,n.x,n.y,n.x2,n.y2);case window.SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:return n={x2:this._parseNumber(),y2:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoCubicSmoothAbs(e,n.x,n.y,n.x2,n.y2);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:return n={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoQuadraticRel(e,n.x,n.y,n.x1,n.y1);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:return n={x1:this._parseNumber(),y1:this._parseNumber(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegCurvetoQuadraticAbs(e,n.x,n.y,n.x1,n.y1);case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:return new window.SVGPathSegCurvetoQuadraticSmoothRel(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:return new window.SVGPathSegCurvetoQuadraticSmoothAbs(e,this._parseNumber(),this._parseNumber());case window.SVGPathSeg.PATHSEG_ARC_REL:return n={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegArcRel(e,n.x,n.y,n.x1,n.y1,n.arcAngle,n.arcLarge,n.arcSweep);case window.SVGPathSeg.PATHSEG_ARC_ABS:return n={x1:this._parseNumber(),y1:this._parseNumber(),arcAngle:this._parseNumber(),arcLarge:this._parseArcFlag(),arcSweep:this._parseArcFlag(),x:this._parseNumber(),y:this._parseNumber()},new window.SVGPathSegArcAbs(e,n.x,n.y,n.x1,n.y1,n.arcAngle,n.arcLarge,n.arcSweep);default:throw"Unknown path seg type."}};const o=new n,r=new i(t);if(!r.initialCommandIsMoveTo())return[];for(;r.hasMoreData();){const t=r.parseSegment();if(!t)return[];o.appendSegment(t)}return o.pathSegList})}catch(t){console.warn("An error occurred in tsParticles pathseg polyfill. If the Polygon Mask is not working, please open an issue here: https://github.com/tsparticles/tsparticles",t)}}();const w=0,g=1;function d(t,e,n,o,r=!1){const s=(0,i.rangeColorToRgb)(t,o.color);if(!s)return;const h=n[0];if(h){e.beginPath(),e.moveTo(h.x,h.y);for(const t of n)e.lineTo(t.x,t.y);e.closePath(),e.strokeStyle=(0,i.getStyleFromRgb)(s,r),e.lineWidth=o.width,e.stroke()}}function p(t,e,n,o,r,s=!1){const h=1,a=0,S=0,c=1;e.setTransform(h,a,S,c,r.x,r.y);const u=(0,i.rangeColorToRgb)(t,o.color);u&&(e.strokeStyle=(0,i.getStyleFromRgb)(u,s,o.opacity),e.lineWidth=o.width,e.stroke(n),e.resetTransform())}function P(t,e,n){const{dx:o,dy:r}=(0,i.getDistances)(n,t),{dx:s,dy:h}=(0,i.getDistances)(e,t),a=(o*s+r*h)/(s**2+h**2),S={x:t.x+s*a,y:t.y+h*a,isOnSegment:a>=w&&a<=g};return a<w?(S.x=t.x,S.y=t.y):a>g&&(S.x=e.x,S.y=e.y),S}function l(t,e,n){const{dx:o,dy:r}=(0,i.getDistances)(t,e),s=Math.atan2(r,o),h=i.Vector.create(Math.sin(s),-Math.cos(s)),a=2*(n.x*h.x+n.y*h.y);h.multTo(a),n.subFrom(h)}const y="No polygon data loaded.",G=0,V=0,A=.5;class b{constructor(t,e){this._checkInsidePolygon=t=>{const e=this._container,n=e.actualOptions.polygon;if(!n?.enable||n.type===u.T.none||n.type===u.T.inline)return!0;if(!this.raw)throw new Error("No polygon found, you need to specify SVG url in config.");const o=e.canvas.size,r=t?.x??(0,i.getRandom)()*o.width,s=t?.y??(0,i.getRandom)()*o.height;let h=!1;for(let t=0,e=this.raw.length-1;t<this.raw.length;e=t++){const n=this.raw[t],i=this.raw[e];if(!n||!i)continue;n.y>s!=i.y>s&&r<(i.x-n.x)*(s-n.y)/(i.y-n.y)+n.x&&(h=!h)}return n.type===u.T.inside?h:!h},this._createPath2D=()=>{if(this._container.actualOptions.polygon&&this.paths?.length)for(const t of this.paths){const e=t.element.getAttribute("d");if(e){const n=new Path2D(e),o=(0,i.safeDocument)().createElementNS("http://www.w3.org/2000/svg","svg").createSVGMatrix(),r=new Path2D,s=o.scale(this._scale);r.addPath(n,s),t.path2d=r}else delete t.path2d;if(t.path2d??!this.raw)continue;t.path2d=new Path2D;const n=0,o=this.raw[n];o&&(t.path2d.moveTo(o.x,o.y),this.raw.forEach(((e,i)=>{i>n&&t.path2d?.lineTo(e.x,e.y)})),t.path2d.closePath())}},this._downloadSvgPath=async(t,e)=>{const n=this._container.actualOptions.polygon;if(!n)return;const i=t??n.url,o=e??!1;if(!i||void 0!==this.paths&&!o)return this.raw;const r=await fetch(i);if(!r.ok)throw new Error("Error occurred during polygon mask download");return this._parseSvgPath(await r.text(),e)},this._drawPoints=()=>{if(this.raw)for(const t of this.raw)this._container.particles.addParticle({x:t.x,y:t.y})},this._getEquidistantPointByIndex=t=>{const e=this._container.actualOptions;if(!e.polygon)return;if(!this.raw?.length||!this.paths?.length)throw new Error(y);let n,i=0;const o=this.paths.reduce(((t,e)=>t+e.length),0)/e.particles.number.value;for(const e of this.paths){const r=o*t-i;if(r<=e.length){n=e.element.getPointAtLength(r);break}i+=e.length}const r=this._scale;return{x:(n?.x??G)*r+(this.offset?.x??G),y:(n?.y??V)*r+(this.offset?.y??V)}},this._getPointByIndex=t=>{if(!this.raw?.length)throw new Error(y);const e=this.raw[t%this.raw.length];if(e)return{x:e.x,y:e.y}},this._getRandomPoint=()=>{if(!this.raw?.length)throw new Error(y);const t=(0,i.itemFromArray)(this.raw);if(t)return{x:t.x,y:t.y}},this._getRandomPointByLength=()=>{if(!this._container.actualOptions.polygon)return;if(!this.raw?.length||!this.paths?.length)throw new Error(y);const t=(0,i.itemFromArray)(this.paths);if(!t)return;const e=Math.floor((0,i.getRandom)()*t.length)+1,n=t.element.getPointAtLength(e),o=this._scale;return{x:n.x*o+(this.offset?.x??G),y:n.y*o+(this.offset?.y??V)}},this._initRawData=async t=>{const e=this._container.actualOptions.polygon;if(e){if(e.url)this.raw=await this._downloadSvgPath(e.url,t);else if(e.data){const n=e.data;let o;if((0,i.isString)(n))o=n;else{const t=t=>`<path d="${t}" />`,e=(0,i.isArray)(n.path)?n.path.map(t).join(""):t(n.path);o=`<svg ${'xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"'} width="${n.size.width.toString()}" height="${n.size.height.toString()}">${e}</svg>`}this.raw=this._parseSvgPath(o,t)}this._createPath2D(),this._engine.dispatchEvent("polygonMaskLoaded",{container:this._container})}},this._parseSvgPath=(t,e)=>{const n=e??!1;if(void 0!==this.paths&&!n)return this.raw;const o=this._container,r=o.actualOptions.polygon;if(!r)return;const s=(new DOMParser).parseFromString(t,"image/svg+xml"),h=s.getElementsByTagName("svg")[0];if(!h)return;let a=h.getElementsByTagName("path");a.length||(a=s.getElementsByTagName("path")),this.paths=[];for(let t=0;t<a.length;t++){const e=a.item(t);e&&this.paths.push({element:e,length:e.getTotalLength()})}const S=this._scale;this.dimension.width=parseFloat(h.getAttribute("width")??"0")*S,this.dimension.height=parseFloat(h.getAttribute("height")??"0")*S;const c=r.position??{x:50,y:50},u=o.canvas.size;return this.offset={x:u.width*c.x/i.percentDenominator-this.dimension.width*A,y:u.height*c.y/i.percentDenominator-this.dimension.height*A},function(t,e,n){const i=[];for(const o of t){const t=o.element.pathSegList,r=t?.numberOfItems??0,s={x:0,y:0};for(let o=0;o<r;o++){const r=t?.getItem(o),h=globalThis.SVGPathSeg;switch(r?.pathSegType){case h.PATHSEG_MOVETO_ABS:case h.PATHSEG_LINETO_ABS:case h.PATHSEG_CURVETO_CUBIC_ABS:case h.PATHSEG_CURVETO_QUADRATIC_ABS:case h.PATHSEG_ARC_ABS:case h.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:case h.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:{const t=r;s.x=t.x,s.y=t.y;break}case h.PATHSEG_LINETO_HORIZONTAL_ABS:s.x=r.x;break;case h.PATHSEG_LINETO_VERTICAL_ABS:s.y=r.y;break;case h.PATHSEG_LINETO_REL:case h.PATHSEG_MOVETO_REL:case h.PATHSEG_CURVETO_CUBIC_REL:case h.PATHSEG_CURVETO_QUADRATIC_REL:case h.PATHSEG_ARC_REL:case h.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:case h.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:{const t=r;s.x+=t.x,s.y+=t.y;break}case h.PATHSEG_LINETO_HORIZONTAL_REL:s.x+=r.x;break;case h.PATHSEG_LINETO_VERTICAL_REL:s.y+=r.y;break;case h.PATHSEG_UNKNOWN:case h.PATHSEG_CLOSEPATH:continue}i.push({x:s.x*e+n.x,y:s.y*e+n.y})}}return i}(this.paths,S,this.offset)},this._polygonBounce=(t,e,n)=>{const o=this._container.actualOptions.polygon;if(!this.raw||!o?.enable||n!==i.OutModeDirection.top)return!1;if(o.type===u.T.inside||o.type===u.T.outside){let e,n,o;const r=t.getPosition(),s=t.getRadius(),h=1;for(let a=0,S=this.raw.length-h;a<this.raw.length;S=a++){const h=this.raw[a],c=this.raw[S];if(!h||!c)continue;e=P(h,c,r);const u=(0,i.getDistances)(r,e);if([n,o]=[u.dx,u.dy],u.distance<s)return l(h,c,t.velocity),!0}if(e&&void 0!==n&&void 0!==o&&!this._checkInsidePolygon(r)){const n={x:1,y:1},i=2*s,o=-1;return r.x>=e.x&&(n.x=-1),r.y>=e.y&&(n.y=-1),t.position.x=e.x+i*n.x,t.position.y=e.y+i*n.y,t.velocity.mult(o),!0}}else if(o.type===u.T.inline){const e=(0,i.getDistance)(t.initialPosition,t.getPosition()),{velocity:n}=t;if(e>this._moveRadius)return n.x=n.y*A-n.x,n.y=n.x*A-n.y,!0}return!1},this._randomPoint=()=>{const t=this._container,e=t.actualOptions.polygon;if(!e)return;let n;if(e.type===u.T.inline)switch(e.inline.arrangement){case s.G.randomPoint:n=this._getRandomPoint();break;case s.G.randomLength:n=this._getRandomPointByLength();break;case s.G.equidistant:n=this._getEquidistantPointByIndex(t.particles.count);break;case s.G.onePerPoint:case s.G.perPoint:default:n=this._getPointByIndex(t.particles.count)}else{const e=t.canvas.size;n={x:(0,i.getRandom)()*e.width,y:(0,i.getRandom)()*e.height}}return this._checkInsidePolygon(n)?n:this._randomPoint()},this._container=t,this._engine=e,this.dimension={height:0,width:0},this._moveRadius=0,this._scale=1}clickPositionValid(t){const e=this._container.actualOptions.polygon;return!!e?.enable&&e.type!==u.T.none&&e.type!==u.T.inline&&this._checkInsidePolygon(t)}draw(t){if(!this.paths?.length)return;const e=this._container.actualOptions.polygon;if(!e?.enable)return;const n=e.draw;if(!n.enable)return;const i=this.raw;for(const e of this.paths){const o=e.path2d;o&&this.offset?p(this._engine,t,o,n.stroke,this.offset,this._container.hdr):i&&d(this._engine,t,i,n.stroke,this._container.hdr)}}async init(){const t=this._container,e=t.actualOptions.polygon,n=t.retina.pixelRatio;e&&(this._moveRadius=e.move.radius*n,this._scale=e.scale*n,e.enable&&await this._initRawData())}particleBounce(t,e,n){return this._polygonBounce(t,e,n)}particlePosition(t){const e=this._container.actualOptions.polygon;if(e?.enable&&(this.raw?.length??0)>0)return(0,i.deepExtend)({},t??this._randomPoint())}particlesInitialization(){const t=this._container.actualOptions.polygon;return!(!t?.enable||t.type!==u.T.inline||t.inline.arrangement!==s.G.onePerPoint&&t.inline.arrangement!==s.G.perPoint)&&(this._drawPoints(),!0)}resize(){const t=this._container,e=t.actualOptions.polygon;if(!e?.enable||e.type===u.T.none)return;this.redrawTimeout&&clearTimeout(this.redrawTimeout);this.redrawTimeout=setTimeout((()=>{(async()=>{await this._initRawData(!0),await t.particles.redraw()})()}),250)}stop(){delete this.raw,delete this.paths}}class f{constructor(t){this.id="polygonMask",this._engine=t}getPlugin(t){return Promise.resolve(new b(t,this._engine))}loadOptions(t,e){if(!this.needsPlugin(t)&&!this.needsPlugin(e))return;let n=t.polygon;void 0===n?.load&&(t.polygon=n=new _(this._engine)),n.load(e?.polygon)}needsPlugin(t){return t?.polygon?.enable??(void 0!==t?.polygon?.type&&t.polygon.type!==u.T.none)}}}}]);
@@ -0,0 +1 @@
1
+ /*! tsParticles Polygon Mask Plugin v4.0.0-alpha.0 by Matteo Bruni */
@@ -1,8 +1,9 @@
1
- import { OutModeDirection, deepExtend, errorPrefix, getDistance, getDistances, getRandom, isArray, isString, itemFromArray, percentDenominator, } from "@tsparticles/engine";
1
+ import "./pathseg.js";
2
+ import { OutModeDirection, deepExtend, getDistance, getDistances, getRandom, isArray, isString, itemFromArray, percentDenominator, safeDocument, } from "@tsparticles/engine";
2
3
  import { calcClosestPointOnSegment, drawPolygonMask, drawPolygonMaskPath, parsePaths, segmentBounce } from "./utils.js";
3
4
  import { PolygonMaskInlineArrangement } from "./Enums/PolygonMaskInlineArrangement.js";
4
5
  import { PolygonMaskType } from "./Enums/PolygonMaskType.js";
5
- const noPolygonDataLoaded = `${errorPrefix} No polygon data loaded.`, noPolygonFound = `${errorPrefix} No polygon found, you need to specify SVG url in config.`, origin = {
6
+ const noPolygonDataLoaded = `No polygon data loaded.`, noPolygonFound = `No polygon found, you need to specify SVG url in config.`, origin = {
6
7
  x: 0,
7
8
  y: 0,
8
9
  }, half = 0.5, double = 2;
@@ -19,7 +20,11 @@ export class PolygonMaskInstance {
19
20
  const canvasSize = container.canvas.size, x = position?.x ?? getRandom() * canvasSize.width, y = position?.y ?? getRandom() * canvasSize.height, indexOffset = 1;
20
21
  let inside = false;
21
22
  for (let i = 0, j = this.raw.length - indexOffset; i < this.raw.length; j = i++) {
22
- const pi = this.raw[i], pj = this.raw[j], intersect = pi.y > y !== pj.y > y && x < ((pj.x - pi.x) * (y - pi.y)) / (pj.y - pi.y) + pi.x;
23
+ const pi = this.raw[i], pj = this.raw[j];
24
+ if (!pi || !pj) {
25
+ continue;
26
+ }
27
+ const intersect = pi.y > y !== pj.y > y && x < ((pj.x - pi.x) * (y - pi.y)) / (pj.y - pi.y) + pi.x;
23
28
  if (intersect) {
24
29
  inside = !inside;
25
30
  }
@@ -28,7 +33,7 @@ export class PolygonMaskInstance {
28
33
  return inside;
29
34
  }
30
35
  else {
31
- return options.type === PolygonMaskType.outside ? !inside : false;
36
+ return !inside;
32
37
  }
33
38
  };
34
39
  this._createPath2D = () => {
@@ -37,16 +42,11 @@ export class PolygonMaskInstance {
37
42
  return;
38
43
  }
39
44
  for (const path of this.paths) {
40
- const pathData = path.element?.getAttribute("d");
45
+ const pathData = path.element.getAttribute("d");
41
46
  if (pathData) {
42
- const path2d = new Path2D(pathData), matrix = document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGMatrix(), finalPath = new Path2D(), transform = matrix.scale(this._scale);
43
- if (finalPath.addPath) {
44
- finalPath.addPath(path2d, transform);
45
- path.path2d = finalPath;
46
- }
47
- else {
48
- delete path.path2d;
49
- }
47
+ const path2d = new Path2D(pathData), matrix = safeDocument().createElementNS("http://www.w3.org/2000/svg", "svg").createSVGMatrix(), finalPath = new Path2D(), transform = matrix.scale(this._scale);
48
+ finalPath.addPath(path2d, transform);
49
+ path.path2d = finalPath;
50
50
  }
51
51
  else {
52
52
  delete path.path2d;
@@ -56,6 +56,9 @@ export class PolygonMaskInstance {
56
56
  }
57
57
  path.path2d = new Path2D();
58
58
  const firstIndex = 0, firstPoint = this.raw[firstIndex];
59
+ if (!firstPoint) {
60
+ continue;
61
+ }
59
62
  path.path2d.moveTo(firstPoint.x, firstPoint.y);
60
63
  this.raw.forEach((pos, i) => {
61
64
  if (i > firstIndex) {
@@ -76,7 +79,7 @@ export class PolygonMaskInstance {
76
79
  }
77
80
  const req = await fetch(url);
78
81
  if (!req.ok) {
79
- throw new Error(`${errorPrefix} occurred during polygon mask download`);
82
+ throw new Error(`Error occurred during polygon mask download`);
80
83
  }
81
84
  return this._parseSvgPath(await req.text(), force);
82
85
  };
@@ -122,6 +125,9 @@ export class PolygonMaskInstance {
122
125
  throw new Error(noPolygonDataLoaded);
123
126
  }
124
127
  const coords = this.raw[index % this.raw.length];
128
+ if (!coords) {
129
+ return;
130
+ }
125
131
  return {
126
132
  x: coords.x,
127
133
  y: coords.y,
@@ -132,6 +138,9 @@ export class PolygonMaskInstance {
132
138
  throw new Error(noPolygonDataLoaded);
133
139
  }
134
140
  const coords = itemFromArray(this.raw);
141
+ if (!coords) {
142
+ return;
143
+ }
135
144
  return {
136
145
  x: coords.x,
137
146
  y: coords.y,
@@ -145,7 +154,11 @@ export class PolygonMaskInstance {
145
154
  if (!this.raw?.length || !this.paths?.length) {
146
155
  throw new Error(noPolygonDataLoaded);
147
156
  }
148
- const path = itemFromArray(this.paths), offset = 1, distance = Math.floor(getRandom() * path.length) + offset, point = path.element.getPointAtLength(distance), scale = this._scale;
157
+ const path = itemFromArray(this.paths);
158
+ if (!path) {
159
+ return;
160
+ }
161
+ const offset = 1, distance = Math.floor(getRandom() * path.length) + offset, point = path.element.getPointAtLength(distance), scale = this._scale;
149
162
  return {
150
163
  x: point.x * scale + (this.offset?.x ?? origin.x),
151
164
  y: point.y * scale + (this.offset?.y ?? origin.y),
@@ -168,7 +181,7 @@ export class PolygonMaskInstance {
168
181
  else {
169
182
  const getPath = (p) => `<path d="${p}" />`, path = isArray(data.path) ? data.path.map(getPath).join("") : getPath(data.path);
170
183
  const namespaces = 'xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"';
171
- svg = `<svg ${namespaces} width="${data.size.width}" height="${data.size.height}">${path}</svg>`;
184
+ svg = `<svg ${namespaces} width="${data.size.width.toString()}" height="${data.size.height.toString()}">${path}</svg>`;
172
185
  }
173
186
  this.raw = this._parseSvgPath(svg, force);
174
187
  }
@@ -187,6 +200,9 @@ export class PolygonMaskInstance {
187
200
  return;
188
201
  }
189
202
  const parser = new DOMParser(), doc = parser.parseFromString(xml, "image/svg+xml"), firstIndex = 0, svg = doc.getElementsByTagName("svg")[firstIndex];
203
+ if (!svg) {
204
+ return;
205
+ }
190
206
  let svgPaths = svg.getElementsByTagName("path");
191
207
  if (!svgPaths.length) {
192
208
  svgPaths = doc.getElementsByTagName("path");
@@ -214,7 +230,7 @@ export class PolygonMaskInstance {
214
230
  };
215
231
  return parsePaths(this.paths, scale, this.offset);
216
232
  };
217
- this._polygonBounce = (particle, delta, direction) => {
233
+ this._polygonBounce = (particle, _delta, direction) => {
218
234
  const options = this._container.actualOptions.polygon;
219
235
  if (!this.raw || !options?.enable || direction !== OutModeDirection.top) {
220
236
  return false;
@@ -224,6 +240,9 @@ export class PolygonMaskInstance {
224
240
  const pos = particle.getPosition(), radius = particle.getRadius(), offset = 1;
225
241
  for (let i = 0, j = this.raw.length - offset; i < this.raw.length; j = i++) {
226
242
  const pi = this.raw[i], pj = this.raw[j];
243
+ if (!pi || !pj) {
244
+ continue;
245
+ }
227
246
  closest = calcClosestPointOnSegment(pi, pj, pos);
228
247
  const dist = getDistances(pos, closest);
229
248
  [dx, dy] = [dist.dx, dist.dy];
@@ -246,7 +265,7 @@ export class PolygonMaskInstance {
246
265
  return true;
247
266
  }
248
267
  }
249
- else if (options.type === PolygonMaskType.inline && particle.initialPosition) {
268
+ else if (options.type === PolygonMaskType.inline) {
250
269
  const dist = getDistance(particle.initialPosition, particle.getPosition()), { velocity } = particle;
251
270
  if (dist > this._moveRadius) {
252
271
  velocity.x = velocity.y * half - velocity.x;
@@ -324,14 +343,11 @@ export class PolygonMaskInstance {
324
343
  const rawData = this.raw;
325
344
  for (const path of this.paths) {
326
345
  const path2d = path.path2d;
327
- if (!context) {
328
- continue;
329
- }
330
346
  if (path2d && this.offset) {
331
- drawPolygonMaskPath(this._engine, context, path2d, polygonDraw.stroke, this.offset);
347
+ drawPolygonMaskPath(this._engine, context, path2d, polygonDraw.stroke, this.offset, this._container.hdr);
332
348
  }
333
349
  else if (rawData) {
334
- drawPolygonMask(this._engine, context, rawData, polygonDraw.stroke);
350
+ drawPolygonMask(this._engine, context, rawData, polygonDraw.stroke, this._container.hdr);
335
351
  }
336
352
  }
337
353
  }
@@ -354,7 +370,7 @@ export class PolygonMaskInstance {
354
370
  if (!(options?.enable && (this.raw?.length ?? defaultLength) > defaultLength)) {
355
371
  return;
356
372
  }
357
- return deepExtend({}, position ? position : this._randomPoint());
373
+ return deepExtend({}, position ?? this._randomPoint());
358
374
  }
359
375
  particlesInitialization() {
360
376
  const options = this._container.actualOptions.polygon;
package/browser/index.js CHANGED
@@ -1,8 +1,9 @@
1
- import "./pathseg.js";
2
- import { PolygonMaskPlugin } from "./PolygonMaskPlugin.js";
3
- export async function loadPolygonMaskPlugin(engine, refresh = true) {
4
- engine.checkVersion("3.9.1");
5
- await engine.addPlugin(new PolygonMaskPlugin(engine), refresh);
1
+ export function loadPolygonMaskPlugin(engine) {
2
+ engine.checkVersion("4.0.0-alpha.0");
3
+ engine.register(async (e) => {
4
+ const { PolygonMaskPlugin } = await import("./PolygonMaskPlugin.js");
5
+ e.addPlugin(new PolygonMaskPlugin(engine));
6
+ });
6
7
  }
7
8
  export * from "./Enums/PolygonMaskInlineArrangement.js";
8
9
  export * from "./Enums/PolygonMaskMoveType.js";
@@ -1147,7 +1147,7 @@
1147
1147
  return string;
1148
1148
  };
1149
1149
  window.SVGPathSegList.prototype._parsePath = function (string) {
1150
- if (!string || !string.length)
1150
+ if (!string?.length)
1151
1151
  return [];
1152
1152
  const owningPathSegList = this;
1153
1153
  const Builder = function () {
package/browser/utils.js CHANGED
@@ -3,23 +3,26 @@ const squareExp = 2, inSegmentRange = {
3
3
  min: 0,
4
4
  max: 1,
5
5
  }, double = 2;
6
- export function drawPolygonMask(engine, context, rawData, stroke) {
6
+ export function drawPolygonMask(engine, context, rawData, stroke, hdr = false) {
7
7
  const color = rangeColorToRgb(engine, stroke.color);
8
8
  if (!color) {
9
9
  return;
10
10
  }
11
11
  const firstIndex = 0, firstItem = rawData[firstIndex];
12
+ if (!firstItem) {
13
+ return;
14
+ }
12
15
  context.beginPath();
13
16
  context.moveTo(firstItem.x, firstItem.y);
14
17
  for (const item of rawData) {
15
18
  context.lineTo(item.x, item.y);
16
19
  }
17
20
  context.closePath();
18
- context.strokeStyle = getStyleFromRgb(color);
21
+ context.strokeStyle = getStyleFromRgb(color, hdr);
19
22
  context.lineWidth = stroke.width;
20
23
  context.stroke();
21
24
  }
22
- export function drawPolygonMaskPath(engine, context, path, stroke, position) {
25
+ export function drawPolygonMaskPath(engine, context, path, stroke, position, hdr = false) {
23
26
  const defaultTransform = {
24
27
  a: 1,
25
28
  b: 0,
@@ -31,7 +34,7 @@ export function drawPolygonMaskPath(engine, context, path, stroke, position) {
31
34
  if (!color) {
32
35
  return;
33
36
  }
34
- context.strokeStyle = getStyleFromRgb(color, stroke.opacity);
37
+ context.strokeStyle = getStyleFromRgb(color, hdr, stroke.opacity);
35
38
  context.lineWidth = stroke.width;
36
39
  context.stroke(path);
37
40
  context.resetTransform();
@@ -44,7 +47,7 @@ export function parsePaths(paths, scale, offset) {
44
47
  y: 0,
45
48
  };
46
49
  for (let i = 0; i < len; i++) {
47
- const segment = segments?.getItem(i), svgPathSeg = window.SVGPathSeg;
50
+ const segment = segments?.getItem(i), svgPathSeg = globalThis.SVGPathSeg;
48
51
  switch (segment?.pathSegType) {
49
52
  case svgPathSeg.PATHSEG_MOVETO_ABS:
50
53
  case svgPathSeg.PATHSEG_LINETO_ABS:
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PolygonMaskInlineArrangement = void 0;
4
- var PolygonMaskInlineArrangement;
1
+ export var PolygonMaskInlineArrangement;
5
2
  (function (PolygonMaskInlineArrangement) {
6
3
  PolygonMaskInlineArrangement["equidistant"] = "equidistant";
7
4
  PolygonMaskInlineArrangement["onePerPoint"] = "one-per-point";
8
5
  PolygonMaskInlineArrangement["perPoint"] = "per-point";
9
6
  PolygonMaskInlineArrangement["randomLength"] = "random-length";
10
7
  PolygonMaskInlineArrangement["randomPoint"] = "random-point";
11
- })(PolygonMaskInlineArrangement || (exports.PolygonMaskInlineArrangement = PolygonMaskInlineArrangement = {}));
8
+ })(PolygonMaskInlineArrangement || (PolygonMaskInlineArrangement = {}));
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PolygonMaskMoveType = void 0;
4
- var PolygonMaskMoveType;
1
+ export var PolygonMaskMoveType;
5
2
  (function (PolygonMaskMoveType) {
6
3
  PolygonMaskMoveType["path"] = "path";
7
4
  PolygonMaskMoveType["radius"] = "radius";
8
- })(PolygonMaskMoveType || (exports.PolygonMaskMoveType = PolygonMaskMoveType = {}));
5
+ })(PolygonMaskMoveType || (PolygonMaskMoveType = {}));
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PolygonMaskType = void 0;
4
- var PolygonMaskType;
1
+ export var PolygonMaskType;
5
2
  (function (PolygonMaskType) {
6
3
  PolygonMaskType["inline"] = "inline";
7
4
  PolygonMaskType["inside"] = "inside";
8
5
  PolygonMaskType["outside"] = "outside";
9
6
  PolygonMaskType["none"] = "none";
10
- })(PolygonMaskType || (exports.PolygonMaskType = PolygonMaskType = {}));
7
+ })(PolygonMaskType || (PolygonMaskType = {}));
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,23 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PolygonMask = void 0;
4
- const engine_1 = require("@tsparticles/engine");
5
- const PolygonMaskDraw_js_1 = require("./PolygonMaskDraw.js");
6
- const PolygonMaskInline_js_1 = require("./PolygonMaskInline.js");
7
- const PolygonMaskLocalSvg_js_1 = require("./PolygonMaskLocalSvg.js");
8
- const PolygonMaskMove_js_1 = require("./PolygonMaskMove.js");
9
- const PolygonMaskType_js_1 = require("../../Enums/PolygonMaskType.js");
10
- class PolygonMask {
1
+ import { deepExtend, isNull, isString, } from "@tsparticles/engine";
2
+ import { PolygonMaskDraw } from "./PolygonMaskDraw.js";
3
+ import { PolygonMaskInline } from "./PolygonMaskInline.js";
4
+ import { PolygonMaskLocalSvg } from "./PolygonMaskLocalSvg.js";
5
+ import { PolygonMaskMove } from "./PolygonMaskMove.js";
6
+ import { PolygonMaskType } from "../../Enums/PolygonMaskType.js";
7
+ export class PolygonMask {
11
8
  constructor(engine) {
12
- this.draw = new PolygonMaskDraw_js_1.PolygonMaskDraw(engine);
9
+ this.draw = new PolygonMaskDraw(engine);
13
10
  this.enable = false;
14
- this.inline = new PolygonMaskInline_js_1.PolygonMaskInline();
15
- this.move = new PolygonMaskMove_js_1.PolygonMaskMove();
11
+ this.inline = new PolygonMaskInline();
12
+ this.move = new PolygonMaskMove();
16
13
  this.scale = 1;
17
- this.type = PolygonMaskType_js_1.PolygonMaskType.none;
14
+ this.type = PolygonMaskType.none;
18
15
  }
19
16
  load(data) {
20
- if ((0, engine_1.isNull)(data)) {
17
+ if (isNull(data)) {
21
18
  return;
22
19
  }
23
20
  this.draw.load(data.draw);
@@ -33,23 +30,22 @@ class PolygonMask {
33
30
  this.enable = data.enable;
34
31
  }
35
32
  else {
36
- this.enable = this.type !== PolygonMaskType_js_1.PolygonMaskType.none;
33
+ this.enable = this.type !== PolygonMaskType.none;
37
34
  }
38
35
  if (data.url !== undefined) {
39
36
  this.url = data.url;
40
37
  }
41
38
  if (data.data !== undefined) {
42
- if ((0, engine_1.isString)(data.data)) {
39
+ if (isString(data.data)) {
43
40
  this.data = data.data;
44
41
  }
45
42
  else {
46
- this.data = new PolygonMaskLocalSvg_js_1.PolygonMaskLocalSvg();
43
+ this.data = new PolygonMaskLocalSvg();
47
44
  this.data.load(data.data);
48
45
  }
49
46
  }
50
47
  if (data.position !== undefined) {
51
- this.position = (0, engine_1.deepExtend)({}, data.position);
48
+ this.position = deepExtend({}, data.position);
52
49
  }
53
50
  }
54
51
  }
55
- exports.PolygonMask = PolygonMask;
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PolygonMaskDraw = void 0;
4
- const engine_1 = require("@tsparticles/engine");
5
- const PolygonMaskDrawStroke_js_1 = require("./PolygonMaskDrawStroke.js");
6
- class PolygonMaskDraw {
1
+ import { isNull } from "@tsparticles/engine";
2
+ import { PolygonMaskDrawStroke } from "./PolygonMaskDrawStroke.js";
3
+ export class PolygonMaskDraw {
7
4
  constructor(engine) {
8
5
  this.enable = false;
9
- this.stroke = new PolygonMaskDrawStroke_js_1.PolygonMaskDrawStroke(engine);
6
+ this.stroke = new PolygonMaskDrawStroke(engine);
10
7
  }
11
8
  load(data) {
12
- if ((0, engine_1.isNull)(data)) {
9
+ if (isNull(data)) {
13
10
  return;
14
11
  }
15
12
  if (data.enable !== undefined) {
@@ -19,4 +16,3 @@ class PolygonMaskDraw {
19
16
  this.stroke.load(stroke);
20
17
  }
21
18
  }
22
- exports.PolygonMaskDraw = PolygonMaskDraw;
@@ -1,21 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PolygonMaskDrawStroke = void 0;
4
- const engine_1 = require("@tsparticles/engine");
5
- class PolygonMaskDrawStroke {
1
+ import { OptionsColor, isNull, isString, stringToAlpha, } from "@tsparticles/engine";
2
+ export class PolygonMaskDrawStroke {
6
3
  constructor(engine) {
7
4
  this._engine = engine;
8
- this.color = new engine_1.OptionsColor();
5
+ this.color = new OptionsColor();
9
6
  this.width = 0.5;
10
7
  this.opacity = 1;
11
8
  }
12
9
  load(data) {
13
- if ((0, engine_1.isNull)(data)) {
10
+ if (isNull(data)) {
14
11
  return;
15
12
  }
16
- this.color = engine_1.OptionsColor.create(this.color, data.color);
17
- if ((0, engine_1.isString)(this.color.value)) {
18
- this.opacity = (0, engine_1.stringToAlpha)(this._engine, this.color.value) ?? this.opacity;
13
+ this.color = OptionsColor.create(this.color, data.color);
14
+ if (isString(this.color.value)) {
15
+ this.opacity = stringToAlpha(this._engine, this.color.value) ?? this.opacity;
19
16
  }
20
17
  if (data.opacity !== undefined) {
21
18
  this.opacity = data.opacity;
@@ -25,4 +22,3 @@ class PolygonMaskDrawStroke {
25
22
  }
26
23
  }
27
24
  }
28
- exports.PolygonMaskDrawStroke = PolygonMaskDrawStroke;
@@ -1,14 +1,11 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PolygonMaskInline = void 0;
4
- const engine_1 = require("@tsparticles/engine");
5
- const PolygonMaskInlineArrangement_js_1 = require("../../Enums/PolygonMaskInlineArrangement.js");
6
- class PolygonMaskInline {
1
+ import { isNull } from "@tsparticles/engine";
2
+ import { PolygonMaskInlineArrangement, } from "../../Enums/PolygonMaskInlineArrangement.js";
3
+ export class PolygonMaskInline {
7
4
  constructor() {
8
- this.arrangement = PolygonMaskInlineArrangement_js_1.PolygonMaskInlineArrangement.onePerPoint;
5
+ this.arrangement = PolygonMaskInlineArrangement.onePerPoint;
9
6
  }
10
7
  load(data) {
11
- if ((0, engine_1.isNull)(data)) {
8
+ if (isNull(data)) {
12
9
  return;
13
10
  }
14
11
  if (data.arrangement !== undefined) {
@@ -16,4 +13,3 @@ class PolygonMaskInline {
16
13
  }
17
14
  }
18
15
  }
19
- exports.PolygonMaskInline = PolygonMaskInline;
@@ -1,8 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PolygonMaskLocalSvg = void 0;
4
- const engine_1 = require("@tsparticles/engine");
5
- class PolygonMaskLocalSvg {
1
+ import { isNull, } from "@tsparticles/engine";
2
+ export class PolygonMaskLocalSvg {
6
3
  constructor() {
7
4
  this.path = [];
8
5
  this.size = {
@@ -11,7 +8,7 @@ class PolygonMaskLocalSvg {
11
8
  };
12
9
  }
13
10
  load(data) {
14
- if ((0, engine_1.isNull)(data)) {
11
+ if (isNull(data)) {
15
12
  return;
16
13
  }
17
14
  if (data.path !== undefined) {
@@ -27,4 +24,3 @@ class PolygonMaskLocalSvg {
27
24
  }
28
25
  }
29
26
  }
30
- exports.PolygonMaskLocalSvg = PolygonMaskLocalSvg;
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PolygonMaskMove = void 0;
4
- const engine_1 = require("@tsparticles/engine");
5
- const PolygonMaskMoveType_js_1 = require("../../Enums/PolygonMaskMoveType.js");
6
- class PolygonMaskMove {
1
+ import { isNull } from "@tsparticles/engine";
2
+ import { PolygonMaskMoveType } from "../../Enums/PolygonMaskMoveType.js";
3
+ export class PolygonMaskMove {
7
4
  constructor() {
8
5
  this.radius = 10;
9
- this.type = PolygonMaskMoveType_js_1.PolygonMaskMoveType.path;
6
+ this.type = PolygonMaskMoveType.path;
10
7
  }
11
8
  load(data) {
12
- if ((0, engine_1.isNull)(data)) {
9
+ if (isNull(data)) {
13
10
  return;
14
11
  }
15
12
  if (data.radius !== undefined) {
@@ -20,4 +17,3 @@ class PolygonMaskMove {
20
17
  }
21
18
  }
22
19
  }
23
- exports.PolygonMaskMove = PolygonMaskMove;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};