@tsparticles/updater-destroy 4.0.0-alpha.8 → 4.0.0-beta.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.
- package/819.min.js +1 -0
- package/browser/DestroyUpdater.js +5 -2
- package/browser/Options/Classes/Destroy.js +3 -0
- package/browser/Options/Classes/DestroyBounds.js +4 -0
- package/browser/Options/Classes/Split.js +34 -10
- package/browser/Utils.js +57 -29
- package/browser/index.js +1 -1
- package/cjs/DestroyUpdater.js +5 -2
- package/cjs/Options/Classes/Destroy.js +3 -0
- package/cjs/Options/Classes/DestroyBounds.js +4 -0
- package/cjs/Options/Classes/Split.js +34 -10
- package/cjs/Utils.js +57 -29
- package/cjs/index.js +1 -1
- package/dist_browser_DestroyUpdater_js.js +9 -9
- package/esm/DestroyUpdater.js +5 -2
- package/esm/Options/Classes/Destroy.js +3 -0
- package/esm/Options/Classes/DestroyBounds.js +4 -0
- package/esm/Options/Classes/Split.js +34 -10
- package/esm/Utils.js +57 -29
- package/esm/index.js +1 -1
- package/package.json +2 -2
- package/report.html +1 -1
- package/tsparticles.updater.destroy.js +31 -19
- package/tsparticles.updater.destroy.min.js +2 -2
- package/types/Options/Classes/Split.d.ts +4 -2
- package/types/Options/Interfaces/ISplit.d.ts +4 -2
- package/types/Types.d.ts +1 -0
- package/umd/DestroyUpdater.js +5 -2
- package/umd/Options/Classes/Destroy.js +3 -0
- package/umd/Options/Classes/DestroyBounds.js +4 -0
- package/umd/Options/Classes/Split.js +34 -10
- package/umd/Utils.js +56 -28
- package/umd/index.js +1 -1
- package/72.min.js +0 -2
- package/72.min.js.LICENSE.txt +0 -1
- package/tsparticles.updater.destroy.min.js.LICENSE.txt +0 -1
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
const DestroyMode_js_1 = require("../../Enums/DestroyMode.js");
|
|
16
16
|
const Split_js_1 = require("./Split.js");
|
|
17
17
|
class Destroy {
|
|
18
|
+
bounds;
|
|
19
|
+
mode;
|
|
20
|
+
split;
|
|
18
21
|
constructor() {
|
|
19
22
|
this.bounds = new DestroyBounds_js_1.DestroyBounds();
|
|
20
23
|
this.mode = DestroyMode_js_1.DestroyMode.none;
|
|
@@ -14,6 +14,15 @@
|
|
|
14
14
|
const SplitFactor_js_1 = require("./SplitFactor.js");
|
|
15
15
|
const SplitRate_js_1 = require("./SplitRate.js");
|
|
16
16
|
class Split {
|
|
17
|
+
count;
|
|
18
|
+
factor;
|
|
19
|
+
fillColor;
|
|
20
|
+
fillColorOffset;
|
|
21
|
+
particles;
|
|
22
|
+
rate;
|
|
23
|
+
sizeOffset;
|
|
24
|
+
strokeColor;
|
|
25
|
+
strokeColorOffset;
|
|
17
26
|
constructor() {
|
|
18
27
|
this.count = 1;
|
|
19
28
|
this.factor = new SplitFactor_js_1.SplitFactor();
|
|
@@ -24,8 +33,11 @@
|
|
|
24
33
|
if ((0, engine_1.isNull)(data)) {
|
|
25
34
|
return;
|
|
26
35
|
}
|
|
27
|
-
if (data.
|
|
28
|
-
this.
|
|
36
|
+
if (data.fillColor !== undefined) {
|
|
37
|
+
this.fillColor = engine_1.OptionsColor.create(this.fillColor, data.fillColor);
|
|
38
|
+
}
|
|
39
|
+
if (data.strokeColor !== undefined) {
|
|
40
|
+
this.strokeColor = engine_1.OptionsColor.create(this.strokeColor, data.strokeColor);
|
|
29
41
|
}
|
|
30
42
|
if (data.count !== undefined) {
|
|
31
43
|
this.count = data.count;
|
|
@@ -38,16 +50,28 @@
|
|
|
38
50
|
if (data.sizeOffset !== undefined) {
|
|
39
51
|
this.sizeOffset = data.sizeOffset;
|
|
40
52
|
}
|
|
41
|
-
if (data.
|
|
42
|
-
this.
|
|
43
|
-
if (data.
|
|
44
|
-
this.
|
|
53
|
+
if (data.fillColorOffset) {
|
|
54
|
+
this.fillColorOffset = this.fillColorOffset ?? {};
|
|
55
|
+
if (data.fillColorOffset.h !== undefined) {
|
|
56
|
+
this.fillColorOffset.h = data.fillColorOffset.h;
|
|
57
|
+
}
|
|
58
|
+
if (data.fillColorOffset.s !== undefined) {
|
|
59
|
+
this.fillColorOffset.s = data.fillColorOffset.s;
|
|
60
|
+
}
|
|
61
|
+
if (data.fillColorOffset.l !== undefined) {
|
|
62
|
+
this.fillColorOffset.l = data.fillColorOffset.l;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (data.strokeColorOffset) {
|
|
66
|
+
this.strokeColorOffset = this.strokeColorOffset ?? {};
|
|
67
|
+
if (data.strokeColorOffset.h !== undefined) {
|
|
68
|
+
this.strokeColorOffset.h = data.strokeColorOffset.h;
|
|
45
69
|
}
|
|
46
|
-
if (data.
|
|
47
|
-
this.
|
|
70
|
+
if (data.strokeColorOffset.s !== undefined) {
|
|
71
|
+
this.strokeColorOffset.s = data.strokeColorOffset.s;
|
|
48
72
|
}
|
|
49
|
-
if (data.
|
|
50
|
-
this.
|
|
73
|
+
if (data.strokeColorOffset.l !== undefined) {
|
|
74
|
+
this.strokeColorOffset.l = data.strokeColorOffset.l;
|
|
51
75
|
}
|
|
52
76
|
}
|
|
53
77
|
}
|
package/umd/Utils.js
CHANGED
|
@@ -17,27 +17,54 @@
|
|
|
17
17
|
if (!destroyOptions) {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
const splitOptions = destroyOptions.split, options = (0, engine_1.loadParticlesOptions)(engine, container, parent.options),
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
const splitOptions = destroyOptions.split, options = (0, engine_1.loadParticlesOptions)(engine, container, parent.options), fillOptions = (0, engine_1.itemFromSingleOrMultiple)(options.fill), strokeOptions = (0, engine_1.itemFromSingleOrMultiple)(options.stroke);
|
|
21
|
+
if (fillOptions?.enable) {
|
|
22
|
+
const fillColor = engine_1.AnimatableColor.create(undefined, fillOptions.color), parentFillColor = parent.getFillColor();
|
|
23
|
+
if (fillColor.value) {
|
|
24
|
+
fillColor.load(splitOptions.fillColor);
|
|
25
|
+
}
|
|
26
|
+
else if (splitOptions.fillColorOffset && parentFillColor) {
|
|
27
|
+
fillColor.load({
|
|
28
|
+
value: {
|
|
29
|
+
hsl: {
|
|
30
|
+
h: parentFillColor.h + (0, engine_1.getRangeValue)(splitOptions.fillColorOffset.h ?? defaultOffset),
|
|
31
|
+
s: parentFillColor.s + (0, engine_1.getRangeValue)(splitOptions.fillColorOffset.s ?? defaultOffset),
|
|
32
|
+
l: parentFillColor.l + (0, engine_1.getRangeValue)(splitOptions.fillColorOffset.l ?? defaultOffset),
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
fillColor.load({
|
|
39
|
+
value: {
|
|
40
|
+
hsl: parent.getFillColor(),
|
|
31
41
|
},
|
|
32
|
-
}
|
|
33
|
-
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
34
44
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
if (strokeOptions?.width) {
|
|
46
|
+
const strokeColor = engine_1.AnimatableColor.create(undefined, strokeOptions.color), parentStrokeColor = parent.getStrokeColor();
|
|
47
|
+
if (strokeColor.value) {
|
|
48
|
+
strokeColor.load(splitOptions.strokeColor);
|
|
49
|
+
}
|
|
50
|
+
else if (splitOptions.strokeColorOffset && parentStrokeColor) {
|
|
51
|
+
strokeColor.load({
|
|
52
|
+
value: {
|
|
53
|
+
hsl: {
|
|
54
|
+
h: parentStrokeColor.h + (0, engine_1.getRangeValue)(splitOptions.strokeColorOffset.h ?? defaultOffset),
|
|
55
|
+
s: parentStrokeColor.s + (0, engine_1.getRangeValue)(splitOptions.strokeColorOffset.s ?? defaultOffset),
|
|
56
|
+
l: parentStrokeColor.l + (0, engine_1.getRangeValue)(splitOptions.strokeColorOffset.l ?? defaultOffset),
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
strokeColor.load({
|
|
63
|
+
value: {
|
|
64
|
+
hsl: parent.getStrokeColor(),
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
41
68
|
}
|
|
42
69
|
options.move.load({
|
|
43
70
|
center: {
|
|
@@ -46,12 +73,13 @@
|
|
|
46
73
|
mode: engine_1.PixelMode.precise,
|
|
47
74
|
},
|
|
48
75
|
});
|
|
76
|
+
const factor = engine_1.identity / (0, engine_1.getRangeValue)(splitOptions.factor.value);
|
|
49
77
|
if ((0, engine_1.isNumber)(options.size.value)) {
|
|
50
|
-
options.size.value
|
|
78
|
+
options.size.value *= factor;
|
|
51
79
|
}
|
|
52
80
|
else {
|
|
53
|
-
options.size.value.min
|
|
54
|
-
options.size.value.max
|
|
81
|
+
options.size.value.min *= factor;
|
|
82
|
+
options.size.value.max *= factor;
|
|
55
83
|
}
|
|
56
84
|
options.load(splitParticlesOptions);
|
|
57
85
|
const offset = splitOptions.sizeOffset ? (0, engine_1.setRangeValue)(-parent.size.value, parent.size.value) : defaultOffset, position = {
|
|
@@ -65,9 +93,7 @@
|
|
|
65
93
|
particle.velocity.length = (0, engine_1.randomInRangeValue)((0, engine_1.setRangeValue)(parent.velocity.length, particle.velocity.length));
|
|
66
94
|
particle.splitCount = (parent.splitCount ?? defaultSplitCount) + increment;
|
|
67
95
|
particle.unbreakable = true;
|
|
68
|
-
|
|
69
|
-
particle.unbreakable = false;
|
|
70
|
-
}, unbreakableTime);
|
|
96
|
+
particle.unbreakableUntil = performance.now() + unbreakableTime;
|
|
71
97
|
return true;
|
|
72
98
|
});
|
|
73
99
|
}
|
|
@@ -77,9 +103,11 @@
|
|
|
77
103
|
return;
|
|
78
104
|
}
|
|
79
105
|
const splitOptions = destroyOptions.split;
|
|
80
|
-
if (splitOptions.count >= minSplitCount
|
|
81
|
-
(particle.splitCount === undefined || particle.splitCount
|
|
82
|
-
|
|
106
|
+
if (splitOptions.count >= minSplitCount) {
|
|
107
|
+
if (particle.splitCount === undefined || particle.splitCount > splitOptions.count) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
particle.splitCount++;
|
|
83
111
|
}
|
|
84
112
|
const rate = (0, engine_1.getRangeValue)(splitOptions.rate.value), particlesSplitOptions = (0, engine_1.itemFromSingleOrMultiple)(splitOptions.particles);
|
|
85
113
|
for (let i = 0; i < rate; i++) {
|
package/umd/index.js
CHANGED
|
@@ -45,7 +45,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
46
|
exports.loadDestroyUpdater = loadDestroyUpdater;
|
|
47
47
|
async function loadDestroyUpdater(engine) {
|
|
48
|
-
engine.checkVersion("4.0.0-
|
|
48
|
+
engine.checkVersion("4.0.0-beta.0");
|
|
49
49
|
await engine.register(e => {
|
|
50
50
|
e.addParticleUpdater("destroy", async (container) => {
|
|
51
51
|
const { DestroyUpdater } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./DestroyUpdater.js"))) : new Promise((resolve_1, reject_1) => { require(["./DestroyUpdater.js"], resolve_1, reject_1); }).then(__importStar));
|
package/72.min.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! For license information please see 72.min.js.LICENSE.txt */
|
|
2
|
-
(this.webpackChunk_tsparticles_updater_destroy=this.webpackChunk_tsparticles_updater_destroy||[]).push([[72],{72(t,e,o){o.d(e,{DestroyUpdater:()=>d});var s,i=o(303);class l{load(t){(0,i.isNull)(t)||(void 0!==t.bottom&&(this.bottom=(0,i.setRangeValue)(t.bottom)),void 0!==t.left&&(this.left=(0,i.setRangeValue)(t.left)),void 0!==t.right&&(this.right=(0,i.setRangeValue)(t.right)),void 0!==t.top&&(this.top=(0,i.setRangeValue)(t.top)))}}!function(t){t.none="none",t.split="split"}(s||(s={}));class n extends i.ValueWithRandom{constructor(){super(),this.value=3}}class r extends i.ValueWithRandom{constructor(){super(),this.value={min:4,max:9}}}class a{constructor(){this.count=1,this.factor=new n,this.rate=new r,this.sizeOffset=!0}load(t){(0,i.isNull)(t)||(void 0!==t.color&&(this.color=i.OptionsColor.create(this.color,t.color)),void 0!==t.count&&(this.count=t.count),this.factor.load(t.factor),this.rate.load(t.rate),this.particles=(0,i.executeOnSingleOrMultiple)(t.particles,(t=>(0,i.deepExtend)({},t))),void 0!==t.sizeOffset&&(this.sizeOffset=t.sizeOffset),t.colorOffset&&(this.colorOffset=this.colorOffset??{},void 0!==t.colorOffset.h&&(this.colorOffset.h=t.colorOffset.h),void 0!==t.colorOffset.s&&(this.colorOffset.s=t.colorOffset.s),void 0!==t.colorOffset.l&&(this.colorOffset.l=t.colorOffset.l)))}}class c{constructor(){this.bounds=new l,this.mode=s.none,this.split=new a}load(t){(0,i.isNull)(t)||(t.mode&&(this.mode=t.mode),t.bounds&&this.bounds.load(t.bounds),this.split.load(t.split))}}function u(t,e,o,s){const l=o.options.destroy;if(!l)return;const n=l.split,r=(0,i.loadParticlesOptions)(t,e,o.options),a=(0,i.getRangeValue)(n.factor.value),c=o.getFillColor();n.color?r.color.load(n.color):n.colorOffset&&c?r.color.load({value:{hsl:{h:c.h+(0,i.getRangeValue)(n.colorOffset.h??0),s:c.s+(0,i.getRangeValue)(n.colorOffset.s??0),l:c.l+(0,i.getRangeValue)(n.colorOffset.l??0)}}}):r.color.load({value:{hsl:o.getFillColor()}}),r.move.load({center:{x:o.position.x,y:o.position.y,mode:i.PixelMode.precise}}),(0,i.isNumber)(r.size.value)?r.size.value/=a:(r.size.value.min/=a,r.size.value.max/=a),r.load(s);const u=n.sizeOffset?(0,i.setRangeValue)(-o.size.value,o.size.value):0,d={x:o.position.x+(0,i.randomInRangeValue)(u),y:o.position.y+(0,i.randomInRangeValue)(u)};return e.particles.addParticle(d,r,o.group,(t=>!(t.size.value<.5)&&(t.velocity.length=(0,i.randomInRangeValue)((0,i.setRangeValue)(o.velocity.length,t.velocity.length)),t.splitCount=(o.splitCount??0)+1,t.unbreakable=!0,setTimeout((()=>{t.unbreakable=!1}),500),!0)))}class d{constructor(t,e){this.container=e,this.engine=t}init(t){const e=this.container,o=t.options.destroy;if(!o)return;t.splitCount=0;const s=o.bounds;t.destroyBounds??={};const{bottom:l,left:n,right:r,top:a}=s,{destroyBounds:c}=t,u=e.canvas.size;l&&(c.bottom=(0,i.getRangeValue)(l)*u.height/i.percentDenominator),n&&(c.left=(0,i.getRangeValue)(n)*u.width/i.percentDenominator),r&&(c.right=(0,i.getRangeValue)(r)*u.width/i.percentDenominator),a&&(c.top=(0,i.getRangeValue)(a)*u.height/i.percentDenominator)}isEnabled(t){return!t.destroyed}loadOptions(t,...e){t.destroy??=new c;for(const o of e)t.destroy.load(o?.destroy)}particleDestroyed(t,e){if(e)return;const o=t.options.destroy;o?.mode===s.split&&function(t,e,o){const s=o.options.destroy;if(!s)return;const l=s.split;if(l.count>=0&&(void 0===o.splitCount||o.splitCount++>l.count))return;const n=(0,i.getRangeValue)(l.rate.value),r=(0,i.itemFromSingleOrMultiple)(l.particles);for(let s=0;s<n;s++)u(t,e,o,r)}(this.engine,this.container,t)}update(t){if(!this.isEnabled(t))return;const e=t.getPosition(),o=t.destroyBounds;o&&(void 0!==o.bottom&&e.y>=o.bottom||void 0!==o.left&&e.x<=o.left||void 0!==o.right&&e.x>=o.right||void 0!==o.top&&e.y<=o.top)&&t.destroy()}}}}]);
|
package/72.min.js.LICENSE.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Destroy Updater v4.0.0-alpha.8 by Matteo Bruni */
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Destroy Updater v4.0.0-alpha.8 by Matteo Bruni */
|