@tsparticles/updater-destroy 4.0.0-beta.0 → 4.0.0-beta.1
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.
- package/513.min.js +1 -0
- package/browser/DestroyUpdater.js +7 -7
- package/browser/Utils.js +4 -4
- package/browser/index.js +4 -4
- package/cjs/DestroyUpdater.js +7 -7
- package/cjs/Utils.js +4 -4
- package/cjs/index.js +4 -4
- package/dist_browser_DestroyUpdater_js.js +3 -3
- package/esm/DestroyUpdater.js +7 -7
- package/esm/Utils.js +4 -4
- package/esm/index.js +4 -4
- package/package.json +2 -2
- package/report.html +84 -29
- package/tsparticles.updater.destroy.js +2 -2
- package/tsparticles.updater.destroy.min.js +2 -2
- package/types/DestroyUpdater.d.ts +4 -4
- package/types/Utils.d.ts +2 -2
- package/umd/DestroyUpdater.js +7 -7
- package/umd/Utils.js +4 -4
- package/umd/index.js +4 -4
- package/819.min.js +0 -1
package/513.min.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(this.webpackChunk_tsparticles_updater_destroy=this.webpackChunk_tsparticles_updater_destroy||[]).push([[513],{513(e,t,o){o.d(t,{DestroyUpdater:()=>d});var l,s,i=o(303);class r{bottom;left;right;top;load(e){(0,i.isNull)(e)||(void 0!==e.bottom&&(this.bottom=(0,i.setRangeValue)(e.bottom)),void 0!==e.left&&(this.left=(0,i.setRangeValue)(e.left)),void 0!==e.right&&(this.right=(0,i.setRangeValue)(e.right)),void 0!==e.top&&(this.top=(0,i.setRangeValue)(e.top)))}}(l=s||(s={})).none="none",l.split="split";class a extends i.ValueWithRandom{constructor(){super(),this.value=3}}class n extends i.ValueWithRandom{constructor(){super(),this.value={min:4,max:9}}}class f{count;factor;fillColor;fillColorOffset;particles;rate;sizeOffset;strokeColor;strokeColorOffset;constructor(){this.count=1,this.factor=new a,this.rate=new n,this.sizeOffset=!0}load(e){!(0,i.isNull)(e)&&(void 0!==e.fillColor&&(this.fillColor=i.OptionsColor.create(this.fillColor,e.fillColor)),void 0!==e.strokeColor&&(this.strokeColor=i.OptionsColor.create(this.strokeColor,e.strokeColor)),void 0!==e.count&&(this.count=e.count),this.factor.load(e.factor),this.rate.load(e.rate),this.particles=(0,i.executeOnSingleOrMultiple)(e.particles,e=>(0,i.deepExtend)({},e)),void 0!==e.sizeOffset&&(this.sizeOffset=e.sizeOffset),e.fillColorOffset&&(this.fillColorOffset=this.fillColorOffset??{},void 0!==e.fillColorOffset.h&&(this.fillColorOffset.h=e.fillColorOffset.h),void 0!==e.fillColorOffset.s&&(this.fillColorOffset.s=e.fillColorOffset.s),void 0!==e.fillColorOffset.l&&(this.fillColorOffset.l=e.fillColorOffset.l)),e.strokeColorOffset&&(this.strokeColorOffset=this.strokeColorOffset??{},void 0!==e.strokeColorOffset.h&&(this.strokeColorOffset.h=e.strokeColorOffset.h),void 0!==e.strokeColorOffset.s&&(this.strokeColorOffset.s=e.strokeColorOffset.s),void 0!==e.strokeColorOffset.l&&(this.strokeColorOffset.l=e.strokeColorOffset.l)))}}class u{bounds;mode;split;constructor(){this.bounds=new r,this.mode=s.none,this.split=new f}load(e){(0,i.isNull)(e)||(e.mode&&(this.mode=e.mode),e.bounds&&this.bounds.load(e.bounds),this.split.load(e.split))}}class d{_container;_pluginManager;constructor(e,t){this._container=t,this._pluginManager=e}init(e){let t=this._container,o=e.options.destroy;if(!o)return;e.splitCount=0;let l=o.bounds;e.destroyBounds??={};let{bottom:s,left:r,right:a,top:n}=l,{destroyBounds:f}=e,u=t.canvas.size;s&&(f.bottom=(0,i.getRangeValue)(s)*u.height/i.percentDenominator),r&&(f.left=(0,i.getRangeValue)(r)*u.width/i.percentDenominator),a&&(f.right=(0,i.getRangeValue)(a)*u.width/i.percentDenominator),n&&(f.top=(0,i.getRangeValue)(n)*u.height/i.percentDenominator)}isEnabled(e){return!e.destroyed}loadOptions(e,...t){for(let o of(e.destroy??=new u,t))e.destroy.load(o?.destroy)}particleDestroyed(e,t){if(t)return;let o=e.options.destroy;o?.mode===s.split&&function(e,t,o){let l=o.options.destroy;if(!l)return;let s=l.split;if(s.count>=0){if(void 0===o.splitCount||o.splitCount>s.count)return;o.splitCount++}let r=(0,i.getRangeValue)(s.rate.value),a=(0,i.itemFromSingleOrMultiple)(s.particles);for(let l=0;l<r;l++)!function(e,t,o,l){let s=o.options.destroy;if(!s)return;let r=s.split,a=(0,i.loadParticlesOptions)(e,t,o.options),n=(0,i.itemFromSingleOrMultiple)(a.fill),f=(0,i.itemFromSingleOrMultiple)(a.stroke);if(n?.enable){let e=i.AnimatableColor.create(void 0,n.color),t=o.getFillColor();e.value?e.load(r.fillColor):r.fillColorOffset&&t?e.load({value:{hsl:{h:t.h+(0,i.getRangeValue)(r.fillColorOffset.h??0),s:t.s+(0,i.getRangeValue)(r.fillColorOffset.s??0),l:t.l+(0,i.getRangeValue)(r.fillColorOffset.l??0)}}}):e.load({value:{hsl:o.getFillColor()}})}if(f?.width){let e=i.AnimatableColor.create(void 0,f.color),t=o.getStrokeColor();e.value?e.load(r.strokeColor):r.strokeColorOffset&&t?e.load({value:{hsl:{h:t.h+(0,i.getRangeValue)(r.strokeColorOffset.h??0),s:t.s+(0,i.getRangeValue)(r.strokeColorOffset.s??0),l:t.l+(0,i.getRangeValue)(r.strokeColorOffset.l??0)}}}):e.load({value:{hsl:o.getStrokeColor()}})}a.move.load({center:{x:o.position.x,y:o.position.y,mode:i.PixelMode.precise}});let u=i.identity/(0,i.getRangeValue)(r.factor.value);(0,i.isNumber)(a.size.value)?a.size.value*=u:(a.size.value.min*=u,a.size.value.max*=u),a.load(l);let d=r.sizeOffset?(0,i.setRangeValue)(-o.size.value,o.size.value):0,h={x:o.position.x+(0,i.randomInRangeValue)(d),y:o.position.y+(0,i.randomInRangeValue)(d)};t.particles.addParticle(h,a,o.group,e=>!(e.size.value<.5)&&(e.velocity.length=(0,i.randomInRangeValue)((0,i.setRangeValue)(o.velocity.length,e.velocity.length)),e.splitCount=(o.splitCount??0)+1,e.unbreakable=!0,e.unbreakableUntil=performance.now()+500,!0))}(e,t,o,a)}(this._pluginManager,this._container,e)}update(e){void 0!==e.unbreakableUntil&&performance.now()>=e.unbreakableUntil&&(e.unbreakable=!1,e.unbreakableUntil=void 0);let t=e.getPosition(),o=e.destroyBounds;o&&(void 0!==o.bottom&&t.y>=o.bottom||void 0!==o.left&&t.x<=o.left||void 0!==o.right&&t.x>=o.right||void 0!==o.top&&t.y<=o.top)&&e.destroy()}}}}]);
|
|
@@ -3,14 +3,14 @@ import { Destroy } from "./Options/Classes/Destroy.js";
|
|
|
3
3
|
import { DestroyMode } from "./Enums/DestroyMode.js";
|
|
4
4
|
import { split } from "./Utils.js";
|
|
5
5
|
export class DestroyUpdater {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
constructor(
|
|
9
|
-
this.
|
|
10
|
-
this.
|
|
6
|
+
_container;
|
|
7
|
+
_pluginManager;
|
|
8
|
+
constructor(pluginManager, container) {
|
|
9
|
+
this._container = container;
|
|
10
|
+
this._pluginManager = pluginManager;
|
|
11
11
|
}
|
|
12
12
|
init(particle) {
|
|
13
|
-
const container = this.
|
|
13
|
+
const container = this._container, particlesOptions = particle.options, destroyOptions = particlesOptions.destroy;
|
|
14
14
|
if (!destroyOptions) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
@@ -46,7 +46,7 @@ export class DestroyUpdater {
|
|
|
46
46
|
}
|
|
47
47
|
const destroyOptions = particle.options.destroy;
|
|
48
48
|
if (destroyOptions?.mode === DestroyMode.split) {
|
|
49
|
-
split(this.
|
|
49
|
+
split(this._pluginManager, this._container, particle);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
update(particle) {
|
package/browser/Utils.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AnimatableColor, PixelMode, getRangeValue, identity, isNumber, itemFromSingleOrMultiple, loadParticlesOptions, randomInRangeValue, setRangeValue, } from "@tsparticles/engine";
|
|
2
2
|
const defaultOffset = 0, minDestroySize = 0.5, defaultSplitCount = 0, increment = 1, unbreakableTime = 500, minSplitCount = 0;
|
|
3
|
-
function addSplitParticle(
|
|
3
|
+
function addSplitParticle(pluginManager, container, parent, splitParticlesOptions) {
|
|
4
4
|
const destroyOptions = parent.options.destroy;
|
|
5
5
|
if (!destroyOptions) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
|
-
const splitOptions = destroyOptions.split, options = loadParticlesOptions(
|
|
8
|
+
const splitOptions = destroyOptions.split, options = loadParticlesOptions(pluginManager, container, parent.options), fillOptions = itemFromSingleOrMultiple(options.fill), strokeOptions = itemFromSingleOrMultiple(options.stroke);
|
|
9
9
|
if (fillOptions?.enable) {
|
|
10
10
|
const fillColor = AnimatableColor.create(undefined, fillOptions.color), parentFillColor = parent.getFillColor();
|
|
11
11
|
if (fillColor.value) {
|
|
@@ -85,7 +85,7 @@ function addSplitParticle(engine, container, parent, splitParticlesOptions) {
|
|
|
85
85
|
return true;
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
export function split(
|
|
88
|
+
export function split(pluginManager, container, particle) {
|
|
89
89
|
const destroyOptions = particle.options.destroy;
|
|
90
90
|
if (!destroyOptions) {
|
|
91
91
|
return;
|
|
@@ -99,6 +99,6 @@ export function split(engine, container, particle) {
|
|
|
99
99
|
}
|
|
100
100
|
const rate = getRangeValue(splitOptions.rate.value), particlesSplitOptions = itemFromSingleOrMultiple(splitOptions.particles);
|
|
101
101
|
for (let i = 0; i < rate; i++) {
|
|
102
|
-
addSplitParticle(
|
|
102
|
+
addSplitParticle(pluginManager, container, particle, particlesSplitOptions);
|
|
103
103
|
}
|
|
104
104
|
}
|
package/browser/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export async function loadDestroyUpdater(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-beta.
|
|
3
|
-
await engine.register(e => {
|
|
4
|
-
e.addParticleUpdater("destroy", async (container) => {
|
|
2
|
+
engine.checkVersion("4.0.0-beta.1");
|
|
3
|
+
await engine.pluginManager.register(e => {
|
|
4
|
+
e.pluginManager.addParticleUpdater("destroy", async (container) => {
|
|
5
5
|
const { DestroyUpdater } = await import("./DestroyUpdater.js");
|
|
6
|
-
return new DestroyUpdater(e, container);
|
|
6
|
+
return new DestroyUpdater(e.pluginManager, container);
|
|
7
7
|
});
|
|
8
8
|
});
|
|
9
9
|
}
|
package/cjs/DestroyUpdater.js
CHANGED
|
@@ -3,14 +3,14 @@ import { Destroy } from "./Options/Classes/Destroy.js";
|
|
|
3
3
|
import { DestroyMode } from "./Enums/DestroyMode.js";
|
|
4
4
|
import { split } from "./Utils.js";
|
|
5
5
|
export class DestroyUpdater {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
constructor(
|
|
9
|
-
this.
|
|
10
|
-
this.
|
|
6
|
+
_container;
|
|
7
|
+
_pluginManager;
|
|
8
|
+
constructor(pluginManager, container) {
|
|
9
|
+
this._container = container;
|
|
10
|
+
this._pluginManager = pluginManager;
|
|
11
11
|
}
|
|
12
12
|
init(particle) {
|
|
13
|
-
const container = this.
|
|
13
|
+
const container = this._container, particlesOptions = particle.options, destroyOptions = particlesOptions.destroy;
|
|
14
14
|
if (!destroyOptions) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
@@ -46,7 +46,7 @@ export class DestroyUpdater {
|
|
|
46
46
|
}
|
|
47
47
|
const destroyOptions = particle.options.destroy;
|
|
48
48
|
if (destroyOptions?.mode === DestroyMode.split) {
|
|
49
|
-
split(this.
|
|
49
|
+
split(this._pluginManager, this._container, particle);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
update(particle) {
|
package/cjs/Utils.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AnimatableColor, PixelMode, getRangeValue, identity, isNumber, itemFromSingleOrMultiple, loadParticlesOptions, randomInRangeValue, setRangeValue, } from "@tsparticles/engine";
|
|
2
2
|
const defaultOffset = 0, minDestroySize = 0.5, defaultSplitCount = 0, increment = 1, unbreakableTime = 500, minSplitCount = 0;
|
|
3
|
-
function addSplitParticle(
|
|
3
|
+
function addSplitParticle(pluginManager, container, parent, splitParticlesOptions) {
|
|
4
4
|
const destroyOptions = parent.options.destroy;
|
|
5
5
|
if (!destroyOptions) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
|
-
const splitOptions = destroyOptions.split, options = loadParticlesOptions(
|
|
8
|
+
const splitOptions = destroyOptions.split, options = loadParticlesOptions(pluginManager, container, parent.options), fillOptions = itemFromSingleOrMultiple(options.fill), strokeOptions = itemFromSingleOrMultiple(options.stroke);
|
|
9
9
|
if (fillOptions?.enable) {
|
|
10
10
|
const fillColor = AnimatableColor.create(undefined, fillOptions.color), parentFillColor = parent.getFillColor();
|
|
11
11
|
if (fillColor.value) {
|
|
@@ -85,7 +85,7 @@ function addSplitParticle(engine, container, parent, splitParticlesOptions) {
|
|
|
85
85
|
return true;
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
export function split(
|
|
88
|
+
export function split(pluginManager, container, particle) {
|
|
89
89
|
const destroyOptions = particle.options.destroy;
|
|
90
90
|
if (!destroyOptions) {
|
|
91
91
|
return;
|
|
@@ -99,6 +99,6 @@ export function split(engine, container, particle) {
|
|
|
99
99
|
}
|
|
100
100
|
const rate = getRangeValue(splitOptions.rate.value), particlesSplitOptions = itemFromSingleOrMultiple(splitOptions.particles);
|
|
101
101
|
for (let i = 0; i < rate; i++) {
|
|
102
|
-
addSplitParticle(
|
|
102
|
+
addSplitParticle(pluginManager, container, particle, particlesSplitOptions);
|
|
103
103
|
}
|
|
104
104
|
}
|
package/cjs/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export async function loadDestroyUpdater(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-beta.
|
|
3
|
-
await engine.register(e => {
|
|
4
|
-
e.addParticleUpdater("destroy", async (container) => {
|
|
2
|
+
engine.checkVersion("4.0.0-beta.1");
|
|
3
|
+
await engine.pluginManager.register(e => {
|
|
4
|
+
e.pluginManager.addParticleUpdater("destroy", async (container) => {
|
|
5
5
|
const { DestroyUpdater } = await import("./DestroyUpdater.js");
|
|
6
|
-
return new DestroyUpdater(e, container);
|
|
6
|
+
return new DestroyUpdater(e.pluginManager, container);
|
|
7
7
|
});
|
|
8
8
|
});
|
|
9
9
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Demo / Generator : https://particles.js.org/
|
|
5
5
|
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
6
|
* How to use? : Check the GitHub README
|
|
7
|
-
* v4.0.0-beta.
|
|
7
|
+
* v4.0.0-beta.1
|
|
8
8
|
*/
|
|
9
9
|
"use strict";
|
|
10
10
|
/*
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
\****************************************/
|
|
24
24
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
25
25
|
|
|
26
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DestroyUpdater: () => (/* binding */ DestroyUpdater)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Options_Classes_Destroy_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Options/Classes/Destroy.js */ \"./dist/browser/Options/Classes/Destroy.js\");\n/* harmony import */ var _Enums_DestroyMode_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Enums/DestroyMode.js */ \"./dist/browser/Enums/DestroyMode.js\");\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n\n\n\n\nclass DestroyUpdater {\n
|
|
26
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ DestroyUpdater: () => (/* binding */ DestroyUpdater)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _Options_Classes_Destroy_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Options/Classes/Destroy.js */ \"./dist/browser/Options/Classes/Destroy.js\");\n/* harmony import */ var _Enums_DestroyMode_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Enums/DestroyMode.js */ \"./dist/browser/Enums/DestroyMode.js\");\n/* harmony import */ var _Utils_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Utils.js */ \"./dist/browser/Utils.js\");\n\n\n\n\nclass DestroyUpdater {\n _container;\n _pluginManager;\n constructor(pluginManager, container){\n this._container = container;\n this._pluginManager = pluginManager;\n }\n init(particle) {\n const container = this._container, particlesOptions = particle.options, destroyOptions = particlesOptions.destroy;\n if (!destroyOptions) {\n return;\n }\n particle.splitCount = 0;\n const destroyBoundsOptions = destroyOptions.bounds;\n particle.destroyBounds ??= {};\n const { bottom, left, right, top } = destroyBoundsOptions, { destroyBounds } = particle, canvasSize = container.canvas.size;\n if (bottom) {\n destroyBounds.bottom = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(bottom) * canvasSize.height / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator;\n }\n if (left) {\n destroyBounds.left = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(left) * canvasSize.width / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator;\n }\n if (right) {\n destroyBounds.right = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(right) * canvasSize.width / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator;\n }\n if (top) {\n destroyBounds.top = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(top) * canvasSize.height / _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.percentDenominator;\n }\n }\n isEnabled(particle) {\n return !particle.destroyed;\n }\n loadOptions(options, ...sources) {\n options.destroy ??= new _Options_Classes_Destroy_js__WEBPACK_IMPORTED_MODULE_1__.Destroy();\n for (const source of sources){\n options.destroy.load(source?.destroy);\n }\n }\n particleDestroyed(particle, override) {\n if (override) {\n return;\n }\n const destroyOptions = particle.options.destroy;\n if (destroyOptions?.mode === _Enums_DestroyMode_js__WEBPACK_IMPORTED_MODULE_2__.DestroyMode.split) {\n (0,_Utils_js__WEBPACK_IMPORTED_MODULE_3__.split)(this._pluginManager, this._container, particle);\n }\n }\n update(particle) {\n if (particle.unbreakableUntil !== undefined && performance.now() >= particle.unbreakableUntil) {\n particle.unbreakable = false;\n particle.unbreakableUntil = undefined;\n }\n const position = particle.getPosition(), bounds = particle.destroyBounds;\n if (!bounds) {\n return;\n }\n if (bounds.bottom !== undefined && position.y >= bounds.bottom || bounds.left !== undefined && position.x <= bounds.left || bounds.right !== undefined && position.x >= bounds.right || bounds.top !== undefined && position.y <= bounds.top) {\n particle.destroy();\n }\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/updater-destroy/./dist/browser/DestroyUpdater.js?\n}");
|
|
27
27
|
|
|
28
28
|
/***/ },
|
|
29
29
|
|
|
@@ -93,7 +93,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
|
|
|
93
93
|
\*******************************/
|
|
94
94
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
95
95
|
|
|
96
|
-
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ split: () => (/* binding */ split)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst defaultOffset = 0, minDestroySize = 0.5, defaultSplitCount = 0, increment = 1, unbreakableTime = 500, minSplitCount = 0;\nfunction addSplitParticle(
|
|
96
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ split: () => (/* binding */ split)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst defaultOffset = 0, minDestroySize = 0.5, defaultSplitCount = 0, increment = 1, unbreakableTime = 500, minSplitCount = 0;\nfunction addSplitParticle(pluginManager, container, parent, splitParticlesOptions) {\n const destroyOptions = parent.options.destroy;\n if (!destroyOptions) {\n return;\n }\n const splitOptions = destroyOptions.split, options = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.loadParticlesOptions)(pluginManager, container, parent.options), fillOptions = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.itemFromSingleOrMultiple)(options.fill), strokeOptions = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.itemFromSingleOrMultiple)(options.stroke);\n if (fillOptions?.enable) {\n const fillColor = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.AnimatableColor.create(undefined, fillOptions.color), parentFillColor = parent.getFillColor();\n if (fillColor.value) {\n fillColor.load(splitOptions.fillColor);\n } else if (splitOptions.fillColorOffset && parentFillColor) {\n fillColor.load({\n value: {\n hsl: {\n h: parentFillColor.h + (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(splitOptions.fillColorOffset.h ?? defaultOffset),\n s: parentFillColor.s + (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(splitOptions.fillColorOffset.s ?? defaultOffset),\n l: parentFillColor.l + (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(splitOptions.fillColorOffset.l ?? defaultOffset)\n }\n }\n });\n } else {\n fillColor.load({\n value: {\n hsl: parent.getFillColor()\n }\n });\n }\n }\n if (strokeOptions?.width) {\n const strokeColor = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.AnimatableColor.create(undefined, strokeOptions.color), parentStrokeColor = parent.getStrokeColor();\n if (strokeColor.value) {\n strokeColor.load(splitOptions.strokeColor);\n } else if (splitOptions.strokeColorOffset && parentStrokeColor) {\n strokeColor.load({\n value: {\n hsl: {\n h: parentStrokeColor.h + (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(splitOptions.strokeColorOffset.h ?? defaultOffset),\n s: parentStrokeColor.s + (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(splitOptions.strokeColorOffset.s ?? defaultOffset),\n l: parentStrokeColor.l + (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(splitOptions.strokeColorOffset.l ?? defaultOffset)\n }\n }\n });\n } else {\n strokeColor.load({\n value: {\n hsl: parent.getStrokeColor()\n }\n });\n }\n }\n options.move.load({\n center: {\n x: parent.position.x,\n y: parent.position.y,\n mode: _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.PixelMode.precise\n }\n });\n const factor = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.identity / (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(splitOptions.factor.value);\n if ((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.isNumber)(options.size.value)) {\n options.size.value *= factor;\n } else {\n options.size.value.min *= factor;\n options.size.value.max *= factor;\n }\n options.load(splitParticlesOptions);\n const offset = splitOptions.sizeOffset ? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(-parent.size.value, parent.size.value) : defaultOffset, position = {\n x: parent.position.x + (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.randomInRangeValue)(offset),\n y: parent.position.y + (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.randomInRangeValue)(offset)\n };\n return container.particles.addParticle(position, options, parent.group, (particle)=>{\n if (particle.size.value < minDestroySize) {\n return false;\n }\n particle.velocity.length = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.randomInRangeValue)((0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.setRangeValue)(parent.velocity.length, particle.velocity.length));\n particle.splitCount = (parent.splitCount ?? defaultSplitCount) + increment;\n particle.unbreakable = true;\n particle.unbreakableUntil = performance.now() + unbreakableTime;\n return true;\n });\n}\nfunction split(pluginManager, container, particle) {\n const destroyOptions = particle.options.destroy;\n if (!destroyOptions) {\n return;\n }\n const splitOptions = destroyOptions.split;\n if (splitOptions.count >= minSplitCount) {\n if (particle.splitCount === undefined || particle.splitCount > splitOptions.count) {\n return;\n }\n particle.splitCount++;\n }\n const rate = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRangeValue)(splitOptions.rate.value), particlesSplitOptions = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.itemFromSingleOrMultiple)(splitOptions.particles);\n for(let i = 0; i < rate; i++){\n addSplitParticle(pluginManager, container, particle, particlesSplitOptions);\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/updater-destroy/./dist/browser/Utils.js?\n}");
|
|
97
97
|
|
|
98
98
|
/***/ }
|
|
99
99
|
|
package/esm/DestroyUpdater.js
CHANGED
|
@@ -3,14 +3,14 @@ import { Destroy } from "./Options/Classes/Destroy.js";
|
|
|
3
3
|
import { DestroyMode } from "./Enums/DestroyMode.js";
|
|
4
4
|
import { split } from "./Utils.js";
|
|
5
5
|
export class DestroyUpdater {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
constructor(
|
|
9
|
-
this.
|
|
10
|
-
this.
|
|
6
|
+
_container;
|
|
7
|
+
_pluginManager;
|
|
8
|
+
constructor(pluginManager, container) {
|
|
9
|
+
this._container = container;
|
|
10
|
+
this._pluginManager = pluginManager;
|
|
11
11
|
}
|
|
12
12
|
init(particle) {
|
|
13
|
-
const container = this.
|
|
13
|
+
const container = this._container, particlesOptions = particle.options, destroyOptions = particlesOptions.destroy;
|
|
14
14
|
if (!destroyOptions) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
@@ -46,7 +46,7 @@ export class DestroyUpdater {
|
|
|
46
46
|
}
|
|
47
47
|
const destroyOptions = particle.options.destroy;
|
|
48
48
|
if (destroyOptions?.mode === DestroyMode.split) {
|
|
49
|
-
split(this.
|
|
49
|
+
split(this._pluginManager, this._container, particle);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
update(particle) {
|
package/esm/Utils.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { AnimatableColor, PixelMode, getRangeValue, identity, isNumber, itemFromSingleOrMultiple, loadParticlesOptions, randomInRangeValue, setRangeValue, } from "@tsparticles/engine";
|
|
2
2
|
const defaultOffset = 0, minDestroySize = 0.5, defaultSplitCount = 0, increment = 1, unbreakableTime = 500, minSplitCount = 0;
|
|
3
|
-
function addSplitParticle(
|
|
3
|
+
function addSplitParticle(pluginManager, container, parent, splitParticlesOptions) {
|
|
4
4
|
const destroyOptions = parent.options.destroy;
|
|
5
5
|
if (!destroyOptions) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
|
-
const splitOptions = destroyOptions.split, options = loadParticlesOptions(
|
|
8
|
+
const splitOptions = destroyOptions.split, options = loadParticlesOptions(pluginManager, container, parent.options), fillOptions = itemFromSingleOrMultiple(options.fill), strokeOptions = itemFromSingleOrMultiple(options.stroke);
|
|
9
9
|
if (fillOptions?.enable) {
|
|
10
10
|
const fillColor = AnimatableColor.create(undefined, fillOptions.color), parentFillColor = parent.getFillColor();
|
|
11
11
|
if (fillColor.value) {
|
|
@@ -85,7 +85,7 @@ function addSplitParticle(engine, container, parent, splitParticlesOptions) {
|
|
|
85
85
|
return true;
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
export function split(
|
|
88
|
+
export function split(pluginManager, container, particle) {
|
|
89
89
|
const destroyOptions = particle.options.destroy;
|
|
90
90
|
if (!destroyOptions) {
|
|
91
91
|
return;
|
|
@@ -99,6 +99,6 @@ export function split(engine, container, particle) {
|
|
|
99
99
|
}
|
|
100
100
|
const rate = getRangeValue(splitOptions.rate.value), particlesSplitOptions = itemFromSingleOrMultiple(splitOptions.particles);
|
|
101
101
|
for (let i = 0; i < rate; i++) {
|
|
102
|
-
addSplitParticle(
|
|
102
|
+
addSplitParticle(pluginManager, container, particle, particlesSplitOptions);
|
|
103
103
|
}
|
|
104
104
|
}
|
package/esm/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export async function loadDestroyUpdater(engine) {
|
|
2
|
-
engine.checkVersion("4.0.0-beta.
|
|
3
|
-
await engine.register(e => {
|
|
4
|
-
e.addParticleUpdater("destroy", async (container) => {
|
|
2
|
+
engine.checkVersion("4.0.0-beta.1");
|
|
3
|
+
await engine.pluginManager.register(e => {
|
|
4
|
+
e.pluginManager.addParticleUpdater("destroy", async (container) => {
|
|
5
5
|
const { DestroyUpdater } = await import("./DestroyUpdater.js");
|
|
6
|
-
return new DestroyUpdater(e, container);
|
|
6
|
+
return new DestroyUpdater(e.pluginManager, container);
|
|
7
7
|
});
|
|
8
8
|
});
|
|
9
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/updater-destroy",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.1",
|
|
4
4
|
"description": "tsParticles particles destroy updater",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"./package.json": "./package.json"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@tsparticles/engine": "4.0.0-beta.
|
|
90
|
+
"@tsparticles/engine": "4.0.0-beta.1"
|
|
91
91
|
},
|
|
92
92
|
"publishConfig": {
|
|
93
93
|
"access": "public"
|