@tsparticles/engine 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/67.min.js +1 -0
- package/README.md +53 -965
- package/browser/Core/CanvasManager.js +303 -0
- package/browser/Core/Container.js +61 -34
- package/browser/Core/Engine.js +26 -138
- package/browser/Core/Particle.js +29 -28
- package/{cjs/Core/Particles.js → browser/Core/ParticlesManager.js} +27 -57
- package/browser/Core/RenderManager.js +303 -0
- package/browser/Core/Retina.js +3 -8
- package/browser/Core/Utils/PluginManager.js +145 -0
- package/browser/Options/Classes/Options.js +8 -21
- package/browser/Options/Classes/Particles/Paint.js +20 -0
- package/browser/Options/Classes/Particles/ParticlesOptions.js +65 -27
- package/browser/Options/Interfaces/Particles/IPaint.js +1 -0
- package/browser/Types/CanvasContextType.js +1 -0
- package/browser/Utils/CanvasUtils.js +4 -4
- package/browser/Utils/ColorUtils.js +21 -21
- package/browser/Utils/LogUtils.js +1 -0
- package/browser/Utils/OptionsUtils.js +2 -2
- package/browser/Utils/Utils.js +16 -10
- package/browser/exports.js +1 -0
- package/cjs/Core/CanvasManager.js +303 -0
- package/cjs/Core/Container.js +61 -34
- package/cjs/Core/Engine.js +26 -138
- package/cjs/Core/Particle.js +29 -28
- package/{esm/Core/Particles.js → cjs/Core/ParticlesManager.js} +27 -57
- package/cjs/Core/RenderManager.js +303 -0
- package/cjs/Core/Retina.js +3 -8
- package/cjs/Core/Utils/PluginManager.js +145 -0
- package/cjs/Options/Classes/Options.js +8 -21
- package/cjs/Options/Classes/Particles/Paint.js +20 -0
- package/cjs/Options/Classes/Particles/ParticlesOptions.js +65 -27
- package/cjs/Options/Interfaces/Particles/IPaint.js +1 -0
- package/cjs/Types/CanvasContextType.js +1 -0
- package/cjs/Utils/CanvasUtils.js +4 -4
- package/cjs/Utils/ColorUtils.js +21 -21
- package/cjs/Utils/LogUtils.js +1 -0
- package/cjs/Utils/OptionsUtils.js +2 -2
- package/cjs/Utils/Utils.js +16 -10
- package/cjs/exports.js +1 -0
- package/dist_browser_Core_Container_js.js +24 -14
- package/esm/Core/CanvasManager.js +303 -0
- package/esm/Core/Container.js +61 -34
- package/esm/Core/Engine.js +26 -138
- package/esm/Core/Particle.js +29 -28
- package/{browser/Core/Particles.js → esm/Core/ParticlesManager.js} +27 -57
- package/esm/Core/RenderManager.js +303 -0
- package/esm/Core/Retina.js +3 -8
- package/esm/Core/Utils/PluginManager.js +145 -0
- package/esm/Options/Classes/Options.js +8 -21
- package/esm/Options/Classes/Particles/Paint.js +20 -0
- package/esm/Options/Classes/Particles/ParticlesOptions.js +65 -27
- package/esm/Options/Interfaces/Particles/IPaint.js +1 -0
- package/esm/Types/CanvasContextType.js +1 -0
- package/esm/Utils/CanvasUtils.js +4 -4
- package/esm/Utils/ColorUtils.js +21 -21
- package/esm/Utils/LogUtils.js +1 -0
- package/esm/Utils/OptionsUtils.js +2 -2
- package/esm/Utils/Utils.js +16 -10
- package/esm/exports.js +1 -0
- package/package.json +2 -3
- package/report.html +84 -29
- package/tsparticles.engine.js +31 -11
- package/tsparticles.engine.min.js +2 -2
- package/types/Core/CanvasManager.d.ts +39 -0
- package/types/Core/Container.d.ts +26 -7
- package/types/Core/Engine.d.ts +2 -54
- package/types/Core/Interfaces/IContainerPlugin.d.ts +8 -7
- package/types/Core/Interfaces/IDrawParticleParams.d.ts +2 -1
- package/types/Core/Interfaces/IPalette.d.ts +15 -2
- package/types/Core/Interfaces/IParticleRetinaProps.d.ts +4 -4
- package/types/Core/Interfaces/IParticleUpdater.d.ts +2 -1
- package/types/Core/Interfaces/IShapeDrawData.d.ts +2 -1
- package/types/Core/Particle.d.ts +4 -4
- package/types/Core/{Particles.d.ts → ParticlesManager.d.ts} +4 -11
- package/types/Core/{Canvas.d.ts → RenderManager.d.ts} +12 -33
- package/types/Core/Retina.d.ts +0 -2
- package/types/Core/Utils/PluginManager.d.ts +62 -0
- package/types/Options/Classes/Options.d.ts +3 -3
- package/types/Options/Classes/Particles/Paint.d.ts +10 -0
- package/types/Options/Classes/Particles/ParticlesOptions.d.ts +7 -7
- package/types/Options/Interfaces/Particles/IPaint.d.ts +6 -0
- package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +3 -4
- package/types/Types/CanvasContextType.d.ts +1 -0
- package/types/Utils/CanvasUtils.d.ts +8 -5
- package/types/Utils/ColorUtils.d.ts +8 -8
- package/types/Utils/LogUtils.d.ts +1 -0
- package/types/Utils/OptionsUtils.d.ts +2 -2
- package/types/export-types.d.ts +5 -2
- package/types/exports.d.ts +1 -0
- package/164.min.js +0 -1
- package/browser/Core/Canvas.js +0 -570
- package/cjs/Core/Canvas.js +0 -570
- package/esm/Core/Canvas.js +0 -570
- package/umd/Core/Canvas.js +0 -584
- package/umd/Core/Container.js +0 -356
- package/umd/Core/Engine.js +0 -295
- package/umd/Core/Interfaces/Colors.js +0 -12
- package/umd/Core/Interfaces/IBounds.js +0 -12
- package/umd/Core/Interfaces/IBubbleParticleData.js +0 -12
- package/umd/Core/Interfaces/ICircleBouncer.js +0 -12
- package/umd/Core/Interfaces/IColorManager.js +0 -12
- package/umd/Core/Interfaces/IContainerPlugin.js +0 -12
- package/umd/Core/Interfaces/ICoordinates.js +0 -12
- package/umd/Core/Interfaces/IDelta.js +0 -12
- package/umd/Core/Interfaces/IDimension.js +0 -12
- package/umd/Core/Interfaces/IDistance.js +0 -12
- package/umd/Core/Interfaces/IDrawParticleParams.js +0 -12
- package/umd/Core/Interfaces/IEffectDrawer.js +0 -12
- package/umd/Core/Interfaces/ILoadParams.js +0 -12
- package/umd/Core/Interfaces/IPalette.js +0 -12
- package/umd/Core/Interfaces/IParticleColorStyle.js +0 -12
- package/umd/Core/Interfaces/IParticleHslAnimation.js +0 -12
- package/umd/Core/Interfaces/IParticleLife.js +0 -12
- package/umd/Core/Interfaces/IParticleOpacityData.js +0 -12
- package/umd/Core/Interfaces/IParticleRetinaProps.js +0 -12
- package/umd/Core/Interfaces/IParticleRoll.js +0 -12
- package/umd/Core/Interfaces/IParticleRotateData.js +0 -12
- package/umd/Core/Interfaces/IParticleTransformValues.js +0 -12
- package/umd/Core/Interfaces/IParticleUpdater.js +0 -12
- package/umd/Core/Interfaces/IParticleValueAnimation.js +0 -12
- package/umd/Core/Interfaces/IPlugin.js +0 -12
- package/umd/Core/Interfaces/IPositionFromSizeParams.js +0 -12
- package/umd/Core/Interfaces/IRangeValue.js +0 -12
- package/umd/Core/Interfaces/IShapeDrawData.js +0 -12
- package/umd/Core/Interfaces/IShapeDrawer.js +0 -12
- package/umd/Core/Interfaces/IShapeValues.js +0 -12
- package/umd/Core/Interfaces/ISlowParticleData.js +0 -12
- package/umd/Core/Particle.js +0 -432
- package/umd/Core/Particles.js +0 -407
- package/umd/Core/Retina.js +0 -52
- package/umd/Core/Utils/Constants.js +0 -23
- package/umd/Core/Utils/EventListeners.js +0 -102
- package/umd/Core/Utils/Ranges.js +0 -91
- package/umd/Core/Utils/SpatialHashGrid.js +0 -116
- package/umd/Core/Utils/Vectors.js +0 -126
- package/umd/Enums/AnimationStatus.js +0 -18
- package/umd/Enums/Directions/MoveDirection.js +0 -27
- package/umd/Enums/Directions/OutModeDirection.js +0 -20
- package/umd/Enums/Directions/RotateDirection.js +0 -19
- package/umd/Enums/Modes/AnimationMode.js +0 -20
- package/umd/Enums/Modes/LimitMode.js +0 -18
- package/umd/Enums/Modes/OutMode.js +0 -21
- package/umd/Enums/Modes/PixelMode.js +0 -18
- package/umd/Enums/RangeType.js +0 -18
- package/umd/Enums/Types/AlterType.js +0 -18
- package/umd/Enums/Types/DestroyType.js +0 -19
- package/umd/Enums/Types/EasingType.js +0 -58
- package/umd/Enums/Types/EventType.js +0 -28
- package/umd/Enums/Types/GradientType.js +0 -19
- package/umd/Enums/Types/ParticleOutType.js +0 -19
- package/umd/Enums/Types/StartValueType.js +0 -19
- package/umd/Options/Classes/AnimatableColor.js +0 -52
- package/umd/Options/Classes/AnimationOptions.js +0 -79
- package/umd/Options/Classes/Background/Background.js +0 -56
- package/umd/Options/Classes/ColorAnimation.js +0 -44
- package/umd/Options/Classes/FullScreen/FullScreen.js +0 -34
- package/umd/Options/Classes/HslAnimation.js +0 -30
- package/umd/Options/Classes/Options.js +0 -171
- package/umd/Options/Classes/OptionsColor.js +0 -42
- package/umd/Options/Classes/Particles/Bounce/ParticlesBounce.js +0 -31
- package/umd/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +0 -21
- package/umd/Options/Classes/Particles/Effect/Effect.js +0 -46
- package/umd/Options/Classes/Particles/Fill.js +0 -42
- package/umd/Options/Classes/Particles/Move/Move.js +0 -120
- package/umd/Options/Classes/Particles/Move/MoveAngle.js +0 -35
- package/umd/Options/Classes/Particles/Move/MoveCenter.js +0 -45
- package/umd/Options/Classes/Particles/Move/MoveGravity.js +0 -45
- package/umd/Options/Classes/Particles/Move/OutModes.js +0 -38
- package/umd/Options/Classes/Particles/Move/Path/MovePath.js +0 -46
- package/umd/Options/Classes/Particles/Move/Spin.js +0 -40
- package/umd/Options/Classes/Particles/Number/ParticlesDensity.js +0 -41
- package/umd/Options/Classes/Particles/Number/ParticlesNumber.js +0 -37
- package/umd/Options/Classes/Particles/Number/ParticlesNumberLimit.js +0 -35
- package/umd/Options/Classes/Particles/Opacity/Opacity.js +0 -35
- package/umd/Options/Classes/Particles/Opacity/OpacityAnimation.js +0 -34
- package/umd/Options/Classes/Particles/ParticlesOptions.js +0 -116
- package/umd/Options/Classes/Particles/Shape/Shape.js +0 -46
- package/umd/Options/Classes/Particles/Size/Size.js +0 -35
- package/umd/Options/Classes/Particles/Size/SizeAnimation.js +0 -34
- package/umd/Options/Classes/Particles/Stroke.js +0 -39
- package/umd/Options/Classes/Particles/ZIndex/ZIndex.js +0 -42
- package/umd/Options/Classes/ResizeEvent.js +0 -34
- package/umd/Options/Classes/ValueWithRandom.js +0 -56
- package/umd/Options/Interfaces/Background/IBackground.js +0 -12
- package/umd/Options/Interfaces/FullScreen/IFullScreen.js +0 -12
- package/umd/Options/Interfaces/IAnimatable.js +0 -12
- package/umd/Options/Interfaces/IAnimatableColor.js +0 -12
- package/umd/Options/Interfaces/IAnimation.js +0 -12
- package/umd/Options/Interfaces/IColorAnimation.js +0 -12
- package/umd/Options/Interfaces/IHslAnimation.js +0 -12
- package/umd/Options/Interfaces/IOptionLoader.js +0 -12
- package/umd/Options/Interfaces/IOptions.js +0 -12
- package/umd/Options/Interfaces/IOptionsColor.js +0 -12
- package/umd/Options/Interfaces/IResizeEvent.js +0 -12
- package/umd/Options/Interfaces/IValueWithRandom.js +0 -12
- package/umd/Options/Interfaces/Particles/Bounce/IParticlesBounce.js +0 -12
- package/umd/Options/Interfaces/Particles/Effect/IEffect.js +0 -12
- package/umd/Options/Interfaces/Particles/IFill.js +0 -12
- package/umd/Options/Interfaces/Particles/IParticlesOptions.js +0 -12
- package/umd/Options/Interfaces/Particles/IStroke.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMove.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMoveAngle.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMoveCenter.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMoveGravity.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IOutModes.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/ISpin.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/Path/IMovePath.js +0 -12
- package/umd/Options/Interfaces/Particles/Number/IParticlesDensity.js +0 -12
- package/umd/Options/Interfaces/Particles/Number/IParticlesNumber.js +0 -12
- package/umd/Options/Interfaces/Particles/Number/IParticlesNumberLimit.js +0 -12
- package/umd/Options/Interfaces/Particles/Opacity/IOpacity.js +0 -12
- package/umd/Options/Interfaces/Particles/Opacity/IOpacityAnimation.js +0 -12
- package/umd/Options/Interfaces/Particles/Shape/IShape.js +0 -12
- package/umd/Options/Interfaces/Particles/Size/ISize.js +0 -12
- package/umd/Options/Interfaces/Particles/Size/ISizeAnimation.js +0 -12
- package/umd/Options/Interfaces/Particles/ZIndex/IZIndex.js +0 -12
- package/umd/Types/CustomEventArgs.js +0 -12
- package/umd/Types/CustomEventListener.js +0 -12
- package/umd/Types/EasingFunction.js +0 -12
- package/umd/Types/EngineInitializers.js +0 -12
- package/umd/Types/ExportResult.js +0 -12
- package/umd/Types/ISourceOptions.js +0 -12
- package/umd/Types/ParticlesGroups.js +0 -12
- package/umd/Types/PathOptions.js +0 -12
- package/umd/Types/RangeValue.js +0 -12
- package/umd/Types/RecursivePartial.js +0 -12
- package/umd/Types/ShapeData.js +0 -12
- package/umd/Types/SingleOrMultiple.js +0 -12
- package/umd/Utils/CanvasUtils.js +0 -145
- package/umd/Utils/ColorUtils.js +0 -395
- package/umd/Utils/EventDispatcher.js +0 -63
- package/umd/Utils/LogUtils.js +0 -36
- package/umd/Utils/MathUtils.js +0 -203
- package/umd/Utils/OptionsUtils.js +0 -25
- package/umd/Utils/TypeUtils.js +0 -40
- package/umd/Utils/Utils.js +0 -484
- package/umd/bundle.js +0 -32
- package/umd/export-types.js +0 -12
- package/umd/exports.js +0 -82
- package/umd/index.js +0 -32
- package/umd/initEngine.js +0 -17
|
@@ -1,50 +1,52 @@
|
|
|
1
1
|
import { deepExtend, executeOnSingleOrMultiple } from "../../../Utils/Utils.js";
|
|
2
|
+
import { isArray, isNull } from "../../../Utils/TypeUtils.js";
|
|
2
3
|
import { Effect } from "./Effect/Effect.js";
|
|
3
|
-
import { Fill } from "./Fill.js";
|
|
4
4
|
import { Move } from "./Move/Move.js";
|
|
5
5
|
import { Opacity } from "./Opacity/Opacity.js";
|
|
6
|
+
import { Paint } from "./Paint.js";
|
|
6
7
|
import { ParticlesBounce } from "./Bounce/ParticlesBounce.js";
|
|
7
8
|
import { ParticlesNumber } from "./Number/ParticlesNumber.js";
|
|
8
9
|
import { Shape } from "./Shape/Shape.js";
|
|
9
10
|
import { Size } from "./Size/Size.js";
|
|
10
|
-
import { Stroke } from "./Stroke.js";
|
|
11
11
|
import { ZIndex } from "./ZIndex/ZIndex.js";
|
|
12
|
-
import { isNull } from "../../../Utils/TypeUtils.js";
|
|
13
12
|
export class ParticlesOptions {
|
|
14
13
|
bounce;
|
|
15
14
|
effect;
|
|
16
|
-
fill;
|
|
17
15
|
groups;
|
|
18
16
|
move;
|
|
19
17
|
number;
|
|
20
18
|
opacity;
|
|
19
|
+
paint;
|
|
20
|
+
palette;
|
|
21
21
|
reduceDuplicates;
|
|
22
22
|
shape;
|
|
23
23
|
size;
|
|
24
|
-
stroke;
|
|
25
24
|
zIndex;
|
|
26
25
|
_container;
|
|
27
|
-
|
|
28
|
-
constructor(
|
|
29
|
-
this.
|
|
26
|
+
_pluginManager;
|
|
27
|
+
constructor(pluginManager, container) {
|
|
28
|
+
this._pluginManager = pluginManager;
|
|
30
29
|
this._container = container;
|
|
31
30
|
this.bounce = new ParticlesBounce();
|
|
32
31
|
this.effect = new Effect();
|
|
33
|
-
this.fill = new Fill();
|
|
34
32
|
this.groups = {};
|
|
35
33
|
this.move = new Move();
|
|
36
34
|
this.number = new ParticlesNumber();
|
|
37
35
|
this.opacity = new Opacity();
|
|
36
|
+
this.paint = new Paint();
|
|
38
37
|
this.reduceDuplicates = false;
|
|
39
38
|
this.shape = new Shape();
|
|
40
39
|
this.size = new Size();
|
|
41
|
-
this.stroke = new Stroke();
|
|
42
40
|
this.zIndex = new ZIndex();
|
|
43
41
|
}
|
|
44
42
|
load(data) {
|
|
45
43
|
if (isNull(data)) {
|
|
46
44
|
return;
|
|
47
45
|
}
|
|
46
|
+
if (data.palette) {
|
|
47
|
+
this.palette = data.palette;
|
|
48
|
+
this._importPalette(this.palette);
|
|
49
|
+
}
|
|
48
50
|
if (data.groups !== undefined) {
|
|
49
51
|
for (const group of Object.keys(data.groups)) {
|
|
50
52
|
if (!(group in data.groups)) {
|
|
@@ -64,32 +66,24 @@ export class ParticlesOptions {
|
|
|
64
66
|
this.move.load(data.move);
|
|
65
67
|
this.number.load(data.number);
|
|
66
68
|
this.opacity.load(data.opacity);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (fillToLoad) {
|
|
72
|
-
this.fill = executeOnSingleOrMultiple(fillToLoad, t => {
|
|
73
|
-
const tmp = new Fill();
|
|
74
|
-
tmp.load(t);
|
|
75
|
-
return tmp;
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
const strokeToLoad = data.stroke;
|
|
79
|
-
if (strokeToLoad) {
|
|
80
|
-
this.stroke = executeOnSingleOrMultiple(strokeToLoad, t => {
|
|
81
|
-
const tmp = new Stroke();
|
|
69
|
+
const paintToLoad = data.paint;
|
|
70
|
+
if (paintToLoad) {
|
|
71
|
+
this.paint = executeOnSingleOrMultiple(paintToLoad, t => {
|
|
72
|
+
const tmp = new Paint();
|
|
82
73
|
tmp.load(t);
|
|
83
74
|
return tmp;
|
|
84
75
|
});
|
|
85
76
|
}
|
|
77
|
+
this.shape.load(data.shape);
|
|
78
|
+
this.size.load(data.size);
|
|
79
|
+
this.zIndex.load(data.zIndex);
|
|
86
80
|
if (this._container) {
|
|
87
|
-
for (const plugin of this.
|
|
81
|
+
for (const plugin of this._pluginManager.plugins) {
|
|
88
82
|
if (plugin.loadParticlesOptions) {
|
|
89
83
|
plugin.loadParticlesOptions(this._container, this, data);
|
|
90
84
|
}
|
|
91
85
|
}
|
|
92
|
-
const updaters = this.
|
|
86
|
+
const updaters = this._pluginManager.updaters.get(this._container);
|
|
93
87
|
if (updaters) {
|
|
94
88
|
for (const updater of updaters) {
|
|
95
89
|
if (updater.loadOptions) {
|
|
@@ -99,4 +93,48 @@ export class ParticlesOptions {
|
|
|
99
93
|
}
|
|
100
94
|
}
|
|
101
95
|
}
|
|
96
|
+
_importPalette = (palette) => {
|
|
97
|
+
const paletteData = this._pluginManager.getPalette(palette);
|
|
98
|
+
if (!paletteData) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const paletteColors = paletteData.colors, paletteFill = paletteColors.fill, paletteStroke = paletteColors.stroke, defaultPaintStrokeIndex = 0, defaultPaintStrokeWidth = 0, palettePaint = {
|
|
102
|
+
fill: paletteFill
|
|
103
|
+
? {
|
|
104
|
+
color: {
|
|
105
|
+
value: paletteFill.value,
|
|
106
|
+
},
|
|
107
|
+
enable: paletteFill.enable,
|
|
108
|
+
}
|
|
109
|
+
: undefined,
|
|
110
|
+
};
|
|
111
|
+
if (paletteStroke) {
|
|
112
|
+
if (isArray(paletteStroke)) {
|
|
113
|
+
const firstStroke = paletteStroke[defaultPaintStrokeIndex];
|
|
114
|
+
if (firstStroke) {
|
|
115
|
+
palettePaint.stroke = {
|
|
116
|
+
color: {
|
|
117
|
+
value: firstStroke.value,
|
|
118
|
+
},
|
|
119
|
+
width: firstStroke.width || defaultPaintStrokeWidth,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
palettePaint.stroke = {
|
|
125
|
+
color: {
|
|
126
|
+
value: paletteStroke.value,
|
|
127
|
+
},
|
|
128
|
+
width: paletteStroke.width,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
this.load({
|
|
133
|
+
paint: palettePaint,
|
|
134
|
+
blend: {
|
|
135
|
+
enable: true,
|
|
136
|
+
mode: paletteData.blendMode,
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
};
|
|
102
140
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -16,7 +16,7 @@ export function clear(context, dimension) {
|
|
|
16
16
|
context.clearRect(originPoint.x, originPoint.y, dimension.width, dimension.height);
|
|
17
17
|
}
|
|
18
18
|
export function drawParticle(data) {
|
|
19
|
-
const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, { effectDrawers, shapeDrawers } = container
|
|
19
|
+
const { container, context, particle, delta, colorStyles, radius, opacity, transform } = data, { effectDrawers, shapeDrawers } = container, pos = particle.getPosition(), transformData = particle.getTransformData(transform), drawScale = defaultZoom, drawPosition = {
|
|
20
20
|
x: pos.x,
|
|
21
21
|
y: pos.y,
|
|
22
22
|
};
|
|
@@ -88,12 +88,12 @@ export function drawShape(drawer, data) {
|
|
|
88
88
|
if (particle.shapeClose) {
|
|
89
89
|
context.closePath();
|
|
90
90
|
}
|
|
91
|
-
if (stroke) {
|
|
92
|
-
context.stroke();
|
|
93
|
-
}
|
|
94
91
|
if (fill) {
|
|
95
92
|
context.fill();
|
|
96
93
|
}
|
|
94
|
+
if (stroke) {
|
|
95
|
+
context.stroke();
|
|
96
|
+
}
|
|
97
97
|
}
|
|
98
98
|
export function drawShapeAfterDraw(drawer, data) {
|
|
99
99
|
if (!drawer?.afterDraw) {
|
|
@@ -17,35 +17,35 @@ function getCachedStyle(key, generator) {
|
|
|
17
17
|
}
|
|
18
18
|
return cached;
|
|
19
19
|
}
|
|
20
|
-
function stringToRgba(
|
|
20
|
+
function stringToRgba(pluginManager, input) {
|
|
21
21
|
if (!input) {
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
|
-
for (const manager of
|
|
24
|
+
for (const manager of pluginManager.colorManagers.values()) {
|
|
25
25
|
if (manager.accepts(input)) {
|
|
26
26
|
return manager.parseString(input);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
return undefined;
|
|
30
30
|
}
|
|
31
|
-
export function rangeColorToRgb(
|
|
31
|
+
export function rangeColorToRgb(pluginManager, input, index, useIndex = true) {
|
|
32
32
|
if (!input) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
const color = isString(input) ? { value: input } : input;
|
|
36
36
|
if (isString(color.value)) {
|
|
37
|
-
return colorToRgb(
|
|
37
|
+
return colorToRgb(pluginManager, color.value, index, useIndex);
|
|
38
38
|
}
|
|
39
39
|
if (isArray(color.value)) {
|
|
40
40
|
const value = itemFromArray(color.value, index, useIndex);
|
|
41
41
|
if (!value) {
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
return rangeColorToRgb(
|
|
44
|
+
return rangeColorToRgb(pluginManager, {
|
|
45
45
|
value,
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
for (const manager of
|
|
48
|
+
for (const manager of pluginManager.colorManagers.values()) {
|
|
49
49
|
const res = manager.handleRangeColor(color);
|
|
50
50
|
if (res) {
|
|
51
51
|
return res;
|
|
@@ -53,24 +53,24 @@ export function rangeColorToRgb(engine, input, index, useIndex = true) {
|
|
|
53
53
|
}
|
|
54
54
|
return undefined;
|
|
55
55
|
}
|
|
56
|
-
export function colorToRgb(
|
|
56
|
+
export function colorToRgb(pluginManager, input, index, useIndex = true) {
|
|
57
57
|
if (!input) {
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
60
|
const color = isString(input) ? { value: input } : input;
|
|
61
61
|
if (isString(color.value)) {
|
|
62
|
-
return color.value === randomColorValue ? getRandomRgbColor() : stringToRgb(
|
|
62
|
+
return color.value === randomColorValue ? getRandomRgbColor() : stringToRgb(pluginManager, color.value);
|
|
63
63
|
}
|
|
64
64
|
if (isArray(color.value)) {
|
|
65
65
|
const value = itemFromArray(color.value, index, useIndex);
|
|
66
66
|
if (!value) {
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
|
-
return colorToRgb(
|
|
69
|
+
return colorToRgb(pluginManager, {
|
|
70
70
|
value,
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
|
-
for (const manager of
|
|
73
|
+
for (const manager of pluginManager.colorManagers.values()) {
|
|
74
74
|
const res = manager.handleColor(color);
|
|
75
75
|
if (res) {
|
|
76
76
|
return res;
|
|
@@ -78,12 +78,12 @@ export function colorToRgb(engine, input, index, useIndex = true) {
|
|
|
78
78
|
}
|
|
79
79
|
return undefined;
|
|
80
80
|
}
|
|
81
|
-
export function colorToHsl(
|
|
82
|
-
const rgb = colorToRgb(
|
|
81
|
+
export function colorToHsl(pluginManager, color, index, useIndex = true) {
|
|
82
|
+
const rgb = colorToRgb(pluginManager, color, index, useIndex);
|
|
83
83
|
return rgb ? rgbToHsl(rgb) : undefined;
|
|
84
84
|
}
|
|
85
|
-
export function rangeColorToHsl(
|
|
86
|
-
const rgb = rangeColorToRgb(
|
|
85
|
+
export function rangeColorToHsl(pluginManager, color, index, useIndex = true) {
|
|
86
|
+
const rgb = rangeColorToRgb(pluginManager, color, index, useIndex);
|
|
87
87
|
return rgb ? rgbToHsl(rgb) : undefined;
|
|
88
88
|
}
|
|
89
89
|
export function rgbToHsl(color) {
|
|
@@ -115,11 +115,11 @@ export function rgbToHsl(color) {
|
|
|
115
115
|
}
|
|
116
116
|
return res;
|
|
117
117
|
}
|
|
118
|
-
export function stringToAlpha(
|
|
119
|
-
return stringToRgba(
|
|
118
|
+
export function stringToAlpha(pluginManager, input) {
|
|
119
|
+
return stringToRgba(pluginManager, input)?.a;
|
|
120
120
|
}
|
|
121
|
-
export function stringToRgb(
|
|
122
|
-
return stringToRgba(
|
|
121
|
+
export function stringToRgb(pluginManager, input) {
|
|
122
|
+
return stringToRgba(pluginManager, input);
|
|
123
123
|
}
|
|
124
124
|
export function hslToRgb(hsl) {
|
|
125
125
|
const h = ((hsl.h % hMax) + hMax) % hMax, s = Math.max(sMin, Math.min(sMax, hsl.s)), l = Math.max(lMin, Math.min(lMax, hsl.l)), hNormalized = h / hMax, sNormalized = s / sMax, lNormalized = l / lMax;
|
|
@@ -223,11 +223,11 @@ export function getLinkColor(p1, p2, linkColor) {
|
|
|
223
223
|
}
|
|
224
224
|
return undefined;
|
|
225
225
|
}
|
|
226
|
-
export function getLinkRandomColor(
|
|
226
|
+
export function getLinkRandomColor(pluginManager, optColor, blink, consent) {
|
|
227
227
|
const color = isString(optColor) ? optColor : optColor.value;
|
|
228
228
|
if (color === randomColorValue) {
|
|
229
229
|
if (consent) {
|
|
230
|
-
return rangeColorToRgb(
|
|
230
|
+
return rangeColorToRgb(pluginManager, {
|
|
231
231
|
value: color,
|
|
232
232
|
});
|
|
233
233
|
}
|
|
@@ -240,7 +240,7 @@ export function getLinkRandomColor(engine, optColor, blink, consent) {
|
|
|
240
240
|
return midColorValue;
|
|
241
241
|
}
|
|
242
242
|
else {
|
|
243
|
-
return rangeColorToRgb(
|
|
243
|
+
return rangeColorToRgb(pluginManager, {
|
|
244
244
|
value: color,
|
|
245
245
|
});
|
|
246
246
|
}
|
|
@@ -4,8 +4,8 @@ export function loadOptions(options, ...sourceOptionsArr) {
|
|
|
4
4
|
options.load(sourceOptions);
|
|
5
5
|
}
|
|
6
6
|
}
|
|
7
|
-
export function loadParticlesOptions(
|
|
8
|
-
const options = new ParticlesOptions(
|
|
7
|
+
export function loadParticlesOptions(pluginManager, container, ...sourceOptionsArr) {
|
|
8
|
+
const options = new ParticlesOptions(pluginManager, container);
|
|
9
9
|
loadOptions(options, ...sourceOptionsArr);
|
|
10
10
|
return options;
|
|
11
11
|
}
|
package/browser/Utils/Utils.js
CHANGED
|
@@ -326,6 +326,19 @@ export function updateAnimation(particle, data, changeDirection, destroyType, de
|
|
|
326
326
|
if ((data.delayTime ?? minDelay) > minDelay && data.time < (data.delayTime ?? minDelay)) {
|
|
327
327
|
return;
|
|
328
328
|
}
|
|
329
|
+
switch (data.status) {
|
|
330
|
+
case AnimationStatus.increasing:
|
|
331
|
+
data.value += velocity;
|
|
332
|
+
break;
|
|
333
|
+
case AnimationStatus.decreasing:
|
|
334
|
+
data.value -= velocity;
|
|
335
|
+
break;
|
|
336
|
+
default:
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
if (data.velocity && decay !== identity) {
|
|
340
|
+
data.velocity *= decay;
|
|
341
|
+
}
|
|
329
342
|
switch (data.status) {
|
|
330
343
|
case AnimationStatus.increasing:
|
|
331
344
|
if (data.value >= maxValue) {
|
|
@@ -338,9 +351,6 @@ export function updateAnimation(particle, data, changeDirection, destroyType, de
|
|
|
338
351
|
data.loops ??= minLoops;
|
|
339
352
|
data.loops++;
|
|
340
353
|
}
|
|
341
|
-
else {
|
|
342
|
-
data.value += velocity;
|
|
343
|
-
}
|
|
344
354
|
break;
|
|
345
355
|
case AnimationStatus.decreasing:
|
|
346
356
|
if (data.value <= minValue) {
|
|
@@ -353,18 +363,14 @@ export function updateAnimation(particle, data, changeDirection, destroyType, de
|
|
|
353
363
|
data.loops ??= minLoops;
|
|
354
364
|
data.loops++;
|
|
355
365
|
}
|
|
356
|
-
else {
|
|
357
|
-
data.value -= velocity;
|
|
358
|
-
}
|
|
359
366
|
break;
|
|
360
367
|
default:
|
|
361
368
|
break;
|
|
362
369
|
}
|
|
363
|
-
if (data.velocity && decay !== identity) {
|
|
364
|
-
data.velocity *= decay;
|
|
365
|
-
}
|
|
366
370
|
checkDestroy(particle, destroyType, data.value, minValue, maxValue);
|
|
367
|
-
|
|
371
|
+
if (!particle.destroyed) {
|
|
372
|
+
data.value = clamp(data.value, minValue, maxValue);
|
|
373
|
+
}
|
|
368
374
|
}
|
|
369
375
|
export function cloneStyle(style) {
|
|
370
376
|
const clonedStyle = safeDocument().createElement("div").style;
|
package/browser/exports.js
CHANGED
|
@@ -28,6 +28,7 @@ export * from "./Options/Classes/Particles/Bounce/ParticlesBounce.js";
|
|
|
28
28
|
export * from "./Options/Classes/Particles/Bounce/ParticlesBounceFactor.js";
|
|
29
29
|
export * from "./Options/Classes/Particles/ParticlesOptions.js";
|
|
30
30
|
export * from "./Options/Classes/Particles/Fill.js";
|
|
31
|
+
export * from "./Options/Classes/Particles/Paint.js";
|
|
31
32
|
export * from "./Options/Classes/Particles/Stroke.js";
|
|
32
33
|
export * from "./Options/Classes/Particles/Move/Move.js";
|
|
33
34
|
export * from "./Options/Classes/Particles/Move/MoveAngle.js";
|