@tsparticles/engine 3.3.0 → 3.5.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/README.md +0 -4
- package/browser/Core/Canvas.js +27 -22
- package/browser/Core/Container.js +57 -44
- package/browser/Core/Engine.js +82 -74
- package/browser/Core/Particle.js +29 -15
- package/browser/Core/Particles.js +23 -24
- package/browser/Core/Utils/EventListeners.js +18 -17
- package/browser/Core/Utils/ExternalInteractorBase.js +2 -1
- package/browser/Core/Utils/InteractionManager.js +3 -2
- package/browser/Core/Utils/ParticlesInteractorBase.js +2 -1
- package/browser/Core/Utils/QuadTree.js +1 -1
- package/browser/Core/Utils/Ranges.js +5 -4
- package/browser/Enums/AnimationStatus.js +5 -1
- package/browser/Enums/Directions/MoveDirection.js +14 -1
- package/browser/Enums/Directions/OutModeDirection.js +7 -1
- package/browser/Enums/Directions/RotateDirection.js +6 -1
- package/browser/Enums/InteractivityDetect.js +6 -1
- package/browser/Enums/Modes/AnimationMode.js +7 -1
- package/browser/Enums/Modes/CollisionMode.js +6 -1
- package/browser/Enums/Modes/LimitMode.js +5 -1
- package/browser/Enums/Modes/OutMode.js +8 -1
- package/browser/Enums/Modes/PixelMode.js +5 -1
- package/browser/Enums/Modes/ResponsiveMode.js +5 -1
- package/browser/Enums/Modes/ThemeMode.js +6 -1
- package/browser/Enums/Types/AlterType.js +5 -1
- package/browser/Enums/Types/DestroyType.js +6 -1
- package/browser/Enums/Types/DivType.js +5 -1
- package/browser/Enums/Types/EasingType.js +30 -1
- package/browser/Enums/Types/EventType.js +15 -1
- package/browser/Enums/Types/GradientType.js +6 -1
- package/browser/Enums/Types/InteractorType.js +5 -1
- package/browser/Enums/Types/ParticleOutType.js +6 -1
- package/browser/Enums/Types/StartValueType.js +6 -1
- package/browser/Options/Classes/AnimationOptions.js +4 -2
- package/browser/Options/Classes/Interactivity/Events/DivEvent.js +2 -1
- package/browser/Options/Classes/Interactivity/Events/Events.js +1 -1
- package/browser/Options/Classes/Interactivity/Interactivity.js +2 -1
- package/browser/Options/Classes/ManualParticle.js +2 -1
- package/browser/Options/Classes/Options.js +14 -12
- package/browser/Options/Classes/Particles/Collisions/Collisions.js +2 -1
- package/browser/Options/Classes/Particles/Move/Move.js +2 -1
- package/browser/Options/Classes/Particles/Move/MoveCenter.js +2 -1
- package/browser/Options/Classes/Particles/Move/OutModes.js +2 -1
- package/browser/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -1
- package/browser/Options/Classes/Particles/Opacity/OpacityAnimation.js +2 -1
- package/browser/Options/Classes/Particles/ParticlesOptions.js +1 -1
- package/browser/Options/Classes/Particles/Size/SizeAnimation.js +2 -1
- package/browser/Options/Classes/Responsive.js +5 -4
- package/browser/Options/Classes/Theme/ThemeDefault.js +2 -1
- package/browser/Types/RangeType.js +5 -1
- package/browser/Utils/CanvasUtils.js +13 -7
- package/browser/Utils/ColorUtils.js +17 -9
- package/browser/Utils/EventDispatcher.js +1 -1
- package/browser/Utils/HslColorManager.js +11 -4
- package/browser/Utils/NumberUtils.js +28 -14
- package/browser/Utils/RgbColorManager.js +11 -4
- package/browser/Utils/Utils.js +37 -31
- package/cjs/Core/Canvas.js +27 -22
- package/cjs/Core/Container.js +57 -44
- package/cjs/Core/Engine.js +82 -74
- package/cjs/Core/Particle.js +29 -15
- package/cjs/Core/Particles.js +23 -24
- package/cjs/Core/Utils/EventListeners.js +18 -17
- package/cjs/Core/Utils/ExternalInteractorBase.js +2 -1
- package/cjs/Core/Utils/InteractionManager.js +3 -2
- package/cjs/Core/Utils/ParticlesInteractorBase.js +2 -1
- package/cjs/Core/Utils/QuadTree.js +1 -1
- package/cjs/Core/Utils/Ranges.js +5 -4
- package/cjs/Enums/AnimationStatus.js +6 -0
- package/cjs/Enums/Directions/MoveDirection.js +15 -0
- package/cjs/Enums/Directions/OutModeDirection.js +8 -0
- package/cjs/Enums/Directions/RotateDirection.js +7 -0
- package/cjs/Enums/InteractivityDetect.js +7 -0
- package/cjs/Enums/Modes/AnimationMode.js +8 -0
- package/cjs/Enums/Modes/CollisionMode.js +7 -0
- package/cjs/Enums/Modes/LimitMode.js +6 -0
- package/cjs/Enums/Modes/OutMode.js +9 -0
- package/cjs/Enums/Modes/PixelMode.js +6 -0
- package/cjs/Enums/Modes/ResponsiveMode.js +6 -0
- package/cjs/Enums/Modes/ThemeMode.js +7 -0
- package/cjs/Enums/Types/AlterType.js +6 -0
- package/cjs/Enums/Types/DestroyType.js +7 -0
- package/cjs/Enums/Types/DivType.js +6 -0
- package/cjs/Enums/Types/EasingType.js +31 -0
- package/cjs/Enums/Types/EventType.js +16 -0
- package/cjs/Enums/Types/GradientType.js +7 -0
- package/cjs/Enums/Types/InteractorType.js +6 -0
- package/cjs/Enums/Types/ParticleOutType.js +7 -0
- package/cjs/Enums/Types/StartValueType.js +7 -0
- package/cjs/Options/Classes/AnimationOptions.js +4 -2
- package/cjs/Options/Classes/Interactivity/Events/DivEvent.js +2 -1
- package/cjs/Options/Classes/Interactivity/Events/Events.js +1 -1
- package/cjs/Options/Classes/Interactivity/Interactivity.js +2 -1
- package/cjs/Options/Classes/ManualParticle.js +2 -1
- package/cjs/Options/Classes/Options.js +14 -12
- package/cjs/Options/Classes/Particles/Collisions/Collisions.js +2 -1
- package/cjs/Options/Classes/Particles/Move/Move.js +2 -1
- package/cjs/Options/Classes/Particles/Move/MoveCenter.js +2 -1
- package/cjs/Options/Classes/Particles/Move/OutModes.js +2 -1
- package/cjs/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -1
- package/cjs/Options/Classes/Particles/Opacity/OpacityAnimation.js +2 -1
- package/cjs/Options/Classes/Particles/ParticlesOptions.js +1 -1
- package/cjs/Options/Classes/Particles/Size/SizeAnimation.js +2 -1
- package/cjs/Options/Classes/Responsive.js +5 -4
- package/cjs/Options/Classes/Theme/ThemeDefault.js +2 -1
- package/cjs/Types/RangeType.js +6 -0
- package/cjs/Utils/CanvasUtils.js +24 -19
- package/cjs/Utils/ColorUtils.js +37 -30
- package/cjs/Utils/EventDispatcher.js +1 -1
- package/cjs/Utils/HslColorManager.js +11 -4
- package/cjs/Utils/NumberUtils.js +54 -38
- package/cjs/Utils/OptionsUtils.js +2 -3
- package/cjs/Utils/RgbColorManager.js +11 -4
- package/cjs/Utils/TypeUtils.js +6 -7
- package/cjs/Utils/Utils.js +66 -61
- package/cjs/init.js +1 -2
- package/esm/Core/Canvas.js +27 -22
- package/esm/Core/Container.js +57 -44
- package/esm/Core/Engine.js +82 -74
- package/esm/Core/Particle.js +29 -15
- package/esm/Core/Particles.js +23 -24
- package/esm/Core/Utils/EventListeners.js +18 -17
- package/esm/Core/Utils/ExternalInteractorBase.js +2 -1
- package/esm/Core/Utils/InteractionManager.js +3 -2
- package/esm/Core/Utils/ParticlesInteractorBase.js +2 -1
- package/esm/Core/Utils/QuadTree.js +1 -1
- package/esm/Core/Utils/Ranges.js +5 -4
- package/esm/Enums/AnimationStatus.js +5 -1
- package/esm/Enums/Directions/MoveDirection.js +14 -1
- package/esm/Enums/Directions/OutModeDirection.js +7 -1
- package/esm/Enums/Directions/RotateDirection.js +6 -1
- package/esm/Enums/InteractivityDetect.js +6 -1
- package/esm/Enums/Modes/AnimationMode.js +7 -1
- package/esm/Enums/Modes/CollisionMode.js +6 -1
- package/esm/Enums/Modes/LimitMode.js +5 -1
- package/esm/Enums/Modes/OutMode.js +8 -1
- package/esm/Enums/Modes/PixelMode.js +5 -1
- package/esm/Enums/Modes/ResponsiveMode.js +5 -1
- package/esm/Enums/Modes/ThemeMode.js +6 -1
- package/esm/Enums/Types/AlterType.js +5 -1
- package/esm/Enums/Types/DestroyType.js +6 -1
- package/esm/Enums/Types/DivType.js +5 -1
- package/esm/Enums/Types/EasingType.js +30 -1
- package/esm/Enums/Types/EventType.js +15 -1
- package/esm/Enums/Types/GradientType.js +6 -1
- package/esm/Enums/Types/InteractorType.js +5 -1
- package/esm/Enums/Types/ParticleOutType.js +6 -1
- package/esm/Enums/Types/StartValueType.js +6 -1
- package/esm/Options/Classes/AnimationOptions.js +4 -2
- package/esm/Options/Classes/Interactivity/Events/DivEvent.js +2 -1
- package/esm/Options/Classes/Interactivity/Events/Events.js +1 -1
- package/esm/Options/Classes/Interactivity/Interactivity.js +2 -1
- package/esm/Options/Classes/ManualParticle.js +2 -1
- package/esm/Options/Classes/Options.js +14 -12
- package/esm/Options/Classes/Particles/Collisions/Collisions.js +2 -1
- package/esm/Options/Classes/Particles/Move/Move.js +2 -1
- package/esm/Options/Classes/Particles/Move/MoveCenter.js +2 -1
- package/esm/Options/Classes/Particles/Move/OutModes.js +2 -1
- package/esm/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -1
- package/esm/Options/Classes/Particles/Opacity/OpacityAnimation.js +2 -1
- package/esm/Options/Classes/Particles/ParticlesOptions.js +1 -1
- package/esm/Options/Classes/Particles/Size/SizeAnimation.js +2 -1
- package/esm/Options/Classes/Responsive.js +5 -4
- package/esm/Options/Classes/Theme/ThemeDefault.js +2 -1
- package/esm/Types/RangeType.js +5 -1
- package/esm/Utils/CanvasUtils.js +13 -7
- package/esm/Utils/ColorUtils.js +17 -9
- package/esm/Utils/EventDispatcher.js +1 -1
- package/esm/Utils/HslColorManager.js +11 -4
- package/esm/Utils/NumberUtils.js +28 -14
- package/esm/Utils/RgbColorManager.js +11 -4
- package/esm/Utils/Utils.js +37 -31
- package/package.json +1 -1
- package/report.html +1 -1
- package/tsparticles.engine.js +327 -225
- package/tsparticles.engine.min.js +1 -1
- package/tsparticles.engine.min.js.LICENSE.txt +1 -1
- package/types/Core/Container.d.ts +4 -2
- package/types/Core/Engine.d.ts +6 -5
- package/types/Core/Interfaces/IPlugin.d.ts +3 -4
- package/types/Core/Interfaces/IShapeDrawer.d.ts +1 -0
- package/types/Core/Particle.d.ts +1 -0
- package/types/Enums/AnimationStatus.d.ts +1 -1
- package/types/Enums/Directions/MoveDirection.d.ts +1 -1
- package/types/Enums/Directions/OutModeDirection.d.ts +1 -1
- package/types/Enums/Directions/RotateDirection.d.ts +1 -1
- package/types/Enums/InteractivityDetect.d.ts +1 -1
- package/types/Enums/Modes/AnimationMode.d.ts +1 -1
- package/types/Enums/Modes/CollisionMode.d.ts +1 -1
- package/types/Enums/Modes/LimitMode.d.ts +1 -1
- package/types/Enums/Modes/OutMode.d.ts +1 -1
- package/types/Enums/Modes/PixelMode.d.ts +1 -1
- package/types/Enums/Modes/ResponsiveMode.d.ts +1 -1
- package/types/Enums/Modes/ThemeMode.d.ts +1 -1
- package/types/Enums/Types/AlterType.d.ts +1 -1
- package/types/Enums/Types/DestroyType.d.ts +1 -1
- package/types/Enums/Types/DivType.d.ts +1 -1
- package/types/Enums/Types/EasingType.d.ts +1 -1
- package/types/Enums/Types/EventType.d.ts +1 -1
- package/types/Enums/Types/GradientType.d.ts +1 -1
- package/types/Enums/Types/InteractorType.d.ts +1 -1
- package/types/Enums/Types/ParticleOutType.d.ts +1 -1
- package/types/Enums/Types/StartValueType.d.ts +1 -1
- package/types/Options/Classes/Options.d.ts +2 -1
- package/types/Options/Classes/Responsive.d.ts +2 -2
- package/types/Options/Classes/Theme/Theme.d.ts +2 -2
- package/types/Options/Interfaces/IResponsive.d.ts +2 -3
- package/types/Options/Interfaces/Theme/ITheme.d.ts +2 -3
- package/types/Types/RangeType.d.ts +1 -1
- package/types/Utils/NumberUtils.d.ts +3 -0
- package/umd/Core/Canvas.js +27 -22
- package/umd/Core/Container.js +58 -45
- package/umd/Core/Engine.js +83 -99
- package/umd/Core/Particle.js +30 -16
- package/umd/Core/Particles.js +24 -25
- package/umd/Core/Utils/EventListeners.js +19 -18
- package/umd/Core/Utils/ExternalInteractorBase.js +3 -2
- package/umd/Core/Utils/InteractionManager.js +4 -3
- package/umd/Core/Utils/ParticlesInteractorBase.js +3 -2
- package/umd/Core/Utils/QuadTree.js +1 -1
- package/umd/Core/Utils/Ranges.js +6 -5
- package/umd/Enums/AnimationStatus.js +6 -0
- package/umd/Enums/Directions/MoveDirection.js +15 -0
- package/umd/Enums/Directions/OutModeDirection.js +8 -0
- package/umd/Enums/Directions/RotateDirection.js +7 -0
- package/umd/Enums/InteractivityDetect.js +7 -0
- package/umd/Enums/Modes/AnimationMode.js +8 -0
- package/umd/Enums/Modes/CollisionMode.js +7 -0
- package/umd/Enums/Modes/LimitMode.js +6 -0
- package/umd/Enums/Modes/OutMode.js +9 -0
- package/umd/Enums/Modes/PixelMode.js +6 -0
- package/umd/Enums/Modes/ResponsiveMode.js +6 -0
- package/umd/Enums/Modes/ThemeMode.js +7 -0
- package/umd/Enums/Types/AlterType.js +6 -0
- package/umd/Enums/Types/DestroyType.js +7 -0
- package/umd/Enums/Types/DivType.js +6 -0
- package/umd/Enums/Types/EasingType.js +31 -0
- package/umd/Enums/Types/EventType.js +16 -0
- package/umd/Enums/Types/GradientType.js +7 -0
- package/umd/Enums/Types/InteractorType.js +6 -0
- package/umd/Enums/Types/ParticleOutType.js +7 -0
- package/umd/Enums/Types/StartValueType.js +7 -0
- package/umd/Options/Classes/AnimationOptions.js +5 -3
- package/umd/Options/Classes/Interactivity/Events/DivEvent.js +3 -2
- package/umd/Options/Classes/Interactivity/Events/Events.js +1 -1
- package/umd/Options/Classes/Interactivity/Interactivity.js +3 -2
- package/umd/Options/Classes/ManualParticle.js +3 -2
- package/umd/Options/Classes/Options.js +15 -13
- package/umd/Options/Classes/Particles/Collisions/Collisions.js +3 -2
- package/umd/Options/Classes/Particles/Move/Move.js +3 -2
- package/umd/Options/Classes/Particles/Move/MoveCenter.js +3 -2
- package/umd/Options/Classes/Particles/Move/OutModes.js +3 -2
- package/umd/Options/Classes/Particles/Number/ParticlesNumberLimit.js +3 -2
- package/umd/Options/Classes/Particles/Opacity/OpacityAnimation.js +3 -2
- package/umd/Options/Classes/Particles/ParticlesOptions.js +1 -1
- package/umd/Options/Classes/Particles/Size/SizeAnimation.js +3 -2
- package/umd/Options/Classes/Responsive.js +6 -5
- package/umd/Options/Classes/Theme/ThemeDefault.js +3 -2
- package/umd/Types/RangeType.js +6 -0
- package/umd/Utils/CanvasUtils.js +25 -20
- package/umd/Utils/ColorUtils.js +38 -31
- package/umd/Utils/EventDispatcher.js +1 -1
- package/umd/Utils/HslColorManager.js +11 -4
- package/umd/Utils/NumberUtils.js +55 -39
- package/umd/Utils/OptionsUtils.js +2 -3
- package/umd/Utils/RgbColorManager.js +11 -4
- package/umd/Utils/TypeUtils.js +6 -7
- package/umd/Utils/Utils.js +67 -62
- package/umd/init.js +1 -2
- package/174.min.js +0 -2
- package/174.min.js.LICENSE.txt +0 -1
- package/dist_browser_Core_Container_js.js +0 -102
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RangeType } from "../../Types/RangeType.js";
|
|
1
2
|
import { getDistance } from "../../Utils/NumberUtils.js";
|
|
2
3
|
const squareExp = 2;
|
|
3
4
|
export class BaseRange {
|
|
@@ -11,7 +12,7 @@ export class BaseRange {
|
|
|
11
12
|
}
|
|
12
13
|
export class Circle extends BaseRange {
|
|
13
14
|
constructor(x, y, radius) {
|
|
14
|
-
super(x, y,
|
|
15
|
+
super(x, y, RangeType.circle);
|
|
15
16
|
this.radius = radius;
|
|
16
17
|
}
|
|
17
18
|
contains(point) {
|
|
@@ -19,11 +20,11 @@ export class Circle extends BaseRange {
|
|
|
19
20
|
}
|
|
20
21
|
intersects(range) {
|
|
21
22
|
const pos1 = this.position, pos2 = range.position, distPos = { x: Math.abs(pos2.x - pos1.x), y: Math.abs(pos2.y - pos1.y) }, r = this.radius;
|
|
22
|
-
if (range instanceof Circle || range.type ===
|
|
23
|
+
if (range instanceof Circle || range.type === RangeType.circle) {
|
|
23
24
|
const circleRange = range, rSum = r + circleRange.radius, dist = Math.sqrt(distPos.x ** squareExp + distPos.y ** squareExp);
|
|
24
25
|
return rSum > dist;
|
|
25
26
|
}
|
|
26
|
-
else if (range instanceof Rectangle || range.type ===
|
|
27
|
+
else if (range instanceof Rectangle || range.type === RangeType.rectangle) {
|
|
27
28
|
const rectRange = range, { width, height } = rectRange.size, edges = Math.pow(distPos.x - width, squareExp) + Math.pow(distPos.y - height, squareExp);
|
|
28
29
|
return (edges <= r ** squareExp ||
|
|
29
30
|
(distPos.x <= r + width && distPos.y <= r + height) ||
|
|
@@ -35,7 +36,7 @@ export class Circle extends BaseRange {
|
|
|
35
36
|
}
|
|
36
37
|
export class Rectangle extends BaseRange {
|
|
37
38
|
constructor(x, y, width, height) {
|
|
38
|
-
super(x, y,
|
|
39
|
+
super(x, y, RangeType.rectangle);
|
|
39
40
|
this.size = {
|
|
40
41
|
height: height,
|
|
41
42
|
width: width,
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
export
|
|
1
|
+
export var MoveDirection;
|
|
2
|
+
(function (MoveDirection) {
|
|
3
|
+
MoveDirection["bottom"] = "bottom";
|
|
4
|
+
MoveDirection["bottomLeft"] = "bottom-left";
|
|
5
|
+
MoveDirection["bottomRight"] = "bottom-right";
|
|
6
|
+
MoveDirection["left"] = "left";
|
|
7
|
+
MoveDirection["none"] = "none";
|
|
8
|
+
MoveDirection["right"] = "right";
|
|
9
|
+
MoveDirection["top"] = "top";
|
|
10
|
+
MoveDirection["topLeft"] = "top-left";
|
|
11
|
+
MoveDirection["topRight"] = "top-right";
|
|
12
|
+
MoveDirection["outside"] = "outside";
|
|
13
|
+
MoveDirection["inside"] = "inside";
|
|
14
|
+
})(MoveDirection || (MoveDirection = {}));
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
export
|
|
1
|
+
export var OutModeDirection;
|
|
2
|
+
(function (OutModeDirection) {
|
|
3
|
+
OutModeDirection["bottom"] = "bottom";
|
|
4
|
+
OutModeDirection["left"] = "left";
|
|
5
|
+
OutModeDirection["right"] = "right";
|
|
6
|
+
OutModeDirection["top"] = "top";
|
|
7
|
+
})(OutModeDirection || (OutModeDirection = {}));
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
export
|
|
1
|
+
export var AnimationMode;
|
|
2
|
+
(function (AnimationMode) {
|
|
3
|
+
AnimationMode["auto"] = "auto";
|
|
4
|
+
AnimationMode["increase"] = "increase";
|
|
5
|
+
AnimationMode["decrease"] = "decrease";
|
|
6
|
+
AnimationMode["random"] = "random";
|
|
7
|
+
})(AnimationMode || (AnimationMode = {}));
|
|
@@ -1 +1,30 @@
|
|
|
1
|
-
export
|
|
1
|
+
export var EasingType;
|
|
2
|
+
(function (EasingType) {
|
|
3
|
+
EasingType["easeInBack"] = "ease-in-back";
|
|
4
|
+
EasingType["easeInCirc"] = "ease-in-circ";
|
|
5
|
+
EasingType["easeInCubic"] = "ease-in-cubic";
|
|
6
|
+
EasingType["easeInLinear"] = "ease-in-linear";
|
|
7
|
+
EasingType["easeInQuad"] = "ease-in-quad";
|
|
8
|
+
EasingType["easeInQuart"] = "ease-in-quart";
|
|
9
|
+
EasingType["easeInQuint"] = "ease-in-quint";
|
|
10
|
+
EasingType["easeInExpo"] = "ease-in-expo";
|
|
11
|
+
EasingType["easeInSine"] = "ease-in-sine";
|
|
12
|
+
EasingType["easeOutBack"] = "ease-out-back";
|
|
13
|
+
EasingType["easeOutCirc"] = "ease-out-circ";
|
|
14
|
+
EasingType["easeOutCubic"] = "ease-out-cubic";
|
|
15
|
+
EasingType["easeOutLinear"] = "ease-out-linear";
|
|
16
|
+
EasingType["easeOutQuad"] = "ease-out-quad";
|
|
17
|
+
EasingType["easeOutQuart"] = "ease-out-quart";
|
|
18
|
+
EasingType["easeOutQuint"] = "ease-out-quint";
|
|
19
|
+
EasingType["easeOutExpo"] = "ease-out-expo";
|
|
20
|
+
EasingType["easeOutSine"] = "ease-out-sine";
|
|
21
|
+
EasingType["easeInOutBack"] = "ease-in-out-back";
|
|
22
|
+
EasingType["easeInOutCirc"] = "ease-in-out-circ";
|
|
23
|
+
EasingType["easeInOutCubic"] = "ease-in-out-cubic";
|
|
24
|
+
EasingType["easeInOutLinear"] = "ease-in-out-linear";
|
|
25
|
+
EasingType["easeInOutQuad"] = "ease-in-out-quad";
|
|
26
|
+
EasingType["easeInOutQuart"] = "ease-in-out-quart";
|
|
27
|
+
EasingType["easeInOutQuint"] = "ease-in-out-quint";
|
|
28
|
+
EasingType["easeInOutExpo"] = "ease-in-out-expo";
|
|
29
|
+
EasingType["easeInOutSine"] = "ease-in-out-sine";
|
|
30
|
+
})(EasingType || (EasingType = {}));
|
|
@@ -1 +1,15 @@
|
|
|
1
|
-
export
|
|
1
|
+
export var EventType;
|
|
2
|
+
(function (EventType) {
|
|
3
|
+
EventType["configAdded"] = "configAdded";
|
|
4
|
+
EventType["containerInit"] = "containerInit";
|
|
5
|
+
EventType["particlesSetup"] = "particlesSetup";
|
|
6
|
+
EventType["containerStarted"] = "containerStarted";
|
|
7
|
+
EventType["containerStopped"] = "containerStopped";
|
|
8
|
+
EventType["containerDestroyed"] = "containerDestroyed";
|
|
9
|
+
EventType["containerPaused"] = "containerPaused";
|
|
10
|
+
EventType["containerPlay"] = "containerPlay";
|
|
11
|
+
EventType["containerBuilt"] = "containerBuilt";
|
|
12
|
+
EventType["particleAdded"] = "particleAdded";
|
|
13
|
+
EventType["particleDestroyed"] = "particleDestroyed";
|
|
14
|
+
EventType["particleRemoved"] = "particleRemoved";
|
|
15
|
+
})(EventType || (EventType = {}));
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { AnimationMode } from "../../Enums/Modes/AnimationMode.js";
|
|
2
|
+
import { StartValueType } from "../../Enums/Types/StartValueType.js";
|
|
1
3
|
import { setRangeValue } from "../../Utils/NumberUtils.js";
|
|
2
4
|
export class AnimationOptions {
|
|
3
5
|
constructor() {
|
|
@@ -35,8 +37,8 @@ export class AnimationOptions {
|
|
|
35
37
|
export class RangedAnimationOptions extends AnimationOptions {
|
|
36
38
|
constructor() {
|
|
37
39
|
super();
|
|
38
|
-
this.mode =
|
|
39
|
-
this.startValue =
|
|
40
|
+
this.mode = AnimationMode.auto;
|
|
41
|
+
this.startValue = StartValueType.random;
|
|
40
42
|
}
|
|
41
43
|
load(data) {
|
|
42
44
|
super.load(data);
|
|
@@ -17,7 +17,7 @@ export class Events {
|
|
|
17
17
|
this.onClick.load(data.onClick);
|
|
18
18
|
const onDiv = data.onDiv;
|
|
19
19
|
if (onDiv !== undefined) {
|
|
20
|
-
this.onDiv = executeOnSingleOrMultiple(onDiv,
|
|
20
|
+
this.onDiv = executeOnSingleOrMultiple(onDiv, t => {
|
|
21
21
|
const tmp = new DivEvent();
|
|
22
22
|
tmp.load(t);
|
|
23
23
|
return tmp;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Events } from "./Events/Events.js";
|
|
2
|
+
import { InteractivityDetect } from "../../../Enums/InteractivityDetect.js";
|
|
2
3
|
import { Modes } from "./Modes/Modes.js";
|
|
3
4
|
export class Interactivity {
|
|
4
5
|
constructor(engine, container) {
|
|
5
|
-
this.detectsOn =
|
|
6
|
+
this.detectsOn = InteractivityDetect.window;
|
|
6
7
|
this.events = new Events();
|
|
7
8
|
this.modes = new Modes(engine, container);
|
|
8
9
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PixelMode } from "../../Enums/Modes/PixelMode.js";
|
|
1
2
|
import { deepExtend } from "../../Utils/Utils.js";
|
|
2
3
|
const defaultPosition = 50;
|
|
3
4
|
export class ManualParticle {
|
|
@@ -9,7 +10,7 @@ export class ManualParticle {
|
|
|
9
10
|
this.position = {
|
|
10
11
|
x: data.position.x ?? defaultPosition,
|
|
11
12
|
y: data.position.y ?? defaultPosition,
|
|
12
|
-
mode: data.position.mode ??
|
|
13
|
+
mode: data.position.mode ?? PixelMode.percent,
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
16
|
if (data.options) {
|
|
@@ -5,17 +5,19 @@ import { FullScreen } from "./FullScreen/FullScreen.js";
|
|
|
5
5
|
import { Interactivity } from "./Interactivity/Interactivity.js";
|
|
6
6
|
import { ManualParticle } from "./ManualParticle.js";
|
|
7
7
|
import { Responsive } from "./Responsive.js";
|
|
8
|
+
import { ResponsiveMode } from "../../Enums/Modes/ResponsiveMode.js";
|
|
8
9
|
import { Theme } from "./Theme/Theme.js";
|
|
10
|
+
import { ThemeMode } from "../../Enums/Modes/ThemeMode.js";
|
|
9
11
|
import { isBoolean } from "../../Utils/TypeUtils.js";
|
|
10
12
|
import { loadParticlesOptions } from "../../Utils/OptionsUtils.js";
|
|
11
13
|
import { setRangeValue } from "../../Utils/NumberUtils.js";
|
|
12
14
|
export class Options {
|
|
13
15
|
constructor(engine, container) {
|
|
14
|
-
this._findDefaultTheme =
|
|
15
|
-
return (this.themes.find(
|
|
16
|
-
this.themes.find(
|
|
16
|
+
this._findDefaultTheme = mode => {
|
|
17
|
+
return (this.themes.find(theme => theme.default.value && theme.default.mode === mode) ??
|
|
18
|
+
this.themes.find(theme => theme.default.value && theme.default.mode === ThemeMode.any));
|
|
17
19
|
};
|
|
18
|
-
this._importPreset =
|
|
20
|
+
this._importPreset = preset => {
|
|
19
21
|
this.load(this._engine.getPreset(preset));
|
|
20
22
|
};
|
|
21
23
|
this._engine = engine;
|
|
@@ -46,7 +48,7 @@ export class Options {
|
|
|
46
48
|
return;
|
|
47
49
|
}
|
|
48
50
|
if (data.preset !== undefined) {
|
|
49
|
-
executeOnSingleOrMultiple(data.preset,
|
|
51
|
+
executeOnSingleOrMultiple(data.preset, preset => this._importPreset(preset));
|
|
50
52
|
}
|
|
51
53
|
if (data.autoPlay !== undefined) {
|
|
52
54
|
this.autoPlay = data.autoPlay;
|
|
@@ -94,7 +96,7 @@ export class Options {
|
|
|
94
96
|
this.backgroundMask.load(data.backgroundMask);
|
|
95
97
|
this.interactivity.load(data.interactivity);
|
|
96
98
|
if (data.manualParticles) {
|
|
97
|
-
this.manualParticles = data.manualParticles.map(
|
|
99
|
+
this.manualParticles = data.manualParticles.map(t => {
|
|
98
100
|
const tmp = new ManualParticle();
|
|
99
101
|
tmp.load(t);
|
|
100
102
|
return tmp;
|
|
@@ -124,7 +126,7 @@ export class Options {
|
|
|
124
126
|
this.responsive.sort((a, b) => a.maxWidth - b.maxWidth);
|
|
125
127
|
if (data.themes !== undefined) {
|
|
126
128
|
for (const theme of data.themes) {
|
|
127
|
-
const existingTheme = this.themes.find(
|
|
129
|
+
const existingTheme = this.themes.find(t => t.name === theme.name);
|
|
128
130
|
if (!existingTheme) {
|
|
129
131
|
const optTheme = new Theme();
|
|
130
132
|
optTheme.load(theme);
|
|
@@ -135,24 +137,24 @@ export class Options {
|
|
|
135
137
|
}
|
|
136
138
|
}
|
|
137
139
|
}
|
|
138
|
-
this.defaultThemes.dark = this._findDefaultTheme(
|
|
139
|
-
this.defaultThemes.light = this._findDefaultTheme(
|
|
140
|
+
this.defaultThemes.dark = this._findDefaultTheme(ThemeMode.dark)?.name;
|
|
141
|
+
this.defaultThemes.light = this._findDefaultTheme(ThemeMode.light)?.name;
|
|
140
142
|
}
|
|
141
143
|
setResponsive(width, pxRatio, defaultOptions) {
|
|
142
144
|
this.load(defaultOptions);
|
|
143
|
-
const responsiveOptions = this.responsive.find(
|
|
145
|
+
const responsiveOptions = this.responsive.find(t => t.mode === ResponsiveMode.screen && screen ? t.maxWidth > screen.availWidth : t.maxWidth * pxRatio > width);
|
|
144
146
|
this.load(responsiveOptions?.options);
|
|
145
147
|
return responsiveOptions?.maxWidth;
|
|
146
148
|
}
|
|
147
149
|
setTheme(name) {
|
|
148
150
|
if (name) {
|
|
149
|
-
const chosenTheme = this.themes.find(
|
|
151
|
+
const chosenTheme = this.themes.find(theme => theme.name === name);
|
|
150
152
|
if (chosenTheme) {
|
|
151
153
|
this.load(chosenTheme.options);
|
|
152
154
|
}
|
|
153
155
|
}
|
|
154
156
|
else {
|
|
155
|
-
const mediaMatch = safeMatchMedia("(prefers-color-scheme: dark)"), clientDarkMode = mediaMatch
|
|
157
|
+
const mediaMatch = safeMatchMedia("(prefers-color-scheme: dark)"), clientDarkMode = mediaMatch?.matches, defaultTheme = this._findDefaultTheme(clientDarkMode ? ThemeMode.dark : ThemeMode.light);
|
|
156
158
|
if (defaultTheme) {
|
|
157
159
|
this.load(defaultTheme.options);
|
|
158
160
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CollisionMode } from "../../../../Enums/Modes/CollisionMode.js";
|
|
1
2
|
import { CollisionsAbsorb } from "./CollisionsAbsorb.js";
|
|
2
3
|
import { CollisionsOverlap } from "./CollisionsOverlap.js";
|
|
3
4
|
import { ParticlesBounce } from "../Bounce/ParticlesBounce.js";
|
|
@@ -8,7 +9,7 @@ export class Collisions {
|
|
|
8
9
|
this.bounce = new ParticlesBounce();
|
|
9
10
|
this.enable = false;
|
|
10
11
|
this.maxSpeed = 50;
|
|
11
|
-
this.mode =
|
|
12
|
+
this.mode = CollisionMode.bounce;
|
|
12
13
|
this.overlap = new CollisionsOverlap();
|
|
13
14
|
}
|
|
14
15
|
load(data) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MoveDirection } from "../../../../Enums/Directions/MoveDirection.js";
|
|
1
2
|
import { isNumber, isObject } from "../../../../Utils/TypeUtils.js";
|
|
2
3
|
import { MoveAngle } from "./MoveAngle.js";
|
|
3
4
|
import { MoveAttract } from "./MoveAttract.js";
|
|
@@ -15,7 +16,7 @@ export class Move {
|
|
|
15
16
|
this.center = new MoveCenter();
|
|
16
17
|
this.decay = 0;
|
|
17
18
|
this.distance = {};
|
|
18
|
-
this.direction =
|
|
19
|
+
this.direction = MoveDirection.none;
|
|
19
20
|
this.drift = 0;
|
|
20
21
|
this.enable = false;
|
|
21
22
|
this.gravity = new MoveGravity();
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { DestroyType } from "../../../../Enums/Types/DestroyType.js";
|
|
1
2
|
import { RangedAnimationOptions } from "../../AnimationOptions.js";
|
|
2
3
|
export class OpacityAnimation extends RangedAnimationOptions {
|
|
3
4
|
constructor() {
|
|
4
5
|
super();
|
|
5
|
-
this.destroy =
|
|
6
|
+
this.destroy = DestroyType.none;
|
|
6
7
|
this.speed = 2;
|
|
7
8
|
}
|
|
8
9
|
load(data) {
|
|
@@ -65,7 +65,7 @@ export class ParticlesOptions {
|
|
|
65
65
|
}
|
|
66
66
|
const strokeToLoad = data.stroke;
|
|
67
67
|
if (strokeToLoad) {
|
|
68
|
-
this.stroke = executeOnSingleOrMultiple(strokeToLoad,
|
|
68
|
+
this.stroke = executeOnSingleOrMultiple(strokeToLoad, t => {
|
|
69
69
|
const tmp = new Stroke();
|
|
70
70
|
tmp.load(t);
|
|
71
71
|
return tmp;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { DestroyType } from "../../../../Enums/Types/DestroyType.js";
|
|
1
2
|
import { RangedAnimationOptions } from "../../AnimationOptions.js";
|
|
2
3
|
export class SizeAnimation extends RangedAnimationOptions {
|
|
3
4
|
constructor() {
|
|
4
5
|
super();
|
|
5
|
-
this.destroy =
|
|
6
|
+
this.destroy = DestroyType.none;
|
|
6
7
|
this.speed = 5;
|
|
7
8
|
}
|
|
8
9
|
load(data) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { ResponsiveMode } from "../../Enums/Modes/ResponsiveMode.js";
|
|
1
2
|
import { deepExtend } from "../../Utils/Utils.js";
|
|
2
3
|
export class Responsive {
|
|
3
4
|
constructor() {
|
|
4
5
|
this.maxWidth = Infinity;
|
|
5
6
|
this.options = {};
|
|
6
|
-
this.mode =
|
|
7
|
+
this.mode = ResponsiveMode.canvas;
|
|
7
8
|
}
|
|
8
9
|
load(data) {
|
|
9
10
|
if (!data) {
|
|
@@ -13,11 +14,11 @@ export class Responsive {
|
|
|
13
14
|
this.maxWidth = data.maxWidth;
|
|
14
15
|
}
|
|
15
16
|
if (data.mode !== undefined) {
|
|
16
|
-
if (data.mode ===
|
|
17
|
-
this.mode =
|
|
17
|
+
if (data.mode === ResponsiveMode.screen) {
|
|
18
|
+
this.mode = ResponsiveMode.screen;
|
|
18
19
|
}
|
|
19
20
|
else {
|
|
20
|
-
this.mode =
|
|
21
|
+
this.mode = ResponsiveMode.canvas;
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
if (data.options !== undefined) {
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import { AlterType } from "../Enums/Types/AlterType.js";
|
|
1
2
|
import { getStyleFromRgb } from "./ColorUtils.js";
|
|
2
|
-
const origin = { x: 0, y: 0 }
|
|
3
|
+
const origin = { x: 0, y: 0 }, defaultTransform = {
|
|
4
|
+
a: 1,
|
|
5
|
+
b: 0,
|
|
6
|
+
c: 0,
|
|
7
|
+
d: 1,
|
|
8
|
+
};
|
|
3
9
|
export function drawLine(context, begin, end) {
|
|
4
10
|
context.beginPath();
|
|
5
11
|
context.moveTo(begin.x, begin.y);
|
|
@@ -25,11 +31,11 @@ export function drawParticle(data) {
|
|
|
25
31
|
const { container, context, particle, delta, colorStyles, backgroundMask, composite, radius, opacity, shadow, transform, } = data, pos = particle.getPosition(), defaultAngle = 0, angle = particle.rotation + (particle.pathRotation ? particle.velocity.angle : defaultAngle), rotateData = {
|
|
26
32
|
sin: Math.sin(angle),
|
|
27
33
|
cos: Math.cos(angle),
|
|
28
|
-
},
|
|
29
|
-
a: rotateData.cos * (transform.a ??
|
|
30
|
-
b: rotateData.sin * (transform.b ??
|
|
31
|
-
c: -rotateData.sin * (transform.c ??
|
|
32
|
-
d: rotateData.cos * (transform.d ??
|
|
34
|
+
}, rotating = !!angle, identity = 1, transformData = {
|
|
35
|
+
a: rotateData.cos * (transform.a ?? defaultTransform.a),
|
|
36
|
+
b: rotating ? rotateData.sin * (transform.b ?? identity) : transform.b ?? defaultTransform.b,
|
|
37
|
+
c: rotating ? -rotateData.sin * (transform.c ?? identity) : transform.c ?? defaultTransform.c,
|
|
38
|
+
d: rotateData.cos * (transform.d ?? defaultTransform.d),
|
|
33
39
|
};
|
|
34
40
|
context.setTransform(transformData.a, transformData.b, transformData.c, transformData.d, pos.x, pos.y);
|
|
35
41
|
if (backgroundMask) {
|
|
@@ -150,6 +156,6 @@ export function alterHsl(color, type, value) {
|
|
|
150
156
|
return {
|
|
151
157
|
h: color.h,
|
|
152
158
|
s: color.s,
|
|
153
|
-
l: color.l + (type ===
|
|
159
|
+
l: color.l + (type === AlterType.darken ? -lFactor : lFactor) * value,
|
|
154
160
|
};
|
|
155
161
|
}
|