@tsparticles/updater-destroy 4.0.0-beta.0 → 4.0.0-beta.10
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/960.min.js +1 -0
- package/README.md +29 -0
- package/browser/DestroyUpdater.js +7 -7
- package/browser/Utils.js +50 -60
- package/browser/index.js +4 -4
- package/cjs/DestroyUpdater.js +7 -7
- package/cjs/Utils.js +50 -60
- package/cjs/index.js +4 -4
- package/dist_browser_DestroyUpdater_js.js +3 -3
- package/esm/DestroyUpdater.js +7 -7
- package/esm/Utils.js +50 -60
- package/esm/index.js +4 -4
- package/package.json +4 -5
- 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/819.min.js +0 -1
- package/umd/DestroyUpdater.js +0 -82
- package/umd/Enums/DestroyMode.js +0 -18
- package/umd/Options/Classes/Destroy.js +0 -40
- package/umd/Options/Classes/DestroyBounds.js +0 -38
- package/umd/Options/Classes/Split.js +0 -80
- package/umd/Options/Classes/SplitFactor.js +0 -21
- package/umd/Options/Classes/SplitRate.js +0 -21
- package/umd/Options/Interfaces/IDestroy.js +0 -12
- package/umd/Options/Interfaces/IDestroyBounds.js +0 -12
- package/umd/Options/Interfaces/ISplit.js +0 -12
- package/umd/Types.js +0 -12
- package/umd/Utils.js +0 -117
- package/umd/index.js +0 -56
package/esm/Utils.js
CHANGED
|
@@ -1,60 +1,43 @@
|
|
|
1
1
|
import { AnimatableColor, PixelMode, getRangeValue, identity, isNumber, itemFromSingleOrMultiple, loadParticlesOptions, randomInRangeValue, setRangeValue, } from "@tsparticles/engine";
|
|
2
|
-
const defaultOffset = 0, minDestroySize = 0.5, defaultSplitCount = 0, increment = 1, unbreakableTime = 500, minSplitCount = 0;
|
|
3
|
-
function
|
|
2
|
+
const defaultOffset = 0, minDestroySize = 0.5, defaultSplitCount = 0, increment = 1, unbreakableTime = 500, minSplitCount = 0, minHue = 0, hueRange = 360, minSaturation = 0, maxSaturation = 100, minLightness = 0, maxLightness = 100;
|
|
3
|
+
function createParentColor(parentColor) {
|
|
4
|
+
return AnimatableColor.create(undefined, {
|
|
5
|
+
value: {
|
|
6
|
+
hsl: parentColor,
|
|
7
|
+
},
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
function createOffsetColor(parentColor, offset) {
|
|
11
|
+
const offsetH = getRangeValue(offset.h ?? defaultOffset), offsetS = getRangeValue(offset.s ?? defaultOffset), offsetL = getRangeValue(offset.l ?? defaultOffset), h = (parentColor.h + offsetH) % hueRange, s = Math.max(minSaturation, Math.min(maxSaturation, parentColor.s + offsetS)), l = Math.max(minLightness, Math.min(maxLightness, parentColor.l + offsetL));
|
|
12
|
+
return AnimatableColor.create(undefined, {
|
|
13
|
+
value: {
|
|
14
|
+
hsl: {
|
|
15
|
+
h: h < minHue ? h + hueRange : h,
|
|
16
|
+
s,
|
|
17
|
+
l,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function resolveSplitColor(offset, splitColor, splitParticlesColor, parentColor) {
|
|
23
|
+
if (offset && parentColor) {
|
|
24
|
+
return createOffsetColor(parentColor, offset);
|
|
25
|
+
}
|
|
26
|
+
if (splitColor) {
|
|
27
|
+
return AnimatableColor.create(undefined, splitColor);
|
|
28
|
+
}
|
|
29
|
+
if (splitParticlesColor) {
|
|
30
|
+
return AnimatableColor.create(undefined, splitParticlesColor);
|
|
31
|
+
}
|
|
32
|
+
return parentColor ? createParentColor(parentColor) : undefined;
|
|
33
|
+
}
|
|
34
|
+
function addSplitParticle(pluginManager, container, parent, splitParticlesOptions) {
|
|
4
35
|
const destroyOptions = parent.options.destroy;
|
|
5
36
|
if (!destroyOptions) {
|
|
6
37
|
return;
|
|
7
38
|
}
|
|
8
|
-
const splitOptions = destroyOptions.split,
|
|
9
|
-
|
|
10
|
-
const fillColor = AnimatableColor.create(undefined, fillOptions.color), parentFillColor = parent.getFillColor();
|
|
11
|
-
if (fillColor.value) {
|
|
12
|
-
fillColor.load(splitOptions.fillColor);
|
|
13
|
-
}
|
|
14
|
-
else if (splitOptions.fillColorOffset && parentFillColor) {
|
|
15
|
-
fillColor.load({
|
|
16
|
-
value: {
|
|
17
|
-
hsl: {
|
|
18
|
-
h: parentFillColor.h + getRangeValue(splitOptions.fillColorOffset.h ?? defaultOffset),
|
|
19
|
-
s: parentFillColor.s + getRangeValue(splitOptions.fillColorOffset.s ?? defaultOffset),
|
|
20
|
-
l: parentFillColor.l + getRangeValue(splitOptions.fillColorOffset.l ?? defaultOffset),
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
fillColor.load({
|
|
27
|
-
value: {
|
|
28
|
-
hsl: parent.getFillColor(),
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (strokeOptions?.width) {
|
|
34
|
-
const strokeColor = AnimatableColor.create(undefined, strokeOptions.color), parentStrokeColor = parent.getStrokeColor();
|
|
35
|
-
if (strokeColor.value) {
|
|
36
|
-
strokeColor.load(splitOptions.strokeColor);
|
|
37
|
-
}
|
|
38
|
-
else if (splitOptions.strokeColorOffset && parentStrokeColor) {
|
|
39
|
-
strokeColor.load({
|
|
40
|
-
value: {
|
|
41
|
-
hsl: {
|
|
42
|
-
h: parentStrokeColor.h + getRangeValue(splitOptions.strokeColorOffset.h ?? defaultOffset),
|
|
43
|
-
s: parentStrokeColor.s + getRangeValue(splitOptions.strokeColorOffset.s ?? defaultOffset),
|
|
44
|
-
l: parentStrokeColor.l + getRangeValue(splitOptions.strokeColorOffset.l ?? defaultOffset),
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
strokeColor.load({
|
|
51
|
-
value: {
|
|
52
|
-
hsl: parent.getStrokeColor(),
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
options.move.load({
|
|
39
|
+
const splitOptions = destroyOptions.split, splitParticleOptions = loadParticlesOptions(pluginManager, container, parent.options), splitFillColor = itemFromSingleOrMultiple(splitOptions.fillColor), splitStrokeColor = itemFromSingleOrMultiple(splitOptions.strokeColor), parentFillColor = parent.getFillColor(), parentStrokeColor = parent.getStrokeColor();
|
|
40
|
+
splitParticleOptions.move.load({
|
|
58
41
|
center: {
|
|
59
42
|
x: parent.position.x,
|
|
60
43
|
y: parent.position.y,
|
|
@@ -62,19 +45,26 @@ function addSplitParticle(engine, container, parent, splitParticlesOptions) {
|
|
|
62
45
|
},
|
|
63
46
|
});
|
|
64
47
|
const factor = identity / getRangeValue(splitOptions.factor.value);
|
|
65
|
-
if (isNumber(
|
|
66
|
-
|
|
48
|
+
if (isNumber(splitParticleOptions.size.value)) {
|
|
49
|
+
splitParticleOptions.size.value *= factor;
|
|
67
50
|
}
|
|
68
51
|
else {
|
|
69
|
-
|
|
70
|
-
|
|
52
|
+
splitParticleOptions.size.value.min *= factor;
|
|
53
|
+
splitParticleOptions.size.value.max *= factor;
|
|
54
|
+
}
|
|
55
|
+
splitParticleOptions.load(splitParticlesOptions);
|
|
56
|
+
const splitParticlePaintOptions = itemFromSingleOrMultiple(splitParticleOptions.paint), splitParticleFillOptions = splitParticlePaintOptions?.fill, splitParticleStrokeOptions = splitParticlePaintOptions?.stroke, fillColor = resolveSplitColor(splitOptions.fillColorOffset, splitFillColor, splitParticleFillOptions?.color, parentFillColor), strokeColor = resolveSplitColor(splitOptions.strokeColorOffset, splitStrokeColor, splitParticleStrokeOptions?.color, parentStrokeColor);
|
|
57
|
+
if (fillColor && splitParticleFillOptions) {
|
|
58
|
+
splitParticleFillOptions.color = fillColor;
|
|
59
|
+
}
|
|
60
|
+
if (strokeColor && splitParticleStrokeOptions) {
|
|
61
|
+
splitParticleStrokeOptions.color = strokeColor;
|
|
71
62
|
}
|
|
72
|
-
options.load(splitParticlesOptions);
|
|
73
63
|
const offset = splitOptions.sizeOffset ? setRangeValue(-parent.size.value, parent.size.value) : defaultOffset, position = {
|
|
74
64
|
x: parent.position.x + randomInRangeValue(offset),
|
|
75
65
|
y: parent.position.y + randomInRangeValue(offset),
|
|
76
66
|
};
|
|
77
|
-
return container.particles.addParticle(position,
|
|
67
|
+
return container.particles.addParticle(position, splitParticleOptions, parent.group, (particle) => {
|
|
78
68
|
if (particle.size.value < minDestroySize) {
|
|
79
69
|
return false;
|
|
80
70
|
}
|
|
@@ -85,7 +75,7 @@ function addSplitParticle(engine, container, parent, splitParticlesOptions) {
|
|
|
85
75
|
return true;
|
|
86
76
|
});
|
|
87
77
|
}
|
|
88
|
-
export function split(
|
|
78
|
+
export function split(pluginManager, container, particle) {
|
|
89
79
|
const destroyOptions = particle.options.destroy;
|
|
90
80
|
if (!destroyOptions) {
|
|
91
81
|
return;
|
|
@@ -99,6 +89,6 @@ export function split(engine, container, particle) {
|
|
|
99
89
|
}
|
|
100
90
|
const rate = getRangeValue(splitOptions.rate.value), particlesSplitOptions = itemFromSingleOrMultiple(splitOptions.particles);
|
|
101
91
|
for (let i = 0; i < rate; i++) {
|
|
102
|
-
addSplitParticle(
|
|
92
|
+
addSplitParticle(pluginManager, container, particle, particlesSplitOptions);
|
|
103
93
|
}
|
|
104
94
|
}
|
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.10");
|
|
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.10",
|
|
4
4
|
"description": "tsParticles particles destroy updater",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -81,13 +81,12 @@
|
|
|
81
81
|
"browser": "./browser/index.js",
|
|
82
82
|
"import": "./esm/index.js",
|
|
83
83
|
"require": "./cjs/index.js",
|
|
84
|
-
"
|
|
85
|
-
"default": "./cjs/index.js"
|
|
84
|
+
"default": "./esm/index.js"
|
|
86
85
|
},
|
|
87
86
|
"./package.json": "./package.json"
|
|
88
87
|
},
|
|
89
|
-
"
|
|
90
|
-
"@tsparticles/engine": "4.0.0-beta.
|
|
88
|
+
"peerDependencies": {
|
|
89
|
+
"@tsparticles/engine": "4.0.0-beta.10"
|
|
91
90
|
},
|
|
92
91
|
"publishConfig": {
|
|
93
92
|
"access": "public"
|