@tsparticles/engine 4.0.0-beta.1 → 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 -944
- package/browser/Core/Engine.js +1 -1
- package/browser/Options/Classes/Options.js +1 -14
- package/browser/Options/Classes/Particles/Paint.js +20 -0
- package/browser/Options/Classes/Particles/ParticlesOptions.js +60 -22
- package/browser/Options/Interfaces/Particles/IPaint.js +1 -0
- package/browser/Utils/CanvasUtils.js +3 -3
- package/browser/Utils/Utils.js +16 -10
- package/browser/exports.js +1 -0
- package/cjs/Core/Engine.js +1 -1
- package/cjs/Options/Classes/Options.js +1 -14
- package/cjs/Options/Classes/Particles/Paint.js +20 -0
- package/cjs/Options/Classes/Particles/ParticlesOptions.js +60 -22
- package/cjs/Options/Interfaces/Particles/IPaint.js +1 -0
- package/cjs/Utils/CanvasUtils.js +3 -3
- package/cjs/Utils/Utils.js +16 -10
- package/cjs/exports.js +1 -0
- package/dist_browser_Core_Container_js.js +1 -1
- package/esm/Core/Engine.js +1 -1
- package/esm/Options/Classes/Options.js +1 -14
- package/esm/Options/Classes/Particles/Paint.js +20 -0
- package/esm/Options/Classes/Particles/ParticlesOptions.js +60 -22
- package/esm/Options/Interfaces/Particles/IPaint.js +1 -0
- package/esm/Utils/CanvasUtils.js +3 -3
- package/esm/Utils/Utils.js +16 -10
- package/esm/exports.js +1 -0
- package/package.json +2 -3
- package/report.html +1 -1
- package/tsparticles.engine.js +18 -8
- package/tsparticles.engine.min.js +2 -2
- package/types/Core/Interfaces/IPalette.d.ts +15 -2
- package/types/Options/Classes/Particles/Paint.d.ts +10 -0
- package/types/Options/Classes/Particles/ParticlesOptions.d.ts +4 -4
- package/types/Options/Interfaces/Particles/IPaint.d.ts +6 -0
- package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +3 -4
- package/types/export-types.d.ts +1 -0
- package/types/exports.d.ts +1 -0
- package/155.min.js +0 -1
- package/umd/Core/CanvasManager.js +0 -317
- package/umd/Core/Container.js +0 -383
- package/umd/Core/Engine.js +0 -183
- 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 -433
- package/umd/Core/ParticlesManager.js +0 -377
- package/umd/Core/RenderManager.js +0 -317
- package/umd/Core/Retina.js +0 -47
- package/umd/Core/Utils/Constants.js +0 -23
- package/umd/Core/Utils/EventListeners.js +0 -102
- package/umd/Core/Utils/PluginManager.js +0 -159
- 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/CanvasContextType.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 -37
- 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,377 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./Utils/Constants.js", "../Enums/Types/EventType.js", "../Enums/Modes/LimitMode.js", "./Particle.js", "./Utils/SpatialHashGrid.js", "../Utils/LogUtils.js", "../Utils/OptionsUtils.js"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.ParticlesManager = void 0;
|
|
13
|
-
const Constants_js_1 = require("./Utils/Constants.js");
|
|
14
|
-
const EventType_js_1 = require("../Enums/Types/EventType.js");
|
|
15
|
-
const LimitMode_js_1 = require("../Enums/Modes/LimitMode.js");
|
|
16
|
-
const Particle_js_1 = require("./Particle.js");
|
|
17
|
-
const SpatialHashGrid_js_1 = require("./Utils/SpatialHashGrid.js");
|
|
18
|
-
const LogUtils_js_1 = require("../Utils/LogUtils.js");
|
|
19
|
-
const OptionsUtils_js_1 = require("../Utils/OptionsUtils.js");
|
|
20
|
-
class ParticlesManager {
|
|
21
|
-
checkParticlePositionPlugins;
|
|
22
|
-
grid;
|
|
23
|
-
_array;
|
|
24
|
-
_container;
|
|
25
|
-
_groupLimits;
|
|
26
|
-
_limit;
|
|
27
|
-
_maxZIndex;
|
|
28
|
-
_minZIndex;
|
|
29
|
-
_needsSort;
|
|
30
|
-
_nextId;
|
|
31
|
-
_particleResetPlugins;
|
|
32
|
-
_particleUpdatePlugins;
|
|
33
|
-
_pluginManager;
|
|
34
|
-
_pool;
|
|
35
|
-
_postParticleUpdatePlugins;
|
|
36
|
-
_postUpdatePlugins;
|
|
37
|
-
_resizeFactor;
|
|
38
|
-
_updatePlugins;
|
|
39
|
-
_zArray;
|
|
40
|
-
constructor(pluginManager, container) {
|
|
41
|
-
this._pluginManager = pluginManager;
|
|
42
|
-
this._container = container;
|
|
43
|
-
this._nextId = 0;
|
|
44
|
-
this._array = [];
|
|
45
|
-
this._zArray = [];
|
|
46
|
-
this._pool = [];
|
|
47
|
-
this._limit = 0;
|
|
48
|
-
this._groupLimits = new Map();
|
|
49
|
-
this._needsSort = false;
|
|
50
|
-
this._minZIndex = 0;
|
|
51
|
-
this._maxZIndex = 0;
|
|
52
|
-
this.grid = new SpatialHashGrid_js_1.SpatialHashGrid(Constants_js_1.spatialHashGridCellSize);
|
|
53
|
-
this.checkParticlePositionPlugins = [];
|
|
54
|
-
this._particleResetPlugins = [];
|
|
55
|
-
this._particleUpdatePlugins = [];
|
|
56
|
-
this._postUpdatePlugins = [];
|
|
57
|
-
this._postParticleUpdatePlugins = [];
|
|
58
|
-
this._updatePlugins = [];
|
|
59
|
-
}
|
|
60
|
-
get count() {
|
|
61
|
-
return this._array.length;
|
|
62
|
-
}
|
|
63
|
-
addParticle(position, overrideOptions, group, initializer) {
|
|
64
|
-
const limitMode = this._container.actualOptions.particles.number.limit.mode, limit = group === undefined ? this._limit : (this._groupLimits.get(group) ?? this._limit), currentCount = this.count;
|
|
65
|
-
if (limit > Constants_js_1.minLimit) {
|
|
66
|
-
switch (limitMode) {
|
|
67
|
-
case LimitMode_js_1.LimitMode.delete: {
|
|
68
|
-
const countToRemove = currentCount + Constants_js_1.countOffset - limit;
|
|
69
|
-
if (countToRemove > Constants_js_1.minCount) {
|
|
70
|
-
this.removeQuantity(countToRemove);
|
|
71
|
-
}
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
case LimitMode_js_1.LimitMode.wait:
|
|
75
|
-
if (currentCount >= limit) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
break;
|
|
79
|
-
default:
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
try {
|
|
84
|
-
const particle = this._pool.pop() ?? new Particle_js_1.Particle(this._pluginManager, this._container);
|
|
85
|
-
particle.init(this._nextId, position, overrideOptions, group);
|
|
86
|
-
let canAdd = true;
|
|
87
|
-
if (initializer) {
|
|
88
|
-
canAdd = initializer(particle);
|
|
89
|
-
}
|
|
90
|
-
if (!canAdd) {
|
|
91
|
-
this._pool.push(particle);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
this._array.push(particle);
|
|
95
|
-
this._zArray.push(particle);
|
|
96
|
-
this._nextId++;
|
|
97
|
-
this._container.dispatchEvent(EventType_js_1.EventType.particleAdded, {
|
|
98
|
-
particle,
|
|
99
|
-
});
|
|
100
|
-
return particle;
|
|
101
|
-
}
|
|
102
|
-
catch (e) {
|
|
103
|
-
(0, LogUtils_js_1.getLogger)().warning(`error adding particle: ${e}`);
|
|
104
|
-
}
|
|
105
|
-
return undefined;
|
|
106
|
-
}
|
|
107
|
-
clear() {
|
|
108
|
-
this._array = [];
|
|
109
|
-
this._zArray = [];
|
|
110
|
-
}
|
|
111
|
-
destroy() {
|
|
112
|
-
this._array = [];
|
|
113
|
-
this._pool.length = 0;
|
|
114
|
-
this._zArray = [];
|
|
115
|
-
this.checkParticlePositionPlugins = [];
|
|
116
|
-
this._particleResetPlugins = [];
|
|
117
|
-
this._particleUpdatePlugins = [];
|
|
118
|
-
this._postUpdatePlugins = [];
|
|
119
|
-
this._postParticleUpdatePlugins = [];
|
|
120
|
-
this._updatePlugins = [];
|
|
121
|
-
}
|
|
122
|
-
drawParticles(delta) {
|
|
123
|
-
for (const particle of this._zArray) {
|
|
124
|
-
particle.draw(delta);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
filter(condition) {
|
|
128
|
-
return this._array.filter(condition);
|
|
129
|
-
}
|
|
130
|
-
find(condition) {
|
|
131
|
-
return this._array.find(condition);
|
|
132
|
-
}
|
|
133
|
-
get(index) {
|
|
134
|
-
return this._array[index];
|
|
135
|
-
}
|
|
136
|
-
async init() {
|
|
137
|
-
const container = this._container, options = container.actualOptions;
|
|
138
|
-
this._minZIndex = 0;
|
|
139
|
-
this._maxZIndex = 0;
|
|
140
|
-
this._needsSort = false;
|
|
141
|
-
this.checkParticlePositionPlugins = [];
|
|
142
|
-
this._updatePlugins = [];
|
|
143
|
-
this._particleUpdatePlugins = [];
|
|
144
|
-
this._postUpdatePlugins = [];
|
|
145
|
-
this._particleResetPlugins = [];
|
|
146
|
-
this._postParticleUpdatePlugins = [];
|
|
147
|
-
this.grid = new SpatialHashGrid_js_1.SpatialHashGrid(Constants_js_1.spatialHashGridCellSize * container.retina.pixelRatio);
|
|
148
|
-
for (const plugin of container.plugins) {
|
|
149
|
-
if (plugin.redrawInit) {
|
|
150
|
-
await plugin.redrawInit();
|
|
151
|
-
}
|
|
152
|
-
if (plugin.checkParticlePosition) {
|
|
153
|
-
this.checkParticlePositionPlugins.push(plugin);
|
|
154
|
-
}
|
|
155
|
-
if (plugin.update) {
|
|
156
|
-
this._updatePlugins.push(plugin);
|
|
157
|
-
}
|
|
158
|
-
if (plugin.particleUpdate) {
|
|
159
|
-
this._particleUpdatePlugins.push(plugin);
|
|
160
|
-
}
|
|
161
|
-
if (plugin.postUpdate) {
|
|
162
|
-
this._postUpdatePlugins.push(plugin);
|
|
163
|
-
}
|
|
164
|
-
if (plugin.particleReset) {
|
|
165
|
-
this._particleResetPlugins.push(plugin);
|
|
166
|
-
}
|
|
167
|
-
if (plugin.postParticleUpdate) {
|
|
168
|
-
this._postParticleUpdatePlugins.push(plugin);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
await this._container.initDrawersAndUpdaters();
|
|
172
|
-
for (const drawer of this._container.effectDrawers.values()) {
|
|
173
|
-
await drawer.init?.(container);
|
|
174
|
-
}
|
|
175
|
-
for (const drawer of this._container.shapeDrawers.values()) {
|
|
176
|
-
await drawer.init?.(container);
|
|
177
|
-
}
|
|
178
|
-
let handled = false;
|
|
179
|
-
for (const plugin of container.plugins) {
|
|
180
|
-
handled = plugin.particlesInitialization?.() ?? handled;
|
|
181
|
-
if (handled) {
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
if (!handled) {
|
|
186
|
-
const particlesOptions = options.particles, groups = particlesOptions.groups;
|
|
187
|
-
for (const group in groups) {
|
|
188
|
-
const groupOptions = groups[group];
|
|
189
|
-
if (!groupOptions) {
|
|
190
|
-
continue;
|
|
191
|
-
}
|
|
192
|
-
for (let i = this.count, j = 0; j < groupOptions.number.value && i < particlesOptions.number.value; i++, j++) {
|
|
193
|
-
this.addParticle(undefined, groupOptions, group);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
for (let i = this.count; i < particlesOptions.number.value; i++) {
|
|
197
|
-
this.addParticle();
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
push(nb, position, overrideOptions, group) {
|
|
202
|
-
for (let i = 0; i < nb; i++) {
|
|
203
|
-
this.addParticle(position, overrideOptions, group);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
async redraw() {
|
|
207
|
-
this.clear();
|
|
208
|
-
await this.init();
|
|
209
|
-
this._container.canvas.render.drawParticles({ value: 0, factor: 0 });
|
|
210
|
-
}
|
|
211
|
-
remove(particle, group, override) {
|
|
212
|
-
this.removeAt(this._array.indexOf(particle), undefined, group, override);
|
|
213
|
-
}
|
|
214
|
-
removeAt(index, quantity = Constants_js_1.defaultRemoveQuantity, group, override) {
|
|
215
|
-
if (index < Constants_js_1.minIndex || index > this.count) {
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
let deleted = 0;
|
|
219
|
-
for (let i = index; deleted < quantity && i < this.count; i++) {
|
|
220
|
-
if (this._removeParticle(i, group, override)) {
|
|
221
|
-
i--;
|
|
222
|
-
deleted++;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
removeQuantity(quantity, group) {
|
|
227
|
-
this.removeAt(Constants_js_1.minIndex, quantity, group);
|
|
228
|
-
}
|
|
229
|
-
setDensity() {
|
|
230
|
-
const options = this._container.actualOptions, groups = options.particles.groups;
|
|
231
|
-
let pluginsCount = 0;
|
|
232
|
-
for (const plugin of this._container.plugins) {
|
|
233
|
-
if (plugin.particlesDensityCount) {
|
|
234
|
-
pluginsCount += plugin.particlesDensityCount();
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
for (const group in groups) {
|
|
238
|
-
const groupData = groups[group];
|
|
239
|
-
if (!groupData) {
|
|
240
|
-
continue;
|
|
241
|
-
}
|
|
242
|
-
const groupDataOptions = (0, OptionsUtils_js_1.loadParticlesOptions)(this._pluginManager, this._container, groupData);
|
|
243
|
-
this._applyDensity(groupDataOptions, pluginsCount, group);
|
|
244
|
-
}
|
|
245
|
-
this._applyDensity(options.particles, pluginsCount);
|
|
246
|
-
}
|
|
247
|
-
setLastZIndex(zIndex) {
|
|
248
|
-
this._needsSort ||= zIndex >= this._maxZIndex || (zIndex > this._minZIndex && zIndex < this._maxZIndex);
|
|
249
|
-
}
|
|
250
|
-
setResizeFactor(factor) {
|
|
251
|
-
this._resizeFactor = factor;
|
|
252
|
-
}
|
|
253
|
-
update(delta) {
|
|
254
|
-
const particlesToDelete = new Set();
|
|
255
|
-
this.grid.clear();
|
|
256
|
-
for (const plugin of this._updatePlugins) {
|
|
257
|
-
plugin.update?.(delta);
|
|
258
|
-
}
|
|
259
|
-
const resizeFactor = this._resizeFactor;
|
|
260
|
-
for (const particle of this._array) {
|
|
261
|
-
if (resizeFactor && !particle.ignoresResizeRatio) {
|
|
262
|
-
particle.position.x *= resizeFactor.width;
|
|
263
|
-
particle.position.y *= resizeFactor.height;
|
|
264
|
-
particle.initialPosition.x *= resizeFactor.width;
|
|
265
|
-
particle.initialPosition.y *= resizeFactor.height;
|
|
266
|
-
}
|
|
267
|
-
particle.ignoresResizeRatio = false;
|
|
268
|
-
for (const plugin of this._particleResetPlugins) {
|
|
269
|
-
plugin.particleReset?.(particle);
|
|
270
|
-
}
|
|
271
|
-
for (const plugin of this._particleUpdatePlugins) {
|
|
272
|
-
if (particle.destroyed) {
|
|
273
|
-
break;
|
|
274
|
-
}
|
|
275
|
-
plugin.particleUpdate?.(particle, delta);
|
|
276
|
-
}
|
|
277
|
-
if (particle.destroyed) {
|
|
278
|
-
particlesToDelete.add(particle);
|
|
279
|
-
continue;
|
|
280
|
-
}
|
|
281
|
-
this.grid.insert(particle);
|
|
282
|
-
}
|
|
283
|
-
for (const plugin of this._postUpdatePlugins) {
|
|
284
|
-
plugin.postUpdate?.(delta);
|
|
285
|
-
}
|
|
286
|
-
for (const particle of this._array) {
|
|
287
|
-
if (particle.destroyed) {
|
|
288
|
-
particlesToDelete.add(particle);
|
|
289
|
-
continue;
|
|
290
|
-
}
|
|
291
|
-
for (const updater of this._container.particleUpdaters) {
|
|
292
|
-
updater.update(particle, delta);
|
|
293
|
-
}
|
|
294
|
-
if (!particle.destroyed && !particle.spawning) {
|
|
295
|
-
for (const plugin of this._postParticleUpdatePlugins) {
|
|
296
|
-
plugin.postParticleUpdate?.(particle, delta);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
else if (particle.destroyed) {
|
|
300
|
-
particlesToDelete.add(particle);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
if (particlesToDelete.size) {
|
|
304
|
-
for (const particle of particlesToDelete) {
|
|
305
|
-
this.remove(particle);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
delete this._resizeFactor;
|
|
309
|
-
if (this._needsSort) {
|
|
310
|
-
const zArray = this._zArray;
|
|
311
|
-
zArray.sort((a, b) => b.position.z - a.position.z || a.id - b.id);
|
|
312
|
-
const firstItem = zArray[Constants_js_1.minIndex], lastItem = zArray[zArray.length - Constants_js_1.lengthOffset];
|
|
313
|
-
if (!firstItem || !lastItem) {
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
this._maxZIndex = firstItem.position.z;
|
|
317
|
-
this._minZIndex = lastItem.position.z;
|
|
318
|
-
this._needsSort = false;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
_addToPool = (...particles) => {
|
|
322
|
-
this._pool.push(...particles);
|
|
323
|
-
};
|
|
324
|
-
_applyDensity = (options, pluginsCount, group, groupOptions) => {
|
|
325
|
-
const numberOptions = options.number;
|
|
326
|
-
if (!numberOptions.density.enable) {
|
|
327
|
-
if (group === undefined) {
|
|
328
|
-
this._limit = numberOptions.limit.value;
|
|
329
|
-
}
|
|
330
|
-
else if (groupOptions?.number.limit.value ?? numberOptions.limit.value) {
|
|
331
|
-
this._groupLimits.set(group, groupOptions?.number.limit.value ?? numberOptions.limit.value);
|
|
332
|
-
}
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
const densityFactor = this._initDensityFactor(numberOptions.density), optParticlesNumber = numberOptions.value, optParticlesLimit = numberOptions.limit.value > Constants_js_1.minLimit ? numberOptions.limit.value : optParticlesNumber, particlesNumber = Math.min(optParticlesNumber, optParticlesLimit) * densityFactor + pluginsCount, particlesCount = Math.min(this.count, this.filter(t => t.group === group).length);
|
|
336
|
-
if (group === undefined) {
|
|
337
|
-
this._limit = numberOptions.limit.value * densityFactor;
|
|
338
|
-
}
|
|
339
|
-
else {
|
|
340
|
-
this._groupLimits.set(group, numberOptions.limit.value * densityFactor);
|
|
341
|
-
}
|
|
342
|
-
if (particlesCount < particlesNumber) {
|
|
343
|
-
this.push(Math.abs(particlesNumber - particlesCount), undefined, options, group);
|
|
344
|
-
}
|
|
345
|
-
else if (particlesCount > particlesNumber) {
|
|
346
|
-
this.removeQuantity(particlesCount - particlesNumber, group);
|
|
347
|
-
}
|
|
348
|
-
};
|
|
349
|
-
_initDensityFactor = densityOptions => {
|
|
350
|
-
const container = this._container;
|
|
351
|
-
if (!container.canvas.element || !densityOptions.enable) {
|
|
352
|
-
return Constants_js_1.defaultDensityFactor;
|
|
353
|
-
}
|
|
354
|
-
const canvas = container.canvas.element, pxRatio = container.retina.pixelRatio;
|
|
355
|
-
return (canvas.width * canvas.height) / (densityOptions.height * densityOptions.width * pxRatio ** Constants_js_1.squareExp);
|
|
356
|
-
};
|
|
357
|
-
_removeParticle = (index, group, override) => {
|
|
358
|
-
const particle = this._array[index];
|
|
359
|
-
if (!particle) {
|
|
360
|
-
return false;
|
|
361
|
-
}
|
|
362
|
-
if (particle.group !== group) {
|
|
363
|
-
return false;
|
|
364
|
-
}
|
|
365
|
-
const zIdx = this._zArray.indexOf(particle);
|
|
366
|
-
this._array.splice(index, Constants_js_1.deleteCount);
|
|
367
|
-
this._zArray.splice(zIdx, Constants_js_1.deleteCount);
|
|
368
|
-
particle.destroy(override);
|
|
369
|
-
this._container.dispatchEvent(EventType_js_1.EventType.particleRemoved, {
|
|
370
|
-
particle,
|
|
371
|
-
});
|
|
372
|
-
this._addToPool(particle);
|
|
373
|
-
return true;
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
exports.ParticlesManager = ParticlesManager;
|
|
377
|
-
});
|
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "../Utils/CanvasUtils.js", "./Utils/Constants.js", "../Utils/ColorUtils.js"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.RenderManager = void 0;
|
|
13
|
-
const CanvasUtils_js_1 = require("../Utils/CanvasUtils.js");
|
|
14
|
-
const Constants_js_1 = require("./Utils/Constants.js");
|
|
15
|
-
const ColorUtils_js_1 = require("../Utils/ColorUtils.js");
|
|
16
|
-
const fColorIndex = 0, sColorIndex = 1;
|
|
17
|
-
function setTransformValue(factor, newFactor, key) {
|
|
18
|
-
const newValue = newFactor[key];
|
|
19
|
-
if (newValue !== undefined) {
|
|
20
|
-
factor[key] = (factor[key] ?? Constants_js_1.defaultTransformValue) * newValue;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
class RenderManager {
|
|
24
|
-
_canvasClearPlugins;
|
|
25
|
-
_canvasManager;
|
|
26
|
-
_canvasPaintPlugins;
|
|
27
|
-
_clearDrawPlugins;
|
|
28
|
-
_colorPlugins;
|
|
29
|
-
_container;
|
|
30
|
-
_context;
|
|
31
|
-
_contextSettings;
|
|
32
|
-
_drawParticlePlugins;
|
|
33
|
-
_drawParticlesCleanupPlugins;
|
|
34
|
-
_drawParticlesSetupPlugins;
|
|
35
|
-
_drawPlugins;
|
|
36
|
-
_drawSettingsCleanupPlugins;
|
|
37
|
-
_drawSettingsSetupPlugins;
|
|
38
|
-
_pluginManager;
|
|
39
|
-
_postDrawUpdaters;
|
|
40
|
-
_preDrawUpdaters;
|
|
41
|
-
_reusableColorStyles = {};
|
|
42
|
-
_reusablePluginColors = [undefined, undefined];
|
|
43
|
-
_reusableTransform = {};
|
|
44
|
-
constructor(pluginManager, container, canvasManager) {
|
|
45
|
-
this._pluginManager = pluginManager;
|
|
46
|
-
this._container = container;
|
|
47
|
-
this._canvasManager = canvasManager;
|
|
48
|
-
this._context = null;
|
|
49
|
-
this._preDrawUpdaters = [];
|
|
50
|
-
this._postDrawUpdaters = [];
|
|
51
|
-
this._colorPlugins = [];
|
|
52
|
-
this._canvasClearPlugins = [];
|
|
53
|
-
this._canvasPaintPlugins = [];
|
|
54
|
-
this._clearDrawPlugins = [];
|
|
55
|
-
this._drawParticlePlugins = [];
|
|
56
|
-
this._drawParticlesCleanupPlugins = [];
|
|
57
|
-
this._drawParticlesSetupPlugins = [];
|
|
58
|
-
this._drawPlugins = [];
|
|
59
|
-
this._drawSettingsSetupPlugins = [];
|
|
60
|
-
this._drawSettingsCleanupPlugins = [];
|
|
61
|
-
}
|
|
62
|
-
get settings() {
|
|
63
|
-
return this._contextSettings;
|
|
64
|
-
}
|
|
65
|
-
canvasClear() {
|
|
66
|
-
if (!this._container.actualOptions.clear) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
this.draw(ctx => {
|
|
70
|
-
(0, CanvasUtils_js_1.clear)(ctx, this._canvasManager.size);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
clear() {
|
|
74
|
-
let pluginHandled = false;
|
|
75
|
-
for (const plugin of this._canvasClearPlugins) {
|
|
76
|
-
pluginHandled = plugin.canvasClear?.() ?? false;
|
|
77
|
-
if (pluginHandled) {
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (pluginHandled) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
this.canvasClear();
|
|
85
|
-
}
|
|
86
|
-
destroy() {
|
|
87
|
-
this.stop();
|
|
88
|
-
this._preDrawUpdaters = [];
|
|
89
|
-
this._postDrawUpdaters = [];
|
|
90
|
-
this._colorPlugins = [];
|
|
91
|
-
this._canvasClearPlugins = [];
|
|
92
|
-
this._canvasPaintPlugins = [];
|
|
93
|
-
this._clearDrawPlugins = [];
|
|
94
|
-
this._drawParticlePlugins = [];
|
|
95
|
-
this._drawParticlesCleanupPlugins = [];
|
|
96
|
-
this._drawParticlesSetupPlugins = [];
|
|
97
|
-
this._drawPlugins = [];
|
|
98
|
-
this._drawSettingsSetupPlugins = [];
|
|
99
|
-
this._drawSettingsCleanupPlugins = [];
|
|
100
|
-
}
|
|
101
|
-
draw(cb) {
|
|
102
|
-
const ctx = this._context;
|
|
103
|
-
if (!ctx) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
return cb(ctx);
|
|
107
|
-
}
|
|
108
|
-
drawParticle(particle, delta) {
|
|
109
|
-
if (particle.spawning || particle.destroyed) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
const radius = particle.getRadius();
|
|
113
|
-
if (radius <= Constants_js_1.minimumSize) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
const pfColor = particle.getFillColor(), psColor = particle.getStrokeColor();
|
|
117
|
-
let [fColor, sColor] = this._getPluginParticleColors(particle);
|
|
118
|
-
fColor ??= pfColor;
|
|
119
|
-
sColor ??= psColor;
|
|
120
|
-
if (!fColor && !sColor) {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
const container = this._container, zIndexOptions = particle.options.zIndex, zIndexFactor = Constants_js_1.zIndexFactorOffset - particle.zIndexFactor, { fillOpacity, opacity, strokeOpacity } = particle.getOpacity(), transform = this._reusableTransform, colorStyles = this._reusableColorStyles, fill = fColor ? (0, ColorUtils_js_1.getStyleFromHsl)(fColor, container.hdr, fillOpacity * opacity) : undefined, stroke = sColor ? (0, ColorUtils_js_1.getStyleFromHsl)(sColor, container.hdr, strokeOpacity * opacity) : fill;
|
|
124
|
-
transform.a = transform.b = transform.c = transform.d = undefined;
|
|
125
|
-
colorStyles.fill = fill;
|
|
126
|
-
colorStyles.stroke = stroke;
|
|
127
|
-
this.draw((context) => {
|
|
128
|
-
for (const plugin of this._drawParticlesSetupPlugins) {
|
|
129
|
-
plugin.drawParticleSetup?.(context, particle, delta);
|
|
130
|
-
}
|
|
131
|
-
this._applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
|
|
132
|
-
(0, CanvasUtils_js_1.drawParticle)({
|
|
133
|
-
container,
|
|
134
|
-
context,
|
|
135
|
-
particle,
|
|
136
|
-
delta,
|
|
137
|
-
colorStyles,
|
|
138
|
-
radius: radius * zIndexFactor ** zIndexOptions.sizeRate,
|
|
139
|
-
opacity: opacity,
|
|
140
|
-
transform,
|
|
141
|
-
});
|
|
142
|
-
this._applyPostDrawUpdaters(particle);
|
|
143
|
-
for (const plugin of this._drawParticlesCleanupPlugins) {
|
|
144
|
-
plugin.drawParticleCleanup?.(context, particle, delta);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
drawParticlePlugins(particle, delta) {
|
|
149
|
-
this.draw(ctx => {
|
|
150
|
-
for (const plugin of this._drawParticlePlugins) {
|
|
151
|
-
(0, CanvasUtils_js_1.drawParticlePlugin)(ctx, plugin, particle, delta);
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
drawParticles(delta) {
|
|
156
|
-
const { particles } = this._container;
|
|
157
|
-
this.clear();
|
|
158
|
-
particles.update(delta);
|
|
159
|
-
this.draw(ctx => {
|
|
160
|
-
for (const plugin of this._drawSettingsSetupPlugins) {
|
|
161
|
-
plugin.drawSettingsSetup?.(ctx, delta);
|
|
162
|
-
}
|
|
163
|
-
for (const plugin of this._drawPlugins) {
|
|
164
|
-
plugin.draw?.(ctx, delta);
|
|
165
|
-
}
|
|
166
|
-
particles.drawParticles(delta);
|
|
167
|
-
for (const plugin of this._clearDrawPlugins) {
|
|
168
|
-
plugin.clearDraw?.(ctx, delta);
|
|
169
|
-
}
|
|
170
|
-
for (const plugin of this._drawSettingsCleanupPlugins) {
|
|
171
|
-
plugin.drawSettingsCleanup?.(ctx, delta);
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
init() {
|
|
176
|
-
this.initUpdaters();
|
|
177
|
-
this.initPlugins();
|
|
178
|
-
this.paint();
|
|
179
|
-
}
|
|
180
|
-
initPlugins() {
|
|
181
|
-
this._colorPlugins = [];
|
|
182
|
-
this._canvasClearPlugins = [];
|
|
183
|
-
this._canvasPaintPlugins = [];
|
|
184
|
-
this._clearDrawPlugins = [];
|
|
185
|
-
this._drawParticlePlugins = [];
|
|
186
|
-
this._drawParticlesSetupPlugins = [];
|
|
187
|
-
this._drawParticlesCleanupPlugins = [];
|
|
188
|
-
this._drawPlugins = [];
|
|
189
|
-
this._drawSettingsSetupPlugins = [];
|
|
190
|
-
this._drawSettingsCleanupPlugins = [];
|
|
191
|
-
for (const plugin of this._container.plugins) {
|
|
192
|
-
if (plugin.particleFillColor ?? plugin.particleStrokeColor) {
|
|
193
|
-
this._colorPlugins.push(plugin);
|
|
194
|
-
}
|
|
195
|
-
if (plugin.canvasClear) {
|
|
196
|
-
this._canvasClearPlugins.push(plugin);
|
|
197
|
-
}
|
|
198
|
-
if (plugin.canvasPaint) {
|
|
199
|
-
this._canvasPaintPlugins.push(plugin);
|
|
200
|
-
}
|
|
201
|
-
if (plugin.drawParticle) {
|
|
202
|
-
this._drawParticlePlugins.push(plugin);
|
|
203
|
-
}
|
|
204
|
-
if (plugin.drawParticleSetup) {
|
|
205
|
-
this._drawParticlesSetupPlugins.push(plugin);
|
|
206
|
-
}
|
|
207
|
-
if (plugin.drawParticleCleanup) {
|
|
208
|
-
this._drawParticlesCleanupPlugins.push(plugin);
|
|
209
|
-
}
|
|
210
|
-
if (plugin.draw) {
|
|
211
|
-
this._drawPlugins.push(plugin);
|
|
212
|
-
}
|
|
213
|
-
if (plugin.drawSettingsSetup) {
|
|
214
|
-
this._drawSettingsSetupPlugins.push(plugin);
|
|
215
|
-
}
|
|
216
|
-
if (plugin.drawSettingsCleanup) {
|
|
217
|
-
this._drawSettingsCleanupPlugins.push(plugin);
|
|
218
|
-
}
|
|
219
|
-
if (plugin.clearDraw) {
|
|
220
|
-
this._clearDrawPlugins.push(plugin);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
initUpdaters() {
|
|
225
|
-
this._preDrawUpdaters = [];
|
|
226
|
-
this._postDrawUpdaters = [];
|
|
227
|
-
for (const updater of this._container.particleUpdaters) {
|
|
228
|
-
if (updater.afterDraw) {
|
|
229
|
-
this._postDrawUpdaters.push(updater);
|
|
230
|
-
}
|
|
231
|
-
if (updater.getColorStyles ?? updater.getTransformValues ?? updater.beforeDraw) {
|
|
232
|
-
this._preDrawUpdaters.push(updater);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
paint() {
|
|
237
|
-
let handled = false;
|
|
238
|
-
for (const plugin of this._canvasPaintPlugins) {
|
|
239
|
-
handled = plugin.canvasPaint?.() ?? false;
|
|
240
|
-
if (handled) {
|
|
241
|
-
break;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
if (handled) {
|
|
245
|
-
return;
|
|
246
|
-
}
|
|
247
|
-
this.paintBase();
|
|
248
|
-
}
|
|
249
|
-
paintBase(baseColor) {
|
|
250
|
-
this.draw(ctx => {
|
|
251
|
-
(0, CanvasUtils_js_1.paintBase)(ctx, this._canvasManager.size, baseColor);
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
paintImage(image, opacity) {
|
|
255
|
-
this.draw(ctx => {
|
|
256
|
-
(0, CanvasUtils_js_1.paintImage)(ctx, this._canvasManager.size, image, opacity);
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
setContext(context) {
|
|
260
|
-
this._context = context;
|
|
261
|
-
if (this._context) {
|
|
262
|
-
this._context.globalCompositeOperation = Constants_js_1.defaultCompositeValue;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
setContextSettings(settings) {
|
|
266
|
-
this._contextSettings = settings;
|
|
267
|
-
}
|
|
268
|
-
stop() {
|
|
269
|
-
this.draw(ctx => {
|
|
270
|
-
(0, CanvasUtils_js_1.clear)(ctx, this._canvasManager.size);
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
_applyPostDrawUpdaters = particle => {
|
|
274
|
-
for (const updater of this._postDrawUpdaters) {
|
|
275
|
-
updater.afterDraw?.(particle);
|
|
276
|
-
}
|
|
277
|
-
};
|
|
278
|
-
_applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
|
|
279
|
-
for (const updater of this._preDrawUpdaters) {
|
|
280
|
-
if (updater.getColorStyles) {
|
|
281
|
-
const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
|
|
282
|
-
if (fill) {
|
|
283
|
-
colorStyles.fill = fill;
|
|
284
|
-
}
|
|
285
|
-
if (stroke) {
|
|
286
|
-
colorStyles.stroke = stroke;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
if (updater.getTransformValues) {
|
|
290
|
-
const updaterTransform = updater.getTransformValues(particle);
|
|
291
|
-
for (const key in updaterTransform) {
|
|
292
|
-
setTransformValue(transform, updaterTransform, key);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
updater.beforeDraw?.(particle);
|
|
296
|
-
}
|
|
297
|
-
};
|
|
298
|
-
_getPluginParticleColors = particle => {
|
|
299
|
-
let fColor, sColor;
|
|
300
|
-
for (const plugin of this._colorPlugins) {
|
|
301
|
-
if (!fColor && plugin.particleFillColor) {
|
|
302
|
-
fColor = (0, ColorUtils_js_1.rangeColorToHsl)(this._pluginManager, plugin.particleFillColor(particle));
|
|
303
|
-
}
|
|
304
|
-
if (!sColor && plugin.particleStrokeColor) {
|
|
305
|
-
sColor = (0, ColorUtils_js_1.rangeColorToHsl)(this._pluginManager, plugin.particleStrokeColor(particle));
|
|
306
|
-
}
|
|
307
|
-
if (fColor && sColor) {
|
|
308
|
-
break;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
this._reusablePluginColors[fColorIndex] = fColor;
|
|
312
|
-
this._reusablePluginColors[sColorIndex] = sColor;
|
|
313
|
-
return this._reusablePluginColors;
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
exports.RenderManager = RenderManager;
|
|
317
|
-
});
|