@tsparticles/engine 4.0.0-alpha.5 → 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/164.min.js +1 -0
- package/README.md +41 -7
- package/browser/Core/Canvas.js +250 -143
- package/browser/Core/Container.js +80 -74
- package/browser/Core/Engine.js +44 -67
- package/browser/Core/Particle.js +202 -173
- package/browser/Core/Particles.js +187 -138
- package/browser/Core/Retina.js +5 -0
- package/browser/Core/Utils/Constants.js +2 -2
- package/browser/Core/Utils/EventListeners.js +67 -63
- package/browser/Core/Utils/Ranges.js +29 -10
- package/browser/Core/Utils/SpatialHashGrid.js +102 -0
- package/browser/Core/Utils/Vectors.js +17 -18
- package/browser/Enums/Types/EasingType.js +18 -3
- package/browser/Options/Classes/AnimatableColor.js +1 -0
- package/browser/Options/Classes/AnimationOptions.js +8 -0
- package/browser/Options/Classes/Background/Background.js +6 -0
- package/browser/Options/Classes/ColorAnimation.js +12 -1
- package/browser/Options/Classes/FullScreen/FullScreen.js +2 -0
- package/browser/Options/Classes/HslAnimation.js +4 -5
- package/browser/Options/Classes/Options.js +63 -4
- package/browser/Options/Classes/OptionsColor.js +1 -0
- package/browser/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
- package/browser/Options/Classes/Particles/Effect/Effect.js +3 -4
- package/browser/Options/Classes/Particles/Fill.js +28 -0
- package/browser/Options/Classes/Particles/Move/Move.js +17 -3
- package/browser/Options/Classes/Particles/Move/MoveAngle.js +2 -0
- package/browser/Options/Classes/Particles/Move/MoveCenter.js +4 -0
- package/browser/Options/Classes/Particles/Move/MoveGravity.js +4 -0
- package/browser/Options/Classes/Particles/Move/OutModes.js +5 -0
- package/browser/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
- package/browser/Options/Classes/Particles/Move/Spin.js +3 -0
- package/browser/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
- package/browser/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
- package/browser/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
- package/browser/Options/Classes/Particles/Opacity/Opacity.js +1 -0
- package/browser/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
- package/browser/Options/Classes/Particles/ParticlesOptions.js +25 -5
- package/browser/Options/Classes/Particles/Shape/Shape.js +3 -4
- package/browser/Options/Classes/Particles/Size/Size.js +1 -0
- package/browser/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
- package/browser/Options/Classes/Particles/Stroke.js +3 -0
- package/browser/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
- package/browser/Options/Classes/ResizeEvent.js +2 -0
- package/browser/Options/Classes/ValueWithRandom.js +3 -4
- package/browser/Utils/CanvasUtils.js +43 -62
- package/browser/Utils/ColorUtils.js +30 -19
- package/browser/Utils/EventDispatcher.js +1 -0
- package/browser/Utils/MathUtils.js +12 -7
- package/browser/Utils/Utils.js +109 -31
- package/browser/exports.js +1 -2
- package/cjs/Core/Canvas.js +250 -143
- package/cjs/Core/Container.js +80 -74
- package/cjs/Core/Engine.js +44 -67
- package/cjs/Core/Particle.js +202 -173
- package/cjs/Core/Particles.js +187 -138
- package/cjs/Core/Retina.js +5 -0
- package/cjs/Core/Utils/Constants.js +2 -2
- package/cjs/Core/Utils/EventListeners.js +67 -63
- package/cjs/Core/Utils/Ranges.js +29 -10
- package/cjs/Core/Utils/SpatialHashGrid.js +102 -0
- package/cjs/Core/Utils/Vectors.js +17 -18
- package/cjs/Enums/Types/EasingType.js +18 -3
- package/cjs/Options/Classes/AnimatableColor.js +1 -0
- package/cjs/Options/Classes/AnimationOptions.js +8 -0
- package/cjs/Options/Classes/Background/Background.js +6 -0
- package/cjs/Options/Classes/ColorAnimation.js +12 -1
- package/cjs/Options/Classes/FullScreen/FullScreen.js +2 -0
- package/cjs/Options/Classes/HslAnimation.js +4 -5
- package/cjs/Options/Classes/Options.js +63 -4
- package/cjs/Options/Classes/OptionsColor.js +1 -0
- package/cjs/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
- package/cjs/Options/Classes/Particles/Effect/Effect.js +3 -4
- package/cjs/Options/Classes/Particles/Fill.js +28 -0
- package/cjs/Options/Classes/Particles/Move/Move.js +17 -3
- package/cjs/Options/Classes/Particles/Move/MoveAngle.js +2 -0
- package/cjs/Options/Classes/Particles/Move/MoveCenter.js +4 -0
- package/cjs/Options/Classes/Particles/Move/MoveGravity.js +4 -0
- package/cjs/Options/Classes/Particles/Move/OutModes.js +5 -0
- package/cjs/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
- package/cjs/Options/Classes/Particles/Move/Spin.js +3 -0
- package/cjs/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
- package/cjs/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
- package/cjs/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
- package/cjs/Options/Classes/Particles/Opacity/Opacity.js +1 -0
- package/cjs/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
- package/cjs/Options/Classes/Particles/ParticlesOptions.js +25 -5
- package/cjs/Options/Classes/Particles/Shape/Shape.js +3 -4
- package/cjs/Options/Classes/Particles/Size/Size.js +1 -0
- package/cjs/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
- package/cjs/Options/Classes/Particles/Stroke.js +3 -0
- package/cjs/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
- package/cjs/Options/Classes/ResizeEvent.js +2 -0
- package/cjs/Options/Classes/ValueWithRandom.js +3 -4
- package/cjs/Utils/CanvasUtils.js +43 -62
- package/cjs/Utils/ColorUtils.js +30 -19
- package/cjs/Utils/EventDispatcher.js +1 -0
- package/cjs/Utils/MathUtils.js +12 -7
- package/cjs/Utils/Utils.js +109 -31
- package/cjs/exports.js +1 -2
- package/dist_browser_Core_Container_js.js +12 -12
- package/esm/Core/Canvas.js +250 -143
- package/esm/Core/Container.js +80 -74
- package/esm/Core/Engine.js +44 -67
- package/esm/Core/Particle.js +202 -173
- package/esm/Core/Particles.js +187 -138
- package/esm/Core/Retina.js +5 -0
- package/esm/Core/Utils/Constants.js +2 -2
- package/esm/Core/Utils/EventListeners.js +67 -63
- package/esm/Core/Utils/Ranges.js +29 -10
- package/esm/Core/Utils/SpatialHashGrid.js +102 -0
- package/esm/Core/Utils/Vectors.js +17 -18
- package/esm/Enums/Types/EasingType.js +18 -3
- package/esm/Options/Classes/AnimatableColor.js +1 -0
- package/esm/Options/Classes/AnimationOptions.js +8 -0
- package/esm/Options/Classes/Background/Background.js +6 -0
- package/esm/Options/Classes/ColorAnimation.js +12 -1
- package/esm/Options/Classes/FullScreen/FullScreen.js +2 -0
- package/esm/Options/Classes/HslAnimation.js +4 -5
- package/esm/Options/Classes/Options.js +63 -4
- package/esm/Options/Classes/OptionsColor.js +1 -0
- package/esm/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
- package/esm/Options/Classes/Particles/Effect/Effect.js +3 -4
- package/esm/Options/Classes/Particles/Fill.js +28 -0
- package/esm/Options/Classes/Particles/Move/Move.js +17 -3
- package/esm/Options/Classes/Particles/Move/MoveAngle.js +2 -0
- package/esm/Options/Classes/Particles/Move/MoveCenter.js +4 -0
- package/esm/Options/Classes/Particles/Move/MoveGravity.js +4 -0
- package/esm/Options/Classes/Particles/Move/OutModes.js +5 -0
- package/esm/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
- package/esm/Options/Classes/Particles/Move/Spin.js +3 -0
- package/esm/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
- package/esm/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
- package/esm/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
- package/esm/Options/Classes/Particles/Opacity/Opacity.js +1 -0
- package/esm/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
- package/esm/Options/Classes/Particles/ParticlesOptions.js +25 -5
- package/esm/Options/Classes/Particles/Shape/Shape.js +3 -4
- package/esm/Options/Classes/Particles/Size/Size.js +1 -0
- package/esm/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
- package/esm/Options/Classes/Particles/Stroke.js +3 -0
- package/esm/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
- package/esm/Options/Classes/ResizeEvent.js +2 -0
- package/esm/Options/Classes/ValueWithRandom.js +3 -4
- package/esm/Utils/CanvasUtils.js +43 -62
- package/esm/Utils/ColorUtils.js +30 -19
- package/esm/Utils/EventDispatcher.js +1 -0
- package/esm/Utils/MathUtils.js +12 -7
- package/esm/Utils/Utils.js +109 -31
- package/esm/exports.js +1 -2
- package/package.json +1 -1
- package/report.html +3 -3
- package/scripts/install.js +4 -20
- package/tsparticles.engine.js +93 -91
- package/tsparticles.engine.min.js +2 -2
- package/types/Core/Canvas.d.ts +17 -4
- package/types/Core/Container.d.ts +3 -7
- package/types/Core/Engine.d.ts +13 -20
- package/types/Core/Interfaces/IColorManager.d.ts +0 -1
- package/types/Core/Interfaces/IContainerPlugin.d.ts +6 -1
- package/types/Core/Interfaces/IPalette.d.ts +7 -0
- package/types/Core/Interfaces/IParticleOpacityData.d.ts +1 -0
- package/types/Core/Interfaces/IParticleValueAnimation.d.ts +3 -3
- package/types/Core/Interfaces/IShapeDrawData.d.ts +8 -0
- package/types/Core/Interfaces/IShapeDrawer.d.ts +0 -1
- package/types/Core/Interfaces/IShapeValues.d.ts +0 -1
- package/types/Core/Particle.d.ts +4 -7
- package/types/Core/Particles.d.ts +15 -7
- package/types/Core/Utils/Constants.d.ts +2 -2
- package/types/Core/Utils/Ranges.d.ts +4 -1
- package/types/Core/Utils/SpatialHashGrid.d.ts +25 -0
- package/types/Core/Utils/Vectors.d.ts +8 -10
- package/types/Enums/Types/EasingType.d.ts +20 -5
- package/types/Options/Classes/ColorAnimation.d.ts +3 -1
- package/types/Options/Classes/HslAnimation.d.ts +3 -4
- package/types/Options/Classes/Options.d.ts +2 -0
- package/types/Options/Classes/Particles/Effect/Effect.d.ts +0 -1
- package/types/Options/Classes/Particles/Fill.d.ts +12 -0
- package/types/Options/Classes/Particles/Move/Move.d.ts +0 -2
- package/types/Options/Classes/Particles/ParticlesOptions.d.ts +2 -2
- package/types/Options/Classes/Particles/Shape/Shape.d.ts +0 -1
- package/types/Options/Classes/ValueWithRandom.d.ts +0 -1
- package/types/Options/Interfaces/IColorAnimation.d.ts +2 -0
- package/types/Options/Interfaces/IOptions.d.ts +1 -0
- package/types/Options/Interfaces/Particles/Effect/IEffect.d.ts +0 -1
- package/types/Options/Interfaces/Particles/IFill.d.ts +9 -0
- package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +2 -2
- package/types/Options/Interfaces/Particles/IStroke.d.ts +2 -2
- package/types/Options/Interfaces/Particles/Move/IMove.d.ts +0 -2
- package/types/Options/Interfaces/Particles/Shape/IShape.d.ts +0 -1
- package/types/Types/EngineInitializers.d.ts +6 -3
- package/types/Utils/CanvasUtils.d.ts +6 -14
- package/types/Utils/ColorUtils.d.ts +3 -2
- package/types/Utils/MathUtils.d.ts +2 -0
- package/types/Utils/Utils.d.ts +8 -1
- package/types/export-types.d.ts +3 -5
- package/types/exports.d.ts +1 -2
- package/umd/Core/Canvas.js +248 -141
- package/umd/Core/Container.js +80 -74
- package/umd/Core/Engine.js +43 -66
- package/umd/Core/Particle.js +203 -174
- package/umd/Core/Particles.js +187 -138
- package/umd/Core/Retina.js +5 -0
- package/umd/Core/Utils/Constants.js +3 -3
- package/umd/Core/Utils/EventListeners.js +67 -63
- package/umd/Core/Utils/Ranges.js +28 -9
- package/umd/Core/Utils/SpatialHashGrid.js +116 -0
- package/umd/Core/Utils/Vectors.js +17 -18
- package/umd/Enums/Types/EasingType.js +18 -3
- package/umd/Options/Classes/AnimatableColor.js +1 -0
- package/umd/Options/Classes/AnimationOptions.js +8 -0
- package/umd/Options/Classes/Background/Background.js +6 -0
- package/umd/Options/Classes/ColorAnimation.js +12 -1
- package/umd/Options/Classes/FullScreen/FullScreen.js +2 -0
- package/umd/Options/Classes/HslAnimation.js +5 -6
- package/umd/Options/Classes/Options.js +63 -4
- package/umd/Options/Classes/OptionsColor.js +1 -0
- package/umd/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
- package/umd/Options/Classes/Particles/Effect/Effect.js +3 -4
- package/umd/Options/Classes/Particles/Fill.js +42 -0
- package/umd/Options/Classes/Particles/Move/Move.js +18 -4
- package/umd/Options/Classes/Particles/Move/MoveAngle.js +2 -0
- package/umd/Options/Classes/Particles/Move/MoveCenter.js +4 -0
- package/umd/Options/Classes/Particles/Move/MoveGravity.js +4 -0
- package/umd/Options/Classes/Particles/Move/OutModes.js +5 -0
- package/umd/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
- package/umd/Options/Classes/Particles/Move/Spin.js +3 -0
- package/umd/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
- package/umd/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
- package/umd/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
- package/umd/Options/Classes/Particles/Opacity/Opacity.js +1 -0
- package/umd/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
- package/umd/Options/Classes/Particles/ParticlesOptions.js +26 -6
- package/umd/Options/Classes/Particles/Shape/Shape.js +3 -4
- package/umd/Options/Classes/Particles/Size/Size.js +1 -0
- package/umd/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
- package/umd/Options/Classes/Particles/Stroke.js +3 -0
- package/umd/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
- package/umd/Options/Classes/ResizeEvent.js +2 -0
- package/umd/Options/Classes/ValueWithRandom.js +3 -4
- package/umd/Utils/CanvasUtils.js +43 -66
- package/umd/Utils/ColorUtils.js +30 -18
- package/umd/Utils/EventDispatcher.js +1 -0
- package/umd/Utils/MathUtils.js +14 -7
- package/umd/Utils/Utils.js +111 -32
- package/umd/exports.js +2 -3
- package/794.min.js +0 -2
- package/794.min.js.LICENSE.txt +0 -1
- package/browser/Core/Utils/Point.js +0 -6
- package/browser/Core/Utils/QuadTree.js +0 -59
- package/browser/Options/Classes/Particles/Move/MoveAttract.js +0 -33
- package/cjs/Core/Utils/Point.js +0 -6
- package/cjs/Core/Utils/QuadTree.js +0 -59
- package/cjs/Options/Classes/Particles/Move/MoveAttract.js +0 -33
- package/esm/Core/Interfaces/IMovePathGenerator.js +0 -1
- package/esm/Core/Interfaces/IParticleMover.js +0 -1
- package/esm/Core/Utils/Point.js +0 -6
- package/esm/Core/Utils/QuadTree.js +0 -59
- package/esm/Options/Classes/Particles/Move/MoveAttract.js +0 -33
- package/esm/Options/Interfaces/Particles/Move/IMoveAttract.js +0 -1
- package/tsparticles.engine.min.js.LICENSE.txt +0 -1
- package/types/Core/Interfaces/IMovePathGenerator.d.ts +0 -10
- package/types/Core/Interfaces/IParticleMover.d.ts +0 -7
- package/types/Core/Utils/Point.d.ts +0 -7
- package/types/Core/Utils/QuadTree.d.ts +0 -18
- package/types/Options/Classes/Particles/Move/MoveAttract.d.ts +0 -12
- package/types/Options/Interfaces/Particles/Move/IMoveAttract.d.ts +0 -7
- package/umd/Core/Utils/Point.js +0 -20
- package/umd/Core/Utils/QuadTree.js +0 -73
- package/umd/Options/Classes/Particles/Move/MoveAttract.js +0 -47
- package/umd/Options/Interfaces/Particles/Move/IMoveAttract.js +0 -12
- /package/browser/Core/Interfaces/{IMovePathGenerator.js → IPalette.js} +0 -0
- /package/browser/{Core/Interfaces/IParticleMover.js → Options/Interfaces/Particles/IFill.js} +0 -0
- /package/{browser/Options/Interfaces/Particles/Move/IMoveAttract.js → cjs/Core/Interfaces/IPalette.js} +0 -0
- /package/cjs/{Core/Interfaces/IMovePathGenerator.js → Options/Interfaces/Particles/IFill.js} +0 -0
- /package/{cjs/Core/Interfaces/IParticleMover.js → esm/Core/Interfaces/IPalette.js} +0 -0
- /package/{cjs/Options/Interfaces/Particles/Move/IMoveAttract.js → esm/Options/Interfaces/Particles/IFill.js} +0 -0
- /package/umd/Core/Interfaces/{IMovePathGenerator.js → IPalette.js} +0 -0
- /package/umd/{Core/Interfaces/IParticleMover.js → Options/Interfaces/Particles/IFill.js} +0 -0
package/esm/Core/Particle.js
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
import { Vector, Vector3d } from "./Utils/Vectors.js";
|
|
2
|
+
import { alterHsl, getHslFromAnimation } from "../Utils/ColorUtils.js";
|
|
2
3
|
import { calcExactPositionOrRandomFromSize, clamp, degToRad, getParticleBaseVelocity, getParticleDirectionAngle, getRandom, getRangeValue, randomInRangeValue, setRangeValue, } from "../Utils/MathUtils.js";
|
|
3
|
-
import { decayOffset, defaultAngle, defaultOpacity, defaultRetryCount, defaultTransform, double, half, identity, millisecondsToSeconds, minZ, none, randomColorValue, rollFactor, squareExp, tryCountIncrement, zIndexFactorOffset, } from "./Utils/Constants.js";
|
|
4
4
|
import { deepExtend, getPosition, initParticleNumericAnimationValue, isInArray, itemFromSingleOrMultiple, } from "../Utils/Utils.js";
|
|
5
|
+
import { defaultAngle, defaultOpacity, defaultRetryCount, defaultTransform, double, doublePI, half, identity, minZ, randomColorValue, squareExp, triple, tryCountIncrement, zIndexFactorOffset, } from "./Utils/Constants.js";
|
|
5
6
|
import { EventType } from "../Enums/Types/EventType.js";
|
|
6
7
|
import { MoveDirection } from "../Enums/Directions/MoveDirection.js";
|
|
7
8
|
import { OutMode } from "../Enums/Modes/OutMode.js";
|
|
8
9
|
import { ParticleOutType } from "../Enums/Types/ParticleOutType.js";
|
|
9
|
-
import { alterHsl } from "../Utils/CanvasUtils.js";
|
|
10
|
-
import { getHslFromAnimation } from "../Utils/ColorUtils.js";
|
|
11
10
|
import { loadParticlesOptions } from "../Utils/OptionsUtils.js";
|
|
12
11
|
function loadEffectData(effect, effectOptions, id, reduceDuplicates) {
|
|
13
12
|
const effectData = effectOptions.options[effect];
|
|
14
13
|
return deepExtend({
|
|
15
14
|
close: effectOptions.close,
|
|
16
|
-
fill: effectOptions.fill,
|
|
17
15
|
}, itemFromSingleOrMultiple(effectData, id, reduceDuplicates));
|
|
18
16
|
}
|
|
19
17
|
function loadShapeData(shape, shapeOptions, id, reduceDuplicates) {
|
|
20
18
|
const shapeData = shapeOptions.options[shape];
|
|
21
19
|
return deepExtend({
|
|
22
20
|
close: shapeOptions.close,
|
|
23
|
-
fill: shapeOptions.fill,
|
|
24
21
|
}, itemFromSingleOrMultiple(shapeData, id, reduceDuplicates));
|
|
25
22
|
}
|
|
26
23
|
function fixOutMode(data) {
|
|
@@ -36,131 +33,65 @@ function fixOutMode(data) {
|
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
35
|
export class Particle {
|
|
36
|
+
container;
|
|
37
|
+
backColor;
|
|
38
|
+
bubble;
|
|
39
|
+
destroyed;
|
|
40
|
+
direction;
|
|
41
|
+
effect;
|
|
42
|
+
effectClose;
|
|
43
|
+
effectData;
|
|
44
|
+
fillColor;
|
|
45
|
+
fillEnabled;
|
|
46
|
+
fillOpacity;
|
|
47
|
+
group;
|
|
48
|
+
id;
|
|
49
|
+
ignoresResizeRatio;
|
|
50
|
+
initialPosition;
|
|
51
|
+
initialVelocity;
|
|
52
|
+
isRotating;
|
|
53
|
+
lastPathTime;
|
|
54
|
+
misplaced;
|
|
55
|
+
moveCenter;
|
|
56
|
+
offset;
|
|
57
|
+
opacity;
|
|
58
|
+
options;
|
|
59
|
+
outType;
|
|
60
|
+
pathRotation;
|
|
61
|
+
position;
|
|
62
|
+
randomIndexData;
|
|
63
|
+
retina;
|
|
64
|
+
roll;
|
|
65
|
+
rotation;
|
|
66
|
+
shape;
|
|
67
|
+
shapeClose;
|
|
68
|
+
shapeData;
|
|
69
|
+
sides;
|
|
70
|
+
size;
|
|
71
|
+
slow;
|
|
72
|
+
spawning;
|
|
73
|
+
strokeColor;
|
|
74
|
+
strokeOpacity;
|
|
75
|
+
strokeWidth;
|
|
76
|
+
unbreakable;
|
|
77
|
+
velocity;
|
|
78
|
+
zIndexFactor;
|
|
79
|
+
_cachedOpacityData = {
|
|
80
|
+
fillOpacity: defaultOpacity,
|
|
81
|
+
opacity: defaultOpacity,
|
|
82
|
+
strokeOpacity: defaultOpacity,
|
|
83
|
+
};
|
|
84
|
+
_cachedPosition = Vector3d.origin;
|
|
85
|
+
_cachedRotateData = { sin: 0, cos: 0 };
|
|
86
|
+
_cachedTransform = {
|
|
87
|
+
a: 1,
|
|
88
|
+
b: 0,
|
|
89
|
+
c: 0,
|
|
90
|
+
d: 1,
|
|
91
|
+
};
|
|
92
|
+
_engine;
|
|
39
93
|
constructor(engine, container) {
|
|
40
94
|
this.container = container;
|
|
41
|
-
this._cachedOpacityData = {
|
|
42
|
-
opacity: defaultOpacity,
|
|
43
|
-
strokeOpacity: defaultOpacity,
|
|
44
|
-
};
|
|
45
|
-
this._cachedPosition = Vector3d.origin;
|
|
46
|
-
this._cachedRotateData = { sin: 0, cos: 0 };
|
|
47
|
-
this._cachedTransform = {
|
|
48
|
-
a: 1,
|
|
49
|
-
b: 0,
|
|
50
|
-
c: 0,
|
|
51
|
-
d: 1,
|
|
52
|
-
};
|
|
53
|
-
this._calcPosition = (position, zIndex) => {
|
|
54
|
-
let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
|
|
55
|
-
const container = this.container, plugins = Array.from(container.plugins), outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
|
|
56
|
-
while (!signal.aborted) {
|
|
57
|
-
for (const plugin of plugins) {
|
|
58
|
-
const pluginPos = plugin.particlePosition?.(posVec, this);
|
|
59
|
-
if (pluginPos) {
|
|
60
|
-
return Vector3d.create(pluginPos.x, pluginPos.y, zIndex);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const exactPosition = calcExactPositionOrRandomFromSize({
|
|
64
|
-
size: canvasSize,
|
|
65
|
-
position: posVec,
|
|
66
|
-
}), pos = Vector3d.create(exactPosition.x, exactPosition.y, zIndex);
|
|
67
|
-
this._fixHorizontal(pos, radius, outModes.left ?? outModes.default);
|
|
68
|
-
this._fixHorizontal(pos, radius, outModes.right ?? outModes.default);
|
|
69
|
-
this._fixVertical(pos, radius, outModes.top ?? outModes.default);
|
|
70
|
-
this._fixVertical(pos, radius, outModes.bottom ?? outModes.default);
|
|
71
|
-
let isValidPosition = true;
|
|
72
|
-
for (const plugin of plugins) {
|
|
73
|
-
isValidPosition = plugin.checkParticlePosition?.(this, pos, tryCount) ?? true;
|
|
74
|
-
if (!isValidPosition) {
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (isValidPosition) {
|
|
79
|
-
return pos;
|
|
80
|
-
}
|
|
81
|
-
tryCount += tryCountIncrement;
|
|
82
|
-
posVec = undefined;
|
|
83
|
-
}
|
|
84
|
-
return posVec;
|
|
85
|
-
};
|
|
86
|
-
this._calculateVelocity = () => {
|
|
87
|
-
const baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy(), moveOptions = this.options.move;
|
|
88
|
-
if (moveOptions.direction === MoveDirection.inside || moveOptions.direction === MoveDirection.outside) {
|
|
89
|
-
return res;
|
|
90
|
-
}
|
|
91
|
-
const rad = degToRad(getRangeValue(moveOptions.angle.value)), radOffset = degToRad(getRangeValue(moveOptions.angle.offset)), range = {
|
|
92
|
-
left: radOffset - rad * half,
|
|
93
|
-
right: radOffset + rad * half,
|
|
94
|
-
};
|
|
95
|
-
if (!moveOptions.straight) {
|
|
96
|
-
res.angle += randomInRangeValue(setRangeValue(range.left, range.right));
|
|
97
|
-
}
|
|
98
|
-
if (moveOptions.random && typeof moveOptions.speed === "number") {
|
|
99
|
-
res.length *= getRandom();
|
|
100
|
-
}
|
|
101
|
-
return res;
|
|
102
|
-
};
|
|
103
|
-
this._fixHorizontal = (pos, radius, outMode) => {
|
|
104
|
-
fixOutMode({
|
|
105
|
-
outMode,
|
|
106
|
-
checkModes: [OutMode.bounce],
|
|
107
|
-
coord: pos.x,
|
|
108
|
-
maxCoord: this.container.canvas.size.width,
|
|
109
|
-
setCb: (value) => (pos.x += value),
|
|
110
|
-
radius,
|
|
111
|
-
});
|
|
112
|
-
};
|
|
113
|
-
this._fixVertical = (pos, radius, outMode) => {
|
|
114
|
-
fixOutMode({
|
|
115
|
-
outMode,
|
|
116
|
-
checkModes: [OutMode.bounce],
|
|
117
|
-
coord: pos.y,
|
|
118
|
-
maxCoord: this.container.canvas.size.height,
|
|
119
|
-
setCb: (value) => (pos.y += value),
|
|
120
|
-
radius,
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
this._getRollColor = color => {
|
|
124
|
-
if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
|
|
125
|
-
return color;
|
|
126
|
-
}
|
|
127
|
-
const backFactor = this.roll.horizontal && this.roll.vertical ? double * rollFactor : rollFactor, backSum = this.roll.horizontal ? Math.PI * half : none, rolled = Math.floor((this.roll.angle + backSum) / (Math.PI / backFactor)) % double;
|
|
128
|
-
if (!rolled) {
|
|
129
|
-
return color;
|
|
130
|
-
}
|
|
131
|
-
if (this.backColor) {
|
|
132
|
-
return this.backColor;
|
|
133
|
-
}
|
|
134
|
-
if (this.roll.alter) {
|
|
135
|
-
return alterHsl(color, this.roll.alter.type, this.roll.alter.value);
|
|
136
|
-
}
|
|
137
|
-
return color;
|
|
138
|
-
};
|
|
139
|
-
this._initPosition = position => {
|
|
140
|
-
const container = this.container, zIndexValue = getRangeValue(this.options.zIndex.value);
|
|
141
|
-
const initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
|
|
142
|
-
if (!initialPosition) {
|
|
143
|
-
throw new Error("a valid position cannot be found for particle");
|
|
144
|
-
}
|
|
145
|
-
this.position = initialPosition;
|
|
146
|
-
this.initialPosition = this.position.copy();
|
|
147
|
-
const canvasSize = container.canvas.size;
|
|
148
|
-
this.moveCenter = {
|
|
149
|
-
...getPosition(this.options.move.center, canvasSize),
|
|
150
|
-
radius: this.options.move.center.radius,
|
|
151
|
-
mode: this.options.move.center.mode,
|
|
152
|
-
};
|
|
153
|
-
this.direction = getParticleDirectionAngle(this.options.move.direction, this.position, this.moveCenter);
|
|
154
|
-
switch (this.options.move.direction) {
|
|
155
|
-
case MoveDirection.inside:
|
|
156
|
-
this.outType = ParticleOutType.inside;
|
|
157
|
-
break;
|
|
158
|
-
case MoveDirection.outside:
|
|
159
|
-
this.outType = ParticleOutType.outside;
|
|
160
|
-
break;
|
|
161
|
-
}
|
|
162
|
-
this.offset = Vector.origin;
|
|
163
|
-
};
|
|
164
95
|
this._engine = engine;
|
|
165
96
|
}
|
|
166
97
|
destroy(override) {
|
|
@@ -170,15 +101,14 @@ export class Particle {
|
|
|
170
101
|
this.destroyed = true;
|
|
171
102
|
this.bubble.inRange = false;
|
|
172
103
|
this.slow.inRange = false;
|
|
173
|
-
const container = this.container,
|
|
104
|
+
const container = this.container, shapeDrawer = this.shape ? container.particles.shapeDrawers.get(this.shape) : undefined;
|
|
174
105
|
shapeDrawer?.particleDestroy?.(this);
|
|
175
|
-
for (const plugin of container.
|
|
106
|
+
for (const plugin of container.particleDestroyedPlugins) {
|
|
176
107
|
plugin.particleDestroyed?.(this, override);
|
|
177
108
|
}
|
|
178
109
|
for (const updater of container.particles.updaters) {
|
|
179
110
|
updater.particleDestroyed?.(this, override);
|
|
180
111
|
}
|
|
181
|
-
pathGenerator?.reset(this);
|
|
182
112
|
this._engine.dispatchEvent(EventType.particleDestroyed, {
|
|
183
113
|
container: this.container,
|
|
184
114
|
data: {
|
|
@@ -188,24 +118,23 @@ export class Particle {
|
|
|
188
118
|
}
|
|
189
119
|
draw(delta) {
|
|
190
120
|
const container = this.container, canvas = container.canvas;
|
|
191
|
-
|
|
192
|
-
canvas.drawParticlePlugin(plugin, this, delta);
|
|
193
|
-
}
|
|
121
|
+
canvas.drawParticlePlugins(this, delta);
|
|
194
122
|
canvas.drawParticle(this, delta);
|
|
195
123
|
}
|
|
196
124
|
getAngle() {
|
|
197
125
|
return this.rotation + (this.pathRotation ? this.velocity.angle : defaultAngle);
|
|
198
126
|
}
|
|
199
127
|
getFillColor() {
|
|
200
|
-
return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.
|
|
128
|
+
return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.fillColor));
|
|
201
129
|
}
|
|
202
130
|
getMass() {
|
|
203
131
|
return this.getRadius() ** squareExp * Math.PI * half;
|
|
204
132
|
}
|
|
205
133
|
getOpacity() {
|
|
206
|
-
const zIndexOptions = this.options.zIndex, zIndexFactor = zIndexFactorOffset - this.zIndexFactor, zOpacityFactor = zIndexFactor ** zIndexOptions.opacityRate, opacity = this.bubble.opacity ?? getRangeValue(this.opacity?.value ?? defaultOpacity), strokeOpacity = this.strokeOpacity ??
|
|
134
|
+
const zIndexOptions = this.options.zIndex, zIndexFactor = zIndexFactorOffset - this.zIndexFactor, zOpacityFactor = zIndexFactor ** zIndexOptions.opacityRate, opacity = this.bubble.opacity ?? getRangeValue(this.opacity?.value ?? defaultOpacity), fillOpacity = this.fillOpacity ?? defaultOpacity, strokeOpacity = this.strokeOpacity ?? defaultOpacity;
|
|
135
|
+
this._cachedOpacityData.fillOpacity = opacity * fillOpacity * zOpacityFactor;
|
|
207
136
|
this._cachedOpacityData.opacity = opacity * zOpacityFactor;
|
|
208
|
-
this._cachedOpacityData.strokeOpacity = strokeOpacity * zOpacityFactor;
|
|
137
|
+
this._cachedOpacityData.strokeOpacity = opacity * strokeOpacity * zOpacityFactor;
|
|
209
138
|
return this._cachedOpacityData;
|
|
210
139
|
}
|
|
211
140
|
getPosition() {
|
|
@@ -243,9 +172,7 @@ export class Particle {
|
|
|
243
172
|
this.id = id;
|
|
244
173
|
this.group = group;
|
|
245
174
|
this.effectClose = true;
|
|
246
|
-
this.effectFill = true;
|
|
247
175
|
this.shapeClose = true;
|
|
248
|
-
this.shapeFill = true;
|
|
249
176
|
this.pathRotation = false;
|
|
250
177
|
this.lastPathTime = 0;
|
|
251
178
|
this.destroyed = false;
|
|
@@ -279,16 +206,14 @@ export class Particle {
|
|
|
279
206
|
}
|
|
280
207
|
}
|
|
281
208
|
if (this.effect === randomColorValue) {
|
|
282
|
-
const availableEffects = [...this.container.effectDrawers.keys()];
|
|
209
|
+
const availableEffects = [...this.container.particles.effectDrawers.keys()];
|
|
283
210
|
this.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
|
|
284
211
|
}
|
|
285
212
|
if (this.shape === randomColorValue) {
|
|
286
|
-
const availableShapes = [...this.container.shapeDrawers.keys()];
|
|
213
|
+
const availableShapes = [...this.container.particles.shapeDrawers.keys()];
|
|
287
214
|
this.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
|
|
288
215
|
}
|
|
289
|
-
this.effectData = this.effect
|
|
290
|
-
? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates)
|
|
291
|
-
: undefined;
|
|
216
|
+
this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;
|
|
292
217
|
this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;
|
|
293
218
|
particlesOptions.load(overrideOptions);
|
|
294
219
|
const effectData = this.effectData;
|
|
@@ -299,19 +224,9 @@ export class Particle {
|
|
|
299
224
|
if (shapeData) {
|
|
300
225
|
particlesOptions.load(shapeData.particles);
|
|
301
226
|
}
|
|
302
|
-
this.effectFill = effectData?.fill ?? particlesOptions.effect.fill;
|
|
303
227
|
this.effectClose = effectData?.close ?? particlesOptions.effect.close;
|
|
304
|
-
this.shapeFill = shapeData?.fill ?? particlesOptions.shape.fill;
|
|
305
228
|
this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
|
|
306
229
|
this.options = particlesOptions;
|
|
307
|
-
const pathOptions = this.options.move.path;
|
|
308
|
-
this.pathDelay = getRangeValue(pathOptions.delay.value) * millisecondsToSeconds;
|
|
309
|
-
if (pathOptions.generator) {
|
|
310
|
-
this.pathGenerator = this._engine.getPathGenerator(pathOptions.generator);
|
|
311
|
-
if (this.pathGenerator && container.addPath(pathOptions.generator, this.pathGenerator)) {
|
|
312
|
-
this.pathGenerator.init(container);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
230
|
container.retina.initParticle(this);
|
|
316
231
|
this.size = initParticleNumericAnimationValue(this.options.size, pxRatio);
|
|
317
232
|
this.bubble = {
|
|
@@ -324,32 +239,19 @@ export class Particle {
|
|
|
324
239
|
this._initPosition(position);
|
|
325
240
|
this.initialVelocity = this._calculateVelocity();
|
|
326
241
|
this.velocity = this.initialVelocity.copy();
|
|
327
|
-
this.moveDecay = decayOffset - getRangeValue(this.options.move.decay);
|
|
328
242
|
const particles = container.particles;
|
|
329
243
|
particles.setLastZIndex(this.position.z);
|
|
330
244
|
this.zIndexFactor = this.position.z / container.zLayers;
|
|
331
245
|
this.sides = 24;
|
|
332
246
|
let effectDrawer, shapeDrawer;
|
|
333
247
|
if (this.effect) {
|
|
334
|
-
effectDrawer = container.effectDrawers.get(this.effect);
|
|
335
|
-
if (!effectDrawer) {
|
|
336
|
-
effectDrawer = this._engine.getEffectDrawer(this.effect);
|
|
337
|
-
if (effectDrawer) {
|
|
338
|
-
container.effectDrawers.set(this.effect, effectDrawer);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
248
|
+
effectDrawer = container.particles.effectDrawers.get(this.effect);
|
|
341
249
|
}
|
|
342
250
|
if (effectDrawer?.loadEffect) {
|
|
343
251
|
effectDrawer.loadEffect(this);
|
|
344
252
|
}
|
|
345
253
|
if (this.shape) {
|
|
346
|
-
shapeDrawer = container.shapeDrawers.get(this.shape);
|
|
347
|
-
if (!shapeDrawer) {
|
|
348
|
-
shapeDrawer = this._engine.getShapeDrawer(this.shape);
|
|
349
|
-
if (shapeDrawer) {
|
|
350
|
-
container.shapeDrawers.set(this.shape, shapeDrawer);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
254
|
+
shapeDrawer = container.particles.shapeDrawers.get(this.shape);
|
|
353
255
|
}
|
|
354
256
|
if (shapeDrawer?.loadShape) {
|
|
355
257
|
shapeDrawer.loadShape(this);
|
|
@@ -362,12 +264,9 @@ export class Particle {
|
|
|
362
264
|
for (const updater of particles.updaters) {
|
|
363
265
|
updater.init(this);
|
|
364
266
|
}
|
|
365
|
-
for (const mover of particles.movers) {
|
|
366
|
-
mover.init(this);
|
|
367
|
-
}
|
|
368
267
|
effectDrawer?.particleInit?.(container, this);
|
|
369
268
|
shapeDrawer?.particleInit?.(container, this);
|
|
370
|
-
for (const plugin of container.
|
|
269
|
+
for (const plugin of container.particleCreatedPlugins) {
|
|
371
270
|
plugin.particleCreated?.(this);
|
|
372
271
|
}
|
|
373
272
|
}
|
|
@@ -378,6 +277,25 @@ export class Particle {
|
|
|
378
277
|
position.y <= canvasSize.height + radius &&
|
|
379
278
|
position.x <= canvasSize.width + radius);
|
|
380
279
|
}
|
|
280
|
+
isShowingBack() {
|
|
281
|
+
if (!this.roll) {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
const angle = this.roll.angle;
|
|
285
|
+
if (this.roll.horizontal && this.roll.vertical) {
|
|
286
|
+
const normalizedAngle = angle % doublePI, adjustedAngle = normalizedAngle < defaultAngle ? normalizedAngle + doublePI : normalizedAngle;
|
|
287
|
+
return adjustedAngle >= Math.PI * half && adjustedAngle < Math.PI * triple * half;
|
|
288
|
+
}
|
|
289
|
+
if (this.roll.horizontal) {
|
|
290
|
+
const normalizedAngle = (angle + Math.PI * half) % (Math.PI * double), adjustedAngle = normalizedAngle < defaultAngle ? normalizedAngle + Math.PI * double : normalizedAngle;
|
|
291
|
+
return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
|
|
292
|
+
}
|
|
293
|
+
if (this.roll.vertical) {
|
|
294
|
+
const normalizedAngle = angle % (Math.PI * double), adjustedAngle = normalizedAngle < defaultAngle ? normalizedAngle + Math.PI * double : normalizedAngle;
|
|
295
|
+
return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
|
|
296
|
+
}
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
381
299
|
isVisible() {
|
|
382
300
|
return !this.destroyed && !this.spawning && this.isInsideCanvas();
|
|
383
301
|
}
|
|
@@ -386,4 +304,115 @@ export class Particle {
|
|
|
386
304
|
updater.reset?.(this);
|
|
387
305
|
}
|
|
388
306
|
}
|
|
307
|
+
_calcPosition = (position, zIndex) => {
|
|
308
|
+
let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
|
|
309
|
+
const container = this.container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
|
|
310
|
+
while (!signal.aborted) {
|
|
311
|
+
for (const plugin of plugins) {
|
|
312
|
+
const pluginPos = plugin.particlePosition?.(posVec, this);
|
|
313
|
+
if (pluginPos) {
|
|
314
|
+
return Vector3d.create(pluginPos.x, pluginPos.y, zIndex);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
const exactPosition = calcExactPositionOrRandomFromSize({
|
|
318
|
+
size: canvasSize,
|
|
319
|
+
position: posVec,
|
|
320
|
+
}), pos = Vector3d.create(exactPosition.x, exactPosition.y, zIndex);
|
|
321
|
+
this._fixHorizontal(pos, radius, outModes.left ?? outModes.default);
|
|
322
|
+
this._fixHorizontal(pos, radius, outModes.right ?? outModes.default);
|
|
323
|
+
this._fixVertical(pos, radius, outModes.top ?? outModes.default);
|
|
324
|
+
this._fixVertical(pos, radius, outModes.bottom ?? outModes.default);
|
|
325
|
+
let isValidPosition = true;
|
|
326
|
+
for (const plugin of container.particles.checkParticlePositionPlugins) {
|
|
327
|
+
isValidPosition = plugin.checkParticlePosition?.(this, pos, tryCount) ?? true;
|
|
328
|
+
if (!isValidPosition) {
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (isValidPosition) {
|
|
333
|
+
return pos;
|
|
334
|
+
}
|
|
335
|
+
tryCount += tryCountIncrement;
|
|
336
|
+
posVec = undefined;
|
|
337
|
+
}
|
|
338
|
+
return posVec;
|
|
339
|
+
};
|
|
340
|
+
_calculateVelocity = () => {
|
|
341
|
+
const baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy(), moveOptions = this.options.move;
|
|
342
|
+
if (moveOptions.direction === MoveDirection.inside || moveOptions.direction === MoveDirection.outside) {
|
|
343
|
+
return res;
|
|
344
|
+
}
|
|
345
|
+
const rad = degToRad(getRangeValue(moveOptions.angle.value)), radOffset = degToRad(getRangeValue(moveOptions.angle.offset)), range = {
|
|
346
|
+
left: radOffset - rad * half,
|
|
347
|
+
right: radOffset + rad * half,
|
|
348
|
+
};
|
|
349
|
+
if (!moveOptions.straight) {
|
|
350
|
+
res.angle += randomInRangeValue(setRangeValue(range.left, range.right));
|
|
351
|
+
}
|
|
352
|
+
if (moveOptions.random && typeof moveOptions.speed === "number") {
|
|
353
|
+
res.length *= getRandom();
|
|
354
|
+
}
|
|
355
|
+
return res;
|
|
356
|
+
};
|
|
357
|
+
_fixHorizontal = (pos, radius, outMode) => {
|
|
358
|
+
fixOutMode({
|
|
359
|
+
outMode,
|
|
360
|
+
checkModes: [OutMode.bounce],
|
|
361
|
+
coord: pos.x,
|
|
362
|
+
maxCoord: this.container.canvas.size.width,
|
|
363
|
+
setCb: (value) => (pos.x += value),
|
|
364
|
+
radius,
|
|
365
|
+
});
|
|
366
|
+
};
|
|
367
|
+
_fixVertical = (pos, radius, outMode) => {
|
|
368
|
+
fixOutMode({
|
|
369
|
+
outMode,
|
|
370
|
+
checkModes: [OutMode.bounce],
|
|
371
|
+
coord: pos.y,
|
|
372
|
+
maxCoord: this.container.canvas.size.height,
|
|
373
|
+
setCb: (value) => (pos.y += value),
|
|
374
|
+
radius,
|
|
375
|
+
});
|
|
376
|
+
};
|
|
377
|
+
_getRollColor = color => {
|
|
378
|
+
if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
|
|
379
|
+
return color;
|
|
380
|
+
}
|
|
381
|
+
if (!this.isShowingBack()) {
|
|
382
|
+
return color;
|
|
383
|
+
}
|
|
384
|
+
if (this.backColor) {
|
|
385
|
+
return this.backColor;
|
|
386
|
+
}
|
|
387
|
+
if (this.roll.alter) {
|
|
388
|
+
return alterHsl(color, this.roll.alter.type, this.roll.alter.value);
|
|
389
|
+
}
|
|
390
|
+
return color;
|
|
391
|
+
};
|
|
392
|
+
_initPosition = position => {
|
|
393
|
+
const container = this.container, zIndexValue = getRangeValue(this.options.zIndex.value), initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
|
|
394
|
+
if (!initialPosition) {
|
|
395
|
+
throw new Error("a valid position cannot be found for particle");
|
|
396
|
+
}
|
|
397
|
+
this.position = initialPosition;
|
|
398
|
+
this.initialPosition = this.position.copy();
|
|
399
|
+
const canvasSize = container.canvas.size;
|
|
400
|
+
this.moveCenter = {
|
|
401
|
+
...getPosition(this.options.move.center, canvasSize),
|
|
402
|
+
radius: this.options.move.center.radius,
|
|
403
|
+
mode: this.options.move.center.mode,
|
|
404
|
+
};
|
|
405
|
+
this.direction = getParticleDirectionAngle(this.options.move.direction, this.position, this.moveCenter);
|
|
406
|
+
switch (this.options.move.direction) {
|
|
407
|
+
case MoveDirection.inside:
|
|
408
|
+
this.outType = ParticleOutType.inside;
|
|
409
|
+
break;
|
|
410
|
+
case MoveDirection.outside:
|
|
411
|
+
this.outType = ParticleOutType.outside;
|
|
412
|
+
break;
|
|
413
|
+
default:
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
416
|
+
this.offset = Vector.origin;
|
|
417
|
+
};
|
|
389
418
|
}
|