@tsparticles/engine 4.0.0-beta.0 → 4.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/67.min.js +1 -0
- package/README.md +53 -965
- package/browser/Core/CanvasManager.js +303 -0
- package/browser/Core/Container.js +61 -34
- package/browser/Core/Engine.js +26 -138
- package/browser/Core/Particle.js +29 -28
- package/{cjs/Core/Particles.js → browser/Core/ParticlesManager.js} +27 -57
- package/browser/Core/RenderManager.js +303 -0
- package/browser/Core/Retina.js +3 -8
- package/browser/Core/Utils/PluginManager.js +145 -0
- package/browser/Options/Classes/Options.js +8 -21
- package/browser/Options/Classes/Particles/Paint.js +20 -0
- package/browser/Options/Classes/Particles/ParticlesOptions.js +65 -27
- package/browser/Options/Interfaces/Particles/IPaint.js +1 -0
- package/browser/Types/CanvasContextType.js +1 -0
- package/browser/Utils/CanvasUtils.js +4 -4
- package/browser/Utils/ColorUtils.js +21 -21
- package/browser/Utils/LogUtils.js +1 -0
- package/browser/Utils/OptionsUtils.js +2 -2
- package/browser/Utils/Utils.js +16 -10
- package/browser/exports.js +1 -0
- package/cjs/Core/CanvasManager.js +303 -0
- package/cjs/Core/Container.js +61 -34
- package/cjs/Core/Engine.js +26 -138
- package/cjs/Core/Particle.js +29 -28
- package/{esm/Core/Particles.js → cjs/Core/ParticlesManager.js} +27 -57
- package/cjs/Core/RenderManager.js +303 -0
- package/cjs/Core/Retina.js +3 -8
- package/cjs/Core/Utils/PluginManager.js +145 -0
- package/cjs/Options/Classes/Options.js +8 -21
- package/cjs/Options/Classes/Particles/Paint.js +20 -0
- package/cjs/Options/Classes/Particles/ParticlesOptions.js +65 -27
- package/cjs/Options/Interfaces/Particles/IPaint.js +1 -0
- package/cjs/Types/CanvasContextType.js +1 -0
- package/cjs/Utils/CanvasUtils.js +4 -4
- package/cjs/Utils/ColorUtils.js +21 -21
- package/cjs/Utils/LogUtils.js +1 -0
- package/cjs/Utils/OptionsUtils.js +2 -2
- package/cjs/Utils/Utils.js +16 -10
- package/cjs/exports.js +1 -0
- package/dist_browser_Core_Container_js.js +24 -14
- package/esm/Core/CanvasManager.js +303 -0
- package/esm/Core/Container.js +61 -34
- package/esm/Core/Engine.js +26 -138
- package/esm/Core/Particle.js +29 -28
- package/{browser/Core/Particles.js → esm/Core/ParticlesManager.js} +27 -57
- package/esm/Core/RenderManager.js +303 -0
- package/esm/Core/Retina.js +3 -8
- package/esm/Core/Utils/PluginManager.js +145 -0
- package/esm/Options/Classes/Options.js +8 -21
- package/esm/Options/Classes/Particles/Paint.js +20 -0
- package/esm/Options/Classes/Particles/ParticlesOptions.js +65 -27
- package/esm/Options/Interfaces/Particles/IPaint.js +1 -0
- package/esm/Types/CanvasContextType.js +1 -0
- package/esm/Utils/CanvasUtils.js +4 -4
- package/esm/Utils/ColorUtils.js +21 -21
- package/esm/Utils/LogUtils.js +1 -0
- package/esm/Utils/OptionsUtils.js +2 -2
- package/esm/Utils/Utils.js +16 -10
- package/esm/exports.js +1 -0
- package/package.json +2 -3
- package/report.html +84 -29
- package/tsparticles.engine.js +31 -11
- package/tsparticles.engine.min.js +2 -2
- package/types/Core/CanvasManager.d.ts +39 -0
- package/types/Core/Container.d.ts +26 -7
- package/types/Core/Engine.d.ts +2 -54
- package/types/Core/Interfaces/IContainerPlugin.d.ts +8 -7
- package/types/Core/Interfaces/IDrawParticleParams.d.ts +2 -1
- package/types/Core/Interfaces/IPalette.d.ts +15 -2
- package/types/Core/Interfaces/IParticleRetinaProps.d.ts +4 -4
- package/types/Core/Interfaces/IParticleUpdater.d.ts +2 -1
- package/types/Core/Interfaces/IShapeDrawData.d.ts +2 -1
- package/types/Core/Particle.d.ts +4 -4
- package/types/Core/{Particles.d.ts → ParticlesManager.d.ts} +4 -11
- package/types/Core/{Canvas.d.ts → RenderManager.d.ts} +12 -33
- package/types/Core/Retina.d.ts +0 -2
- package/types/Core/Utils/PluginManager.d.ts +62 -0
- package/types/Options/Classes/Options.d.ts +3 -3
- package/types/Options/Classes/Particles/Paint.d.ts +10 -0
- package/types/Options/Classes/Particles/ParticlesOptions.d.ts +7 -7
- package/types/Options/Interfaces/Particles/IPaint.d.ts +6 -0
- package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +3 -4
- package/types/Types/CanvasContextType.d.ts +1 -0
- package/types/Utils/CanvasUtils.d.ts +8 -5
- package/types/Utils/ColorUtils.d.ts +8 -8
- package/types/Utils/LogUtils.d.ts +1 -0
- package/types/Utils/OptionsUtils.d.ts +2 -2
- package/types/export-types.d.ts +5 -2
- package/types/exports.d.ts +1 -0
- package/164.min.js +0 -1
- package/browser/Core/Canvas.js +0 -570
- package/cjs/Core/Canvas.js +0 -570
- package/esm/Core/Canvas.js +0 -570
- package/umd/Core/Canvas.js +0 -584
- package/umd/Core/Container.js +0 -356
- package/umd/Core/Engine.js +0 -295
- package/umd/Core/Interfaces/Colors.js +0 -12
- package/umd/Core/Interfaces/IBounds.js +0 -12
- package/umd/Core/Interfaces/IBubbleParticleData.js +0 -12
- package/umd/Core/Interfaces/ICircleBouncer.js +0 -12
- package/umd/Core/Interfaces/IColorManager.js +0 -12
- package/umd/Core/Interfaces/IContainerPlugin.js +0 -12
- package/umd/Core/Interfaces/ICoordinates.js +0 -12
- package/umd/Core/Interfaces/IDelta.js +0 -12
- package/umd/Core/Interfaces/IDimension.js +0 -12
- package/umd/Core/Interfaces/IDistance.js +0 -12
- package/umd/Core/Interfaces/IDrawParticleParams.js +0 -12
- package/umd/Core/Interfaces/IEffectDrawer.js +0 -12
- package/umd/Core/Interfaces/ILoadParams.js +0 -12
- package/umd/Core/Interfaces/IPalette.js +0 -12
- package/umd/Core/Interfaces/IParticleColorStyle.js +0 -12
- package/umd/Core/Interfaces/IParticleHslAnimation.js +0 -12
- package/umd/Core/Interfaces/IParticleLife.js +0 -12
- package/umd/Core/Interfaces/IParticleOpacityData.js +0 -12
- package/umd/Core/Interfaces/IParticleRetinaProps.js +0 -12
- package/umd/Core/Interfaces/IParticleRoll.js +0 -12
- package/umd/Core/Interfaces/IParticleRotateData.js +0 -12
- package/umd/Core/Interfaces/IParticleTransformValues.js +0 -12
- package/umd/Core/Interfaces/IParticleUpdater.js +0 -12
- package/umd/Core/Interfaces/IParticleValueAnimation.js +0 -12
- package/umd/Core/Interfaces/IPlugin.js +0 -12
- package/umd/Core/Interfaces/IPositionFromSizeParams.js +0 -12
- package/umd/Core/Interfaces/IRangeValue.js +0 -12
- package/umd/Core/Interfaces/IShapeDrawData.js +0 -12
- package/umd/Core/Interfaces/IShapeDrawer.js +0 -12
- package/umd/Core/Interfaces/IShapeValues.js +0 -12
- package/umd/Core/Interfaces/ISlowParticleData.js +0 -12
- package/umd/Core/Particle.js +0 -432
- package/umd/Core/Particles.js +0 -407
- package/umd/Core/Retina.js +0 -52
- package/umd/Core/Utils/Constants.js +0 -23
- package/umd/Core/Utils/EventListeners.js +0 -102
- package/umd/Core/Utils/Ranges.js +0 -91
- package/umd/Core/Utils/SpatialHashGrid.js +0 -116
- package/umd/Core/Utils/Vectors.js +0 -126
- package/umd/Enums/AnimationStatus.js +0 -18
- package/umd/Enums/Directions/MoveDirection.js +0 -27
- package/umd/Enums/Directions/OutModeDirection.js +0 -20
- package/umd/Enums/Directions/RotateDirection.js +0 -19
- package/umd/Enums/Modes/AnimationMode.js +0 -20
- package/umd/Enums/Modes/LimitMode.js +0 -18
- package/umd/Enums/Modes/OutMode.js +0 -21
- package/umd/Enums/Modes/PixelMode.js +0 -18
- package/umd/Enums/RangeType.js +0 -18
- package/umd/Enums/Types/AlterType.js +0 -18
- package/umd/Enums/Types/DestroyType.js +0 -19
- package/umd/Enums/Types/EasingType.js +0 -58
- package/umd/Enums/Types/EventType.js +0 -28
- package/umd/Enums/Types/GradientType.js +0 -19
- package/umd/Enums/Types/ParticleOutType.js +0 -19
- package/umd/Enums/Types/StartValueType.js +0 -19
- package/umd/Options/Classes/AnimatableColor.js +0 -52
- package/umd/Options/Classes/AnimationOptions.js +0 -79
- package/umd/Options/Classes/Background/Background.js +0 -56
- package/umd/Options/Classes/ColorAnimation.js +0 -44
- package/umd/Options/Classes/FullScreen/FullScreen.js +0 -34
- package/umd/Options/Classes/HslAnimation.js +0 -30
- package/umd/Options/Classes/Options.js +0 -171
- package/umd/Options/Classes/OptionsColor.js +0 -42
- package/umd/Options/Classes/Particles/Bounce/ParticlesBounce.js +0 -31
- package/umd/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +0 -21
- package/umd/Options/Classes/Particles/Effect/Effect.js +0 -46
- package/umd/Options/Classes/Particles/Fill.js +0 -42
- package/umd/Options/Classes/Particles/Move/Move.js +0 -120
- package/umd/Options/Classes/Particles/Move/MoveAngle.js +0 -35
- package/umd/Options/Classes/Particles/Move/MoveCenter.js +0 -45
- package/umd/Options/Classes/Particles/Move/MoveGravity.js +0 -45
- package/umd/Options/Classes/Particles/Move/OutModes.js +0 -38
- package/umd/Options/Classes/Particles/Move/Path/MovePath.js +0 -46
- package/umd/Options/Classes/Particles/Move/Spin.js +0 -40
- package/umd/Options/Classes/Particles/Number/ParticlesDensity.js +0 -41
- package/umd/Options/Classes/Particles/Number/ParticlesNumber.js +0 -37
- package/umd/Options/Classes/Particles/Number/ParticlesNumberLimit.js +0 -35
- package/umd/Options/Classes/Particles/Opacity/Opacity.js +0 -35
- package/umd/Options/Classes/Particles/Opacity/OpacityAnimation.js +0 -34
- package/umd/Options/Classes/Particles/ParticlesOptions.js +0 -116
- package/umd/Options/Classes/Particles/Shape/Shape.js +0 -46
- package/umd/Options/Classes/Particles/Size/Size.js +0 -35
- package/umd/Options/Classes/Particles/Size/SizeAnimation.js +0 -34
- package/umd/Options/Classes/Particles/Stroke.js +0 -39
- package/umd/Options/Classes/Particles/ZIndex/ZIndex.js +0 -42
- package/umd/Options/Classes/ResizeEvent.js +0 -34
- package/umd/Options/Classes/ValueWithRandom.js +0 -56
- package/umd/Options/Interfaces/Background/IBackground.js +0 -12
- package/umd/Options/Interfaces/FullScreen/IFullScreen.js +0 -12
- package/umd/Options/Interfaces/IAnimatable.js +0 -12
- package/umd/Options/Interfaces/IAnimatableColor.js +0 -12
- package/umd/Options/Interfaces/IAnimation.js +0 -12
- package/umd/Options/Interfaces/IColorAnimation.js +0 -12
- package/umd/Options/Interfaces/IHslAnimation.js +0 -12
- package/umd/Options/Interfaces/IOptionLoader.js +0 -12
- package/umd/Options/Interfaces/IOptions.js +0 -12
- package/umd/Options/Interfaces/IOptionsColor.js +0 -12
- package/umd/Options/Interfaces/IResizeEvent.js +0 -12
- package/umd/Options/Interfaces/IValueWithRandom.js +0 -12
- package/umd/Options/Interfaces/Particles/Bounce/IParticlesBounce.js +0 -12
- package/umd/Options/Interfaces/Particles/Effect/IEffect.js +0 -12
- package/umd/Options/Interfaces/Particles/IFill.js +0 -12
- package/umd/Options/Interfaces/Particles/IParticlesOptions.js +0 -12
- package/umd/Options/Interfaces/Particles/IStroke.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMove.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMoveAngle.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMoveCenter.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMoveGravity.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IOutModes.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/ISpin.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/Path/IMovePath.js +0 -12
- package/umd/Options/Interfaces/Particles/Number/IParticlesDensity.js +0 -12
- package/umd/Options/Interfaces/Particles/Number/IParticlesNumber.js +0 -12
- package/umd/Options/Interfaces/Particles/Number/IParticlesNumberLimit.js +0 -12
- package/umd/Options/Interfaces/Particles/Opacity/IOpacity.js +0 -12
- package/umd/Options/Interfaces/Particles/Opacity/IOpacityAnimation.js +0 -12
- package/umd/Options/Interfaces/Particles/Shape/IShape.js +0 -12
- package/umd/Options/Interfaces/Particles/Size/ISize.js +0 -12
- package/umd/Options/Interfaces/Particles/Size/ISizeAnimation.js +0 -12
- package/umd/Options/Interfaces/Particles/ZIndex/IZIndex.js +0 -12
- package/umd/Types/CustomEventArgs.js +0 -12
- package/umd/Types/CustomEventListener.js +0 -12
- package/umd/Types/EasingFunction.js +0 -12
- package/umd/Types/EngineInitializers.js +0 -12
- package/umd/Types/ExportResult.js +0 -12
- package/umd/Types/ISourceOptions.js +0 -12
- package/umd/Types/ParticlesGroups.js +0 -12
- package/umd/Types/PathOptions.js +0 -12
- package/umd/Types/RangeValue.js +0 -12
- package/umd/Types/RecursivePartial.js +0 -12
- package/umd/Types/ShapeData.js +0 -12
- package/umd/Types/SingleOrMultiple.js +0 -12
- package/umd/Utils/CanvasUtils.js +0 -145
- package/umd/Utils/ColorUtils.js +0 -395
- package/umd/Utils/EventDispatcher.js +0 -63
- package/umd/Utils/LogUtils.js +0 -36
- package/umd/Utils/MathUtils.js +0 -203
- package/umd/Utils/OptionsUtils.js +0 -25
- package/umd/Utils/TypeUtils.js +0 -40
- package/umd/Utils/Utils.js +0 -484
- package/umd/bundle.js +0 -32
- package/umd/export-types.js +0 -12
- package/umd/exports.js +0 -82
- package/umd/index.js +0 -32
- package/umd/initEngine.js +0 -17
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
import type { Container } from "./Container.js";
|
|
2
|
-
import type { Engine } from "./Engine.js";
|
|
3
2
|
import type { IContainerPlugin } from "./Interfaces/IContainerPlugin.js";
|
|
4
3
|
import type { ICoordinates } from "./Interfaces/ICoordinates.js";
|
|
5
4
|
import type { IDelta } from "./Interfaces/IDelta.js";
|
|
6
5
|
import type { IDimension } from "./Interfaces/IDimension.js";
|
|
7
|
-
import type { IEffectDrawer } from "./Interfaces/IEffectDrawer.js";
|
|
8
|
-
import type { IParticleUpdater } from "./Interfaces/IParticleUpdater.js";
|
|
9
6
|
import type { IParticlesOptions } from "../Options/Interfaces/Particles/IParticlesOptions.js";
|
|
10
|
-
import type { IShapeDrawer } from "./Interfaces/IShapeDrawer.js";
|
|
11
7
|
import { Particle } from "./Particle.js";
|
|
8
|
+
import type { PluginManager } from "./Utils/PluginManager.js";
|
|
12
9
|
import type { RecursivePartial } from "../Types/RecursivePartial.js";
|
|
13
10
|
import { SpatialHashGrid } from "./Utils/SpatialHashGrid.js";
|
|
14
|
-
export declare class
|
|
11
|
+
export declare class ParticlesManager {
|
|
15
12
|
checkParticlePositionPlugins: IContainerPlugin[];
|
|
16
|
-
effectDrawers: Map<string, IEffectDrawer>;
|
|
17
13
|
grid: SpatialHashGrid;
|
|
18
|
-
shapeDrawers: Map<string, IShapeDrawer>;
|
|
19
|
-
updaters: IParticleUpdater[];
|
|
20
14
|
private _array;
|
|
21
15
|
private readonly _container;
|
|
22
|
-
private readonly _engine;
|
|
23
16
|
private readonly _groupLimits;
|
|
24
17
|
private _limit;
|
|
25
18
|
private _maxZIndex;
|
|
@@ -28,13 +21,14 @@ export declare class Particles {
|
|
|
28
21
|
private _nextId;
|
|
29
22
|
private _particleResetPlugins;
|
|
30
23
|
private _particleUpdatePlugins;
|
|
24
|
+
private readonly _pluginManager;
|
|
31
25
|
private readonly _pool;
|
|
32
26
|
private _postParticleUpdatePlugins;
|
|
33
27
|
private _postUpdatePlugins;
|
|
34
28
|
private _resizeFactor?;
|
|
35
29
|
private _updatePlugins;
|
|
36
30
|
private _zArray;
|
|
37
|
-
constructor(
|
|
31
|
+
constructor(pluginManager: PluginManager, container: Container);
|
|
38
32
|
get count(): number;
|
|
39
33
|
addParticle(position?: ICoordinates, overrideOptions?: RecursivePartial<IParticlesOptions>, group?: string, initializer?: (particle: Particle) => boolean): Particle | undefined;
|
|
40
34
|
clear(): void;
|
|
@@ -44,7 +38,6 @@ export declare class Particles {
|
|
|
44
38
|
find(condition: (particle: Particle) => boolean): Particle | undefined;
|
|
45
39
|
get(index: number): Particle | undefined;
|
|
46
40
|
init(): Promise<void>;
|
|
47
|
-
initPlugins(): Promise<void>;
|
|
48
41
|
push(nb: number, position?: ICoordinates, overrideOptions?: RecursivePartial<IParticlesOptions>, group?: string): void;
|
|
49
42
|
redraw(): Promise<void>;
|
|
50
43
|
remove(particle: Particle, group?: string, override?: boolean): void;
|
|
@@ -1,70 +1,49 @@
|
|
|
1
|
+
import type { CanvasContextType } from "../Types/CanvasContextType.js";
|
|
2
|
+
import type { CanvasManager } from "./CanvasManager.js";
|
|
1
3
|
import type { Container } from "./Container.js";
|
|
2
|
-
import type { Engine } from "./Engine.js";
|
|
3
|
-
import type { ICoordinates } from "./Interfaces/ICoordinates.js";
|
|
4
4
|
import type { IDelta } from "./Interfaces/IDelta.js";
|
|
5
|
-
import type { IDimension } from "./Interfaces/IDimension.js";
|
|
6
5
|
import type { Particle } from "./Particle.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
element?: HTMLCanvasElement;
|
|
10
|
-
readonly size: IDimension;
|
|
11
|
-
zoom: number;
|
|
6
|
+
import type { PluginManager } from "./Utils/PluginManager.js";
|
|
7
|
+
export declare class RenderManager {
|
|
12
8
|
private _canvasClearPlugins;
|
|
9
|
+
private readonly _canvasManager;
|
|
13
10
|
private _canvasPaintPlugins;
|
|
14
|
-
private _canvasSettings?;
|
|
15
11
|
private _clearDrawPlugins;
|
|
16
12
|
private _colorPlugins;
|
|
13
|
+
private readonly _container;
|
|
17
14
|
private _context;
|
|
15
|
+
private _contextSettings?;
|
|
18
16
|
private _drawParticlePlugins;
|
|
19
17
|
private _drawParticlesCleanupPlugins;
|
|
20
18
|
private _drawParticlesSetupPlugins;
|
|
21
19
|
private _drawPlugins;
|
|
22
20
|
private _drawSettingsCleanupPlugins;
|
|
23
21
|
private _drawSettingsSetupPlugins;
|
|
24
|
-
private readonly
|
|
25
|
-
private _generated;
|
|
26
|
-
private _mutationObserver?;
|
|
27
|
-
private _originalStyle?;
|
|
28
|
-
private _pointerEvents;
|
|
22
|
+
private readonly _pluginManager;
|
|
29
23
|
private _postDrawUpdaters;
|
|
30
24
|
private _preDrawUpdaters;
|
|
31
|
-
private _resizePlugins;
|
|
32
25
|
private readonly _reusableColorStyles;
|
|
33
26
|
private readonly _reusablePluginColors;
|
|
34
27
|
private readonly _reusableTransform;
|
|
35
|
-
|
|
36
|
-
private _zoomCenter?;
|
|
37
|
-
constructor(container: Container, engine: Engine);
|
|
28
|
+
constructor(pluginManager: PluginManager, container: Container, canvasManager: CanvasManager);
|
|
38
29
|
get settings(): CanvasRenderingContext2DSettings | undefined;
|
|
39
|
-
private get _fullScreen();
|
|
40
30
|
canvasClear(): void;
|
|
41
31
|
clear(): void;
|
|
42
32
|
destroy(): void;
|
|
43
|
-
draw<T>(cb: (context:
|
|
33
|
+
draw<T>(cb: (context: CanvasContextType) => T): T | undefined;
|
|
44
34
|
drawParticle(particle: Particle, delta: IDelta): void;
|
|
45
35
|
drawParticlePlugins(particle: Particle, delta: IDelta): void;
|
|
46
36
|
drawParticles(delta: IDelta): void;
|
|
47
|
-
getZoomCenter(): ICoordinates;
|
|
48
37
|
init(): void;
|
|
49
|
-
initBackground(): void;
|
|
50
38
|
initPlugins(): void;
|
|
51
39
|
initUpdaters(): void;
|
|
52
|
-
loadCanvas(canvas: HTMLCanvasElement): void;
|
|
53
40
|
paint(): void;
|
|
54
41
|
paintBase(baseColor?: string): void;
|
|
55
42
|
paintImage(image: HTMLImageElement, opacity: number): void;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
setZoom(zoomLevel: number, center?: ICoordinates): void;
|
|
43
|
+
setContext(context: CanvasContextType | null): void;
|
|
44
|
+
setContextSettings(settings: CanvasRenderingContext2DSettings): void;
|
|
59
45
|
stop(): void;
|
|
60
|
-
windowResize(): Promise<void>;
|
|
61
46
|
private readonly _applyPostDrawUpdaters;
|
|
62
47
|
private readonly _applyPreDrawUpdaters;
|
|
63
|
-
private readonly _applyResizePlugins;
|
|
64
48
|
private readonly _getPluginParticleColors;
|
|
65
|
-
private readonly _initStyle;
|
|
66
|
-
private readonly _repairStyle;
|
|
67
|
-
private readonly _resetOriginalStyle;
|
|
68
|
-
private readonly _safeMutationObserver;
|
|
69
|
-
private readonly _setFullScreenStyle;
|
|
70
49
|
}
|
package/types/Core/Retina.d.ts
CHANGED
|
@@ -2,10 +2,8 @@ import type { Container } from "./Container.js";
|
|
|
2
2
|
import type { Particle } from "./Particle.js";
|
|
3
3
|
export declare class Retina {
|
|
4
4
|
private readonly container;
|
|
5
|
-
maxSpeed: number;
|
|
6
5
|
pixelRatio: number;
|
|
7
6
|
reduceFactor: number;
|
|
8
|
-
sizeAnimationSpeed: number;
|
|
9
7
|
constructor(container: Container);
|
|
10
8
|
init(): void;
|
|
11
9
|
initParticle(particle: Particle): void;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { EasingType, EasingTypeAlt } from "../../Enums/Types/EasingType.js";
|
|
2
|
+
import type { EffectInitializer, Initializers, ShapeInitializer, UpdaterInitializer } from "../../Types/EngineInitializers.js";
|
|
3
|
+
import type { Container } from "../Container.js";
|
|
4
|
+
import type { EasingFunction } from "../../Types/EasingFunction.js";
|
|
5
|
+
import type { Engine } from "../Engine.js";
|
|
6
|
+
import type { IColorManager } from "../Interfaces/IColorManager.js";
|
|
7
|
+
import type { IEffectDrawer } from "../Interfaces/IEffectDrawer.js";
|
|
8
|
+
import type { IPalette } from "../Interfaces/IPalette.js";
|
|
9
|
+
import type { IParticleUpdater } from "../Interfaces/IParticleUpdater.js";
|
|
10
|
+
import type { IParticlesOptions } from "../../Options/Interfaces/Particles/IParticlesOptions.js";
|
|
11
|
+
import type { IPlugin } from "../Interfaces/IPlugin.js";
|
|
12
|
+
import type { IShapeDrawer } from "../Interfaces/IShapeDrawer.js";
|
|
13
|
+
import type { ISourceOptions } from "../../Types/ISourceOptions.js";
|
|
14
|
+
import type { ParticlesOptions } from "../../Options/Classes/Particles/ParticlesOptions.js";
|
|
15
|
+
import type { RecursivePartial } from "../../Types/RecursivePartial.js";
|
|
16
|
+
type AsyncLoadPluginFunction = (engine: Engine) => Promise<void>;
|
|
17
|
+
type SyncLoadPluginFunction = (engine: Engine) => void;
|
|
18
|
+
type AsyncLoadPluginNoEngine = () => Promise<void>;
|
|
19
|
+
type SyncLoadPluginNoEngine = () => void;
|
|
20
|
+
type LoadPluginFunction = AsyncLoadPluginFunction | SyncLoadPluginFunction | AsyncLoadPluginNoEngine | SyncLoadPluginNoEngine;
|
|
21
|
+
export declare class PluginManager {
|
|
22
|
+
readonly colorManagers: Map<string, IColorManager>;
|
|
23
|
+
readonly easingFunctions: Map<EasingTypeAlt | EasingType, EasingFunction>;
|
|
24
|
+
readonly effectDrawers: Map<Container, Map<string, IEffectDrawer<import("../Particle.js").Particle>>>;
|
|
25
|
+
readonly initializers: Initializers;
|
|
26
|
+
readonly palettes: Map<string, IPalette>;
|
|
27
|
+
readonly plugins: IPlugin[];
|
|
28
|
+
readonly presets: Map<string, RecursivePartial<import("../../export-types.js").IOptions>>;
|
|
29
|
+
readonly shapeDrawers: Map<Container, Map<string, IShapeDrawer<import("../Particle.js").Particle>>>;
|
|
30
|
+
readonly updaters: Map<Container, IParticleUpdater[]>;
|
|
31
|
+
private _allLoadersSet;
|
|
32
|
+
private readonly _configs;
|
|
33
|
+
private readonly _engine;
|
|
34
|
+
private _executedSet;
|
|
35
|
+
private _initialized;
|
|
36
|
+
private _isRunningLoaders;
|
|
37
|
+
private readonly _loadPromises;
|
|
38
|
+
constructor(engine: Engine);
|
|
39
|
+
get configs(): Record<string, ISourceOptions>;
|
|
40
|
+
addColorManager(name: string, manager: IColorManager): void;
|
|
41
|
+
addConfig(config: ISourceOptions): void;
|
|
42
|
+
addEasing(name: EasingType | EasingTypeAlt, easing: EasingFunction): void;
|
|
43
|
+
addEffect(effect: string, drawer: EffectInitializer): void;
|
|
44
|
+
addPalette(name: string, palette: IPalette): void;
|
|
45
|
+
addParticleUpdater(name: string, updaterInitializer: UpdaterInitializer): void;
|
|
46
|
+
addPlugin(plugin: IPlugin): void;
|
|
47
|
+
addPreset(preset: string, options: Readonly<ISourceOptions>, override?: boolean): void;
|
|
48
|
+
addShape(shapes: string[], drawer: ShapeInitializer): void;
|
|
49
|
+
clearPlugins(container: Container): void;
|
|
50
|
+
getEasing(name: EasingType | EasingTypeAlt): EasingFunction;
|
|
51
|
+
getEffectDrawers(container: Container, force?: boolean): Promise<Map<string, IEffectDrawer>>;
|
|
52
|
+
getPalette(name: string): IPalette | undefined;
|
|
53
|
+
getPlugin(plugin: string): IPlugin | undefined;
|
|
54
|
+
getPreset(preset: string): ISourceOptions | undefined;
|
|
55
|
+
getShapeDrawers(container: Container, force?: boolean): Promise<Map<string, IShapeDrawer>>;
|
|
56
|
+
getUpdaters(container: Container, force?: boolean): Promise<IParticleUpdater[]>;
|
|
57
|
+
init(): Promise<void>;
|
|
58
|
+
loadParticlesOptions(container: Container, options: ParticlesOptions, ...sourceOptions: (RecursivePartial<IParticlesOptions> | undefined)[]): void;
|
|
59
|
+
register(...loaders: LoadPluginFunction[]): Promise<void>;
|
|
60
|
+
private _runLoader;
|
|
61
|
+
}
|
|
62
|
+
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Background } from "./Background/Background.js";
|
|
2
2
|
import type { Container } from "../../Core/Container.js";
|
|
3
|
-
import type { Engine } from "../../Core/Engine.js";
|
|
4
3
|
import { FullScreen } from "./FullScreen/FullScreen.js";
|
|
5
4
|
import type { IOptionLoader } from "../Interfaces/IOptionLoader.js";
|
|
6
5
|
import type { IOptions } from "../Interfaces/IOptions.js";
|
|
7
6
|
import type { ISourceOptions } from "../../Types/ISourceOptions.js";
|
|
7
|
+
import type { PluginManager } from "../../Core/Utils/PluginManager.js";
|
|
8
8
|
import type { RangeValue } from "../../Types/RangeValue.js";
|
|
9
9
|
import type { RecursivePartial } from "../../Types/RecursivePartial.js";
|
|
10
10
|
import { ResizeEvent } from "./ResizeEvent.js";
|
|
@@ -37,8 +37,8 @@ export declare class Options implements IOptions, IOptionLoader<IOptions> {
|
|
|
37
37
|
style: RecursivePartial<CSSStyleDeclaration>;
|
|
38
38
|
zLayers: number;
|
|
39
39
|
private readonly _container;
|
|
40
|
-
private readonly
|
|
41
|
-
constructor(
|
|
40
|
+
private readonly _pluginManager;
|
|
41
|
+
constructor(pluginManager: PluginManager, container: Container);
|
|
42
42
|
load(data?: ISourceOptions): void;
|
|
43
43
|
private readonly _importPalette;
|
|
44
44
|
private readonly _importPreset;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Fill } from "./Fill.js";
|
|
2
|
+
import type { IOptionLoader } from "../../Interfaces/IOptionLoader.js";
|
|
3
|
+
import type { IPaint } from "../../Interfaces/Particles/IPaint.js";
|
|
4
|
+
import type { RecursivePartial } from "../../../Types/RecursivePartial.js";
|
|
5
|
+
import { Stroke } from "./Stroke.js";
|
|
6
|
+
export declare class Paint implements IPaint, IOptionLoader<IPaint> {
|
|
7
|
+
fill?: Fill;
|
|
8
|
+
stroke?: Stroke;
|
|
9
|
+
load(data?: RecursivePartial<IPaint>): void;
|
|
10
|
+
}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import type { Container } from "../../../Core/Container.js";
|
|
2
2
|
import { Effect } from "./Effect/Effect.js";
|
|
3
|
-
import type { Engine } from "../../../Core/Engine.js";
|
|
4
|
-
import { Fill } from "./Fill.js";
|
|
5
3
|
import type { IOptionLoader } from "../../Interfaces/IOptionLoader.js";
|
|
6
4
|
import type { IParticlesOptions } from "../../Interfaces/Particles/IParticlesOptions.js";
|
|
7
5
|
import { Move } from "./Move/Move.js";
|
|
8
6
|
import { Opacity } from "./Opacity/Opacity.js";
|
|
7
|
+
import { Paint } from "./Paint.js";
|
|
9
8
|
import { ParticlesBounce } from "./Bounce/ParticlesBounce.js";
|
|
10
9
|
import type { ParticlesGroups } from "../../../Types/ParticlesGroups.js";
|
|
11
10
|
import { ParticlesNumber } from "./Number/ParticlesNumber.js";
|
|
11
|
+
import type { PluginManager } from "../../../Core/Utils/PluginManager.js";
|
|
12
12
|
import type { RecursivePartial } from "../../../Types/RecursivePartial.js";
|
|
13
13
|
import { Shape } from "./Shape/Shape.js";
|
|
14
14
|
import type { SingleOrMultiple } from "../../../Types/SingleOrMultiple.js";
|
|
15
15
|
import { Size } from "./Size/Size.js";
|
|
16
|
-
import { Stroke } from "./Stroke.js";
|
|
17
16
|
import { ZIndex } from "./ZIndex/ZIndex.js";
|
|
18
17
|
export declare class ParticlesOptions implements IParticlesOptions, IOptionLoader<IParticlesOptions> {
|
|
19
18
|
[name: string]: unknown;
|
|
20
19
|
readonly bounce: ParticlesBounce;
|
|
21
20
|
readonly effect: Effect;
|
|
22
|
-
fill: SingleOrMultiple<Fill>;
|
|
23
21
|
readonly groups: ParticlesGroups;
|
|
24
22
|
readonly move: Move;
|
|
25
23
|
readonly number: ParticlesNumber;
|
|
26
24
|
readonly opacity: Opacity;
|
|
25
|
+
paint: SingleOrMultiple<Paint>;
|
|
26
|
+
palette?: string;
|
|
27
27
|
reduceDuplicates: boolean;
|
|
28
28
|
readonly shape: Shape;
|
|
29
29
|
readonly size: Size;
|
|
30
|
-
stroke: SingleOrMultiple<Stroke>;
|
|
31
30
|
readonly zIndex: ZIndex;
|
|
32
31
|
private readonly _container;
|
|
33
|
-
private readonly
|
|
34
|
-
constructor(
|
|
32
|
+
private readonly _pluginManager;
|
|
33
|
+
constructor(pluginManager: PluginManager, container?: Container);
|
|
35
34
|
load(data?: RecursivePartial<IParticlesOptions>): void;
|
|
35
|
+
private readonly _importPalette;
|
|
36
36
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { IEffect } from "./Effect/IEffect.js";
|
|
2
|
-
import type { IFill } from "./IFill.js";
|
|
3
2
|
import type { IMove } from "./Move/IMove.js";
|
|
4
3
|
import type { IOpacity } from "./Opacity/IOpacity.js";
|
|
4
|
+
import type { IPaint } from "./IPaint.js";
|
|
5
5
|
import type { IParticlesBounce } from "./Bounce/IParticlesBounce.js";
|
|
6
6
|
import type { IParticlesNumber } from "./Number/IParticlesNumber.js";
|
|
7
7
|
import type { IShape } from "./Shape/IShape.js";
|
|
8
8
|
import type { ISize } from "./Size/ISize.js";
|
|
9
|
-
import type { IStroke } from "./IStroke.js";
|
|
10
9
|
import type { IZIndex } from "./ZIndex/IZIndex.js";
|
|
11
10
|
import type { ParticlesGroups } from "../../../Types/ParticlesGroups.js";
|
|
12
11
|
import type { SingleOrMultiple } from "../../../Types/SingleOrMultiple.js";
|
|
@@ -14,14 +13,14 @@ export interface IParticlesOptions {
|
|
|
14
13
|
[name: string]: unknown;
|
|
15
14
|
bounce: IParticlesBounce;
|
|
16
15
|
effect: IEffect;
|
|
17
|
-
fill: SingleOrMultiple<IFill>;
|
|
18
16
|
groups: ParticlesGroups;
|
|
19
17
|
move: IMove;
|
|
20
18
|
number: IParticlesNumber;
|
|
21
19
|
opacity: IOpacity;
|
|
20
|
+
paint: SingleOrMultiple<IPaint>;
|
|
21
|
+
palette?: string;
|
|
22
22
|
reduceDuplicates: boolean;
|
|
23
23
|
shape: IShape;
|
|
24
24
|
size: ISize;
|
|
25
|
-
stroke: SingleOrMultiple<IStroke>;
|
|
26
25
|
zIndex: IZIndex;
|
|
27
26
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type CanvasContextType = CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CanvasContextType } from "../Types/CanvasContextType.js";
|
|
2
2
|
import type { IContainerPlugin } from "../Core/Interfaces/IContainerPlugin.js";
|
|
3
3
|
import type { IDelta } from "../Core/Interfaces/IDelta.js";
|
|
4
4
|
import type { IDimension } from "../Core/Interfaces/IDimension.js";
|
|
5
5
|
import type { IDrawParticleParams } from "../Core/Interfaces/IDrawParticleParams.js";
|
|
6
|
+
import type { IEffectDrawer } from "../Core/Interfaces/IEffectDrawer.js";
|
|
7
|
+
import type { IShapeDrawData } from "../Core/Interfaces/IShapeDrawData.js";
|
|
8
|
+
import type { IShapeDrawer } from "../Core/Interfaces/IShapeDrawer.js";
|
|
6
9
|
import type { Particle } from "../Core/Particle.js";
|
|
7
|
-
export declare function paintBase(context:
|
|
8
|
-
export declare function paintImage(context:
|
|
9
|
-
export declare function clear(context:
|
|
10
|
+
export declare function paintBase(context: CanvasContextType, dimension: IDimension, baseColor?: string): void;
|
|
11
|
+
export declare function paintImage(context: CanvasContextType, dimension: IDimension, image: HTMLImageElement | undefined, opacity: number): void;
|
|
12
|
+
export declare function clear(context: CanvasContextType, dimension: IDimension): void;
|
|
10
13
|
export declare function drawParticle(data: IDrawParticleParams): void;
|
|
11
14
|
export declare function drawAfterEffect(drawer: IEffectDrawer | undefined, data: IShapeDrawData): void;
|
|
12
15
|
export declare function drawBeforeEffect(drawer: IEffectDrawer | undefined, data: IShapeDrawData): void;
|
|
13
16
|
export declare function drawShape(drawer: IShapeDrawer | undefined, data: IShapeDrawData): void;
|
|
14
17
|
export declare function drawShapeAfterDraw(drawer: IShapeDrawer | undefined, data: IShapeDrawData): void;
|
|
15
18
|
export declare function drawShapeBeforeDraw(drawer: IShapeDrawer | undefined, data: IShapeDrawData): void;
|
|
16
|
-
export declare function drawParticlePlugin(context:
|
|
19
|
+
export declare function drawParticlePlugin(context: CanvasContextType, plugin: IContainerPlugin, particle: Particle, delta: IDelta): void;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { IColor, IHsl, IHsla, IRangeColor, IRgb, IRgba } from "../Core/Interfaces/Colors.js";
|
|
2
2
|
import { AlterType } from "../Enums/Types/AlterType.js";
|
|
3
|
-
import type { Engine } from "../Core/Engine.js";
|
|
4
3
|
import type { HslAnimation } from "../Options/Classes/HslAnimation.js";
|
|
5
4
|
import type { IDelta } from "../Core/Interfaces/IDelta.js";
|
|
6
5
|
import type { IOptionsColor } from "../Options/Interfaces/IOptionsColor.js";
|
|
7
6
|
import type { IParticleColorAnimation } from "../Core/Interfaces/IParticleValueAnimation.js";
|
|
8
7
|
import type { IParticleHslAnimation } from "../Core/Interfaces/IParticleHslAnimation.js";
|
|
9
8
|
import type { Particle } from "../Core/Particle.js";
|
|
10
|
-
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
9
|
+
import type { PluginManager } from "../Core/Utils/PluginManager.js";
|
|
10
|
+
export declare function rangeColorToRgb(pluginManager: PluginManager, input?: string | IRangeColor, index?: number, useIndex?: boolean): IRgb | undefined;
|
|
11
|
+
export declare function colorToRgb(pluginManager: PluginManager, input?: string | IColor, index?: number, useIndex?: boolean): IRgb | undefined;
|
|
12
|
+
export declare function colorToHsl(pluginManager: PluginManager, color: string | IColor | undefined, index?: number, useIndex?: boolean): IHsl | undefined;
|
|
13
|
+
export declare function rangeColorToHsl(pluginManager: PluginManager, color: string | IRangeColor | undefined, index?: number, useIndex?: boolean): IHsl | undefined;
|
|
14
14
|
export declare function rgbToHsl(color: IRgb): IHsl;
|
|
15
|
-
export declare function stringToAlpha(
|
|
16
|
-
export declare function stringToRgb(
|
|
15
|
+
export declare function stringToAlpha(pluginManager: PluginManager, input: string): number | undefined;
|
|
16
|
+
export declare function stringToRgb(pluginManager: PluginManager, input: string): IRgb | undefined;
|
|
17
17
|
export declare function hslToRgb(hsl: IHsl): IRgb;
|
|
18
18
|
export declare function hslaToRgba(hsla: IHsla): IRgba;
|
|
19
19
|
export declare function getRandomRgbColor(min?: number): IRgb;
|
|
@@ -21,7 +21,7 @@ export declare function getStyleFromRgb(color: IRgb, hdr: boolean, opacity?: num
|
|
|
21
21
|
export declare function getStyleFromHsl(color: IHsl, hdr: boolean, opacity?: number): string;
|
|
22
22
|
export declare function colorMix(color1: IRgb | IHsl, color2: IRgb | IHsl, size1: number, size2: number): IRgb;
|
|
23
23
|
export declare function getLinkColor(p1: Particle, p2?: Particle, linkColor?: string | IRgb): IRgb | undefined;
|
|
24
|
-
export declare function getLinkRandomColor(
|
|
24
|
+
export declare function getLinkRandomColor(pluginManager: PluginManager, optColor: string | IOptionsColor, blink: boolean, consent: boolean): IRgb | string | undefined;
|
|
25
25
|
export declare function getHslFromAnimation(animation?: IParticleHslAnimation): IHsl | undefined;
|
|
26
26
|
export declare function getHslAnimationFromHsl(hsl: IHsl, animationOptions: HslAnimation | undefined, reduceFactor: number): IParticleHslAnimation;
|
|
27
27
|
export declare function updateColorValue(data: IParticleColorAnimation, decrease: boolean, delta: IDelta): void;
|
|
@@ -3,6 +3,7 @@ interface ILogger {
|
|
|
3
3
|
error(this: void, message?: unknown, ...optionalParams: unknown[]): void;
|
|
4
4
|
info(this: void, message?: unknown, ...optionalParams: unknown[]): void;
|
|
5
5
|
log(this: void, message?: unknown, ...optionalParams: unknown[]): void;
|
|
6
|
+
trace(this: void, ...data: unknown[]): void;
|
|
6
7
|
verbose(this: void, message?: unknown, ...optionalParams: unknown[]): void;
|
|
7
8
|
warning(this: void, message?: unknown, ...optionalParams: unknown[]): void;
|
|
8
9
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Container } from "../Core/Container.js";
|
|
2
|
-
import type { Engine } from "../Core/Engine.js";
|
|
3
2
|
import type { IOptionLoader } from "../Options/Interfaces/IOptionLoader.js";
|
|
4
3
|
import type { IParticlesOptions } from "../Options/Interfaces/Particles/IParticlesOptions.js";
|
|
5
4
|
import { ParticlesOptions } from "../Options/Classes/Particles/ParticlesOptions.js";
|
|
5
|
+
import type { PluginManager } from "../Core/Utils/PluginManager.js";
|
|
6
6
|
import type { RecursivePartial } from "../Types/RecursivePartial.js";
|
|
7
7
|
export declare function loadOptions<T>(options: IOptionLoader<T>, ...sourceOptionsArr: RecursivePartial<T | undefined>[]): void;
|
|
8
|
-
export declare function loadParticlesOptions(
|
|
8
|
+
export declare function loadParticlesOptions(pluginManager: PluginManager, container: Container, ...sourceOptionsArr: RecursivePartial<IParticlesOptions | undefined>[]): ParticlesOptions;
|
package/types/export-types.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ export type * from "./Options/Interfaces/Particles/Bounce/IParticlesBounce.js";
|
|
|
43
43
|
export type * from "./Options/Interfaces/Particles/Effect/IEffect.js";
|
|
44
44
|
export type * from "./Options/Interfaces/Particles/IParticlesOptions.js";
|
|
45
45
|
export type * from "./Options/Interfaces/Particles/IFill.js";
|
|
46
|
+
export type * from "./Options/Interfaces/Particles/IPaint.js";
|
|
46
47
|
export type * from "./Options/Interfaces/Particles/IStroke.js";
|
|
47
48
|
export type * from "./Options/Interfaces/Particles/Move/IMove.js";
|
|
48
49
|
export type * from "./Options/Interfaces/Particles/Move/IMoveAngle.js";
|
|
@@ -60,6 +61,7 @@ export type * from "./Options/Interfaces/Particles/Shape/IShape.js";
|
|
|
60
61
|
export type * from "./Options/Interfaces/Particles/Size/ISize.js";
|
|
61
62
|
export type * from "./Options/Interfaces/Particles/Size/ISizeAnimation.js";
|
|
62
63
|
export type * from "./Options/Interfaces/Particles/ZIndex/IZIndex.js";
|
|
64
|
+
export type * from "./Types/CanvasContextType.js";
|
|
63
65
|
export type * from "./Types/CustomEventArgs.js";
|
|
64
66
|
export type * from "./Types/CustomEventListener.js";
|
|
65
67
|
export type * from "./Types/EasingFunction.js";
|
|
@@ -74,9 +76,10 @@ export type * from "./Types/ShapeData.js";
|
|
|
74
76
|
export type * from "./Types/SingleOrMultiple.js";
|
|
75
77
|
export type { EventListeners } from "./Core/Utils/EventListeners.js";
|
|
76
78
|
export type { SpatialHashGrid } from "./Core/Utils/SpatialHashGrid.js";
|
|
77
|
-
export type {
|
|
79
|
+
export type { CanvasManager } from "./Core/CanvasManager.js";
|
|
78
80
|
export type { Container } from "./Core/Container.js";
|
|
79
81
|
export type { Particle } from "./Core/Particle.js";
|
|
80
|
-
export type {
|
|
82
|
+
export type { ParticlesManager } from "./Core/ParticlesManager.js";
|
|
81
83
|
export type { Retina } from "./Core/Retina.js";
|
|
82
84
|
export type { Engine } from "./Core/Engine.js";
|
|
85
|
+
export type { PluginManager } from "./Core/Utils/PluginManager.js";
|
package/types/exports.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export * from "./Options/Classes/Particles/Bounce/ParticlesBounce.js";
|
|
|
28
28
|
export * from "./Options/Classes/Particles/Bounce/ParticlesBounceFactor.js";
|
|
29
29
|
export * from "./Options/Classes/Particles/ParticlesOptions.js";
|
|
30
30
|
export * from "./Options/Classes/Particles/Fill.js";
|
|
31
|
+
export * from "./Options/Classes/Particles/Paint.js";
|
|
31
32
|
export * from "./Options/Classes/Particles/Stroke.js";
|
|
32
33
|
export * from "./Options/Classes/Particles/Move/Move.js";
|
|
33
34
|
export * from "./Options/Classes/Particles/Move/MoveAngle.js";
|
package/164.min.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(this.webpackChunk_tsparticles_engine=this.webpackChunk_tsparticles_engine||[]).push([[164],{8164(t,i,e){e.d(i,{Container:()=>O});var s=e(3884),a=e(1590),r=e(9854),n=e(4874),o=e(1339);function l(t,i,e=!1){if(!i)return;let s=t.style,a=new Set;for(let t=0;t<s.length;t++){let i=s.item(t);i&&a.add(i)}for(let t=0;t<i.length;t++){let e=i.item(t);e&&a.add(e)}for(let t of a){let a=i.getPropertyValue(t);a?s.setProperty(t,a,e?"important":""):s.removeProperty(t)}}class h{container;element;size;zoom=a.Pf;_canvasClearPlugins;_canvasPaintPlugins;_canvasSettings;_clearDrawPlugins;_colorPlugins;_context;_drawParticlePlugins;_drawParticlesCleanupPlugins;_drawParticlesSetupPlugins;_drawPlugins;_drawSettingsCleanupPlugins;_drawSettingsSetupPlugins;_engine;_generated;_mutationObserver;_originalStyle;_pointerEvents;_postDrawUpdaters;_preDrawUpdaters;_resizePlugins;_reusableColorStyles={};_reusablePluginColors=[void 0,void 0];_reusableTransform={};_standardSize;_zoomCenter;constructor(t,i){this.container=t,this._engine=i,this._standardSize={height:0,width:0};const e=t.retina.pixelRatio,s=this._standardSize;this.size={height:s.height*e,width:s.width*e},this._context=null,this._generated=!1,this._preDrawUpdaters=[],this._postDrawUpdaters=[],this._resizePlugins=[],this._colorPlugins=[],this._canvasClearPlugins=[],this._canvasPaintPlugins=[],this._clearDrawPlugins=[],this._drawParticlePlugins=[],this._drawParticlesCleanupPlugins=[],this._drawParticlesSetupPlugins=[],this._drawPlugins=[],this._drawSettingsSetupPlugins=[],this._drawSettingsCleanupPlugins=[],this._pointerEvents="none"}get settings(){return this._canvasSettings}get _fullScreen(){return this.container.actualOptions.fullScreen.enable}canvasClear(){this.container.actualOptions.clear&&this.draw(t=>{(0,r.IU)(t,this.size)})}clear(){let t=!1;for(let i of this._canvasClearPlugins)if(t=i.canvasClear?.()??!1)break;t||this.canvasClear()}destroy(){if(this.stop(),this._generated){let t=this.element;t?.remove(),this.element=void 0}else this._resetOriginalStyle();this._preDrawUpdaters=[],this._postDrawUpdaters=[],this._resizePlugins=[],this._colorPlugins=[],this._canvasClearPlugins=[],this._canvasPaintPlugins=[],this._clearDrawPlugins=[],this._drawParticlePlugins=[],this._drawParticlesCleanupPlugins=[],this._drawParticlesSetupPlugins=[],this._drawPlugins=[],this._drawSettingsSetupPlugins=[],this._drawSettingsCleanupPlugins=[]}draw(t){let i=this._context;if(i)return t(i)}drawParticle(t,i){if(t.spawning||t.destroyed)return;let e=t.getRadius();if(e<=a.w2)return;let s=t.getFillColor(),n=t.getStrokeColor(),[l,h]=this._getPluginParticleColors(t);if(l??=s,h??=n,!l&&!h)return;let c=this.container,d=t.options.zIndex,p=a.RV-t.zIndexFactor,{fillOpacity:u,opacity:_,strokeOpacity:g}=t.getOpacity(),f=this._reusableTransform,P=this._reusableColorStyles,m=l?(0,o.LC)(l,c.hdr,u*_):void 0,y=h?(0,o.LC)(h,c.hdr,g*_):m;f.a=f.b=f.c=f.d=void 0,P.fill=m,P.stroke=y,this.draw(s=>{for(let e of this._drawParticlesSetupPlugins)e.drawParticleSetup?.(s,t,i);for(let a of(this._applyPreDrawUpdaters(s,t,e,_,P,f),(0,r.p0)({container:c,context:s,particle:t,delta:i,colorStyles:P,radius:e*p**d.sizeRate,opacity:_,transform:f}),this._applyPostDrawUpdaters(t),this._drawParticlesCleanupPlugins))a.drawParticleCleanup?.(s,t,i)})}drawParticlePlugins(t,i){this.draw(e=>{for(let s of this._drawParticlePlugins)(0,r.Wb)(e,s,t,i)})}drawParticles(t){let{particles:i}=this.container;this.clear(),i.update(t),this.draw(e=>{for(let i of this._drawSettingsSetupPlugins)i.drawSettingsSetup?.(e,t);for(let i of this._drawPlugins)i.draw?.(e,t);for(let s of(i.drawParticles(t),this._clearDrawPlugins))s.clearDraw?.(e,t);for(let i of this._drawSettingsCleanupPlugins)i.drawSettingsCleanup?.(e,t)})}getZoomCenter(){let t=this.container.retina.pixelRatio,{width:i,height:e}=this.size;return this._zoomCenter?this._zoomCenter:{x:i*a.MX/t,y:e*a.MX/t}}init(){this._safeMutationObserver(t=>{t.disconnect()}),this._mutationObserver=(0,n.tG)(t=>{for(let i of t)"attributes"===i.type&&"style"===i.attributeName&&this._repairStyle()}),this.resize(),this._initStyle(),this.initBackground(),this._safeMutationObserver(t=>{this.element&&this.element instanceof Node&&t.observe(this.element,{attributes:!0})}),this.initUpdaters(),this.initPlugins(),this.paint()}initBackground(){let{container:t}=this,i=t.actualOptions.background,e=this.element;if(!e)return;let s=e.style,a=(0,o.BN)(this._engine,i.color);a?s.backgroundColor=(0,o.xx)(a,t.hdr,i.opacity):s.backgroundColor="",s.backgroundImage=i.image||"",s.backgroundPosition=i.position||"",s.backgroundRepeat=i.repeat||"",s.backgroundSize=i.size||""}initPlugins(){for(let t of(this._resizePlugins=[],this._colorPlugins=[],this._canvasClearPlugins=[],this._canvasPaintPlugins=[],this._clearDrawPlugins=[],this._drawParticlePlugins=[],this._drawParticlesSetupPlugins=[],this._drawParticlesCleanupPlugins=[],this._drawPlugins=[],this._drawSettingsSetupPlugins=[],this._drawSettingsCleanupPlugins=[],this.container.plugins))t.resize&&this._resizePlugins.push(t),(t.particleFillColor??t.particleStrokeColor)&&this._colorPlugins.push(t),t.canvasClear&&this._canvasClearPlugins.push(t),t.canvasPaint&&this._canvasPaintPlugins.push(t),t.drawParticle&&this._drawParticlePlugins.push(t),t.drawParticleSetup&&this._drawParticlesSetupPlugins.push(t),t.drawParticleCleanup&&this._drawParticlesCleanupPlugins.push(t),t.draw&&this._drawPlugins.push(t),t.drawSettingsSetup&&this._drawSettingsSetupPlugins.push(t),t.drawSettingsCleanup&&this._drawSettingsCleanupPlugins.push(t),t.clearDraw&&this._clearDrawPlugins.push(t)}initUpdaters(){for(let t of(this._preDrawUpdaters=[],this._postDrawUpdaters=[],this.container.particles.updaters))t.afterDraw&&this._postDrawUpdaters.push(t),(t.getColorStyles??t.getTransformValues??t.beforeDraw)&&this._preDrawUpdaters.push(t)}loadCanvas(t){this._generated&&this.element&&this.element.remove();let i=this.container;this._generated=a.eb in t.dataset?"true"===t.dataset[a.eb]:this._generated,this.element=t,this.element.ariaHidden="true",this._originalStyle=(0,n.td)(this.element.style);let e=this._standardSize;e.height=t.offsetHeight,e.width=t.offsetWidth;let s=this.container.retina.pixelRatio,r=this.size;t.height=r.height=e.height*s,t.width=r.width=e.width*s;let o=(0,n.lV)("(color-gamut: p3)");this._canvasSettings={alpha:!0,colorSpace:o?.matches&&i.hdr?"display-p3":"srgb",desynchronized:!0,willReadFrequently:!1},this._context=this.element.getContext("2d",this._canvasSettings),this._context&&(this._context.globalCompositeOperation=a.yj),this._safeMutationObserver(t=>{t.disconnect()}),i.retina.init(),this.initBackground(),this._safeMutationObserver(t=>{this.element&&this.element instanceof Node&&t.observe(this.element,{attributes:!0})})}paint(){let t=!1;for(let i of this._canvasPaintPlugins)if(t=i.canvasPaint?.()??!1)break;t||this.paintBase()}paintBase(t){this.draw(i=>{(0,r.Sn)(i,this.size,t)})}paintImage(t,i){this.draw(e=>{(0,r.Md)(e,this.size,t,i)})}resize(){if(!this.element)return!1;let t=this.container,i=t.canvas._standardSize,e={width:this.element.offsetWidth,height:this.element.offsetHeight},s=t.retina.pixelRatio,a={width:e.width*s,height:e.height*s};if(e.height===i.height&&e.width===i.width&&a.height===this.element.height&&a.width===this.element.width)return!1;let r={...i};i.height=e.height,i.width=e.width;let n=this.size;return this.element.width=n.width=a.width,this.element.height=n.height=a.height,this.container.started&&t.particles.setResizeFactor({width:i.width/r.width,height:i.height/r.height}),!0}setPointerEvents(t){this.element&&(this._pointerEvents=t,this._repairStyle())}setZoom(t,i){this.zoom=t,this._zoomCenter=i}stop(){this._safeMutationObserver(t=>{t.disconnect()}),this._mutationObserver=void 0,this.draw(t=>{(0,r.IU)(t,this.size)})}async windowResize(){if(!this.element||!this.resize())return;let t=this.container,i=t.updateActualOptions();t.particles.setDensity(),this._applyResizePlugins(),i&&await t.refresh()}_applyPostDrawUpdaters=t=>{for(let i of this._postDrawUpdaters)i.afterDraw?.(t)};_applyPreDrawUpdaters=(t,i,e,s,r,n)=>{for(let o of this._preDrawUpdaters){if(o.getColorStyles){let{fill:a,stroke:n}=o.getColorStyles(i,t,e,s);a&&(r.fill=a),n&&(r.stroke=n)}if(o.getTransformValues){let t=o.getTransformValues(i);for(let i in t)!function(t,i,e){let s=i[e];void 0!==s&&(t[e]=(t[e]??a.zs)*s)}(n,t,i)}o.beforeDraw?.(i)}};_applyResizePlugins=()=>{for(let t of this._resizePlugins)t.resize?.()};_getPluginParticleColors=t=>{let i,e;for(let s of this._colorPlugins)if(!i&&s.particleFillColor&&(i=(0,o.R5)(this._engine,s.particleFillColor(t))),!e&&s.particleStrokeColor&&(e=(0,o.R5)(this._engine,s.particleStrokeColor(t))),i&&e)break;return this._reusablePluginColors[0]=i,this._reusablePluginColors[1]=e,this._reusablePluginColors};_initStyle=()=>{let t=this.element,i=this.container.actualOptions;if(t)for(let e in this._fullScreen?this._setFullScreenStyle():this._resetOriginalStyle(),i.style){if(!e||!(e in i.style))continue;let s=i.style[e];s&&t.style.setProperty(e,s,"important")}};_repairStyle=()=>{let t=this.element;if(!t)return;this._safeMutationObserver(t=>{t.disconnect()}),this._initStyle(),this.initBackground();let i=this._pointerEvents;t.style.pointerEvents=i,t.setAttribute("pointer-events",i),this._safeMutationObserver(i=>{t instanceof Node&&i.observe(t,{attributes:!0})})};_resetOriginalStyle=()=>{let t=this.element,i=this._originalStyle;t&&i&&l(t,i,!0)};_safeMutationObserver=t=>{this._mutationObserver&&t(this._mutationObserver)};_setFullScreenStyle=()=>{let t=this.element;t&&l(t,(0,n.hJ)(this.container.actualOptions.fullScreen.zIndex),!0)}}class c{container;_handlers;_resizeObserver;_resizeTimeout;constructor(t){this.container=t,this._handlers={visibilityChange:()=>{this._handleVisibilityChange()},resize:()=>{this._handleWindowResize()}}}addListeners(){this._manageListeners(!0)}removeListeners(){this._manageListeners(!1)}_handleVisibilityChange=()=>{let t=this.container;t.actualOptions.pauseOnBlur&&((0,n.T5)().hidden?(t.pageHidden=!0,t.pause()):(t.pageHidden=!1,t.animationStatus?t.play(!0):t.draw(!0)))};_handleWindowResize=()=>{this._resizeTimeout&&(clearTimeout(this._resizeTimeout),delete this._resizeTimeout);let t=async()=>{let t=this.container.canvas;await t.windowResize()};this._resizeTimeout=setTimeout(()=>void t(),this.container.actualOptions.resize.delay*a.Xu)};_manageListeners=t=>{let i=this._handlers;this._manageResize(t),(0,n.Kp)(document,a.nK,i.visibilityChange,t,!1)};_manageResize=t=>{let i=this._handlers,e=this.container;if(!e.actualOptions.resize.enable)return;if("u"<typeof ResizeObserver)return void(0,n.Kp)(globalThis,a.NF,i.resize,t);let s=e.canvas.element;this._resizeObserver&&!t?(s&&this._resizeObserver.unobserve(s),this._resizeObserver.disconnect(),delete this._resizeObserver):!this._resizeObserver&&t&&s&&(this._resizeObserver=new ResizeObserver(t=>{t.find(t=>t.target===s)&&this._handleWindowResize()}),this._resizeObserver.observe(s))}}var d=e(8202),p=e(9289),u=e(3443),_=e(2067),g=e(7613),f=e(3652),P=e(6492),m=e(3692);function y(t){if(!(0,n.hn)(t.outMode,t.checkModes))return;let i=t.radius*a.gd;t.coord>t.maxCoord-i?t.setCb(-t.radius):t.coord<i&&t.setCb(t.radius)}class w{container;backColor;bubble;destroyed;direction;effect;effectClose;effectData;fillColor;fillEnabled;fillOpacity;group;id;ignoresResizeRatio;initialPosition;initialVelocity;isRotating;lastPathTime;misplaced;moveCenter;offset;opacity;options;outType;pathRotation;position;randomIndexData;retina;roll;rotation;shape;shapeClose;shapeData;sides;size;slow;spawning;strokeColor;strokeOpacity;strokeWidth;unbreakable;velocity;zIndexFactor;_cachedOpacityData={fillOpacity:a.hv,opacity:a.hv,strokeOpacity:a.hv};_cachedPosition=_.p.origin;_cachedRotateData={sin:0,cos:0};_cachedTransform={a:1,b:0,c:0,d:1};_engine;constructor(t,i){this.container=i,this._engine=t}destroy(t){if(this.unbreakable||this.destroyed)return;this.destroyed=!0,this.bubble.inRange=!1,this.slow.inRange=!1;let i=this.container,e=this.shape?i.particles.shapeDrawers.get(this.shape):void 0;for(let s of(e?.particleDestroy?.(this),i.particleDestroyedPlugins))s.particleDestroyed?.(this,t);for(let e of i.particles.updaters)e.particleDestroyed?.(this,t);this._engine.dispatchEvent(d.B.particleDestroyed,{container:this.container,data:{particle:this}})}draw(t){let i=this.container.canvas;i.drawParticlePlugins(this,t),i.drawParticle(this,t)}getAngle(){return this.rotation+(this.pathRotation?this.velocity.angle:a.tA)}getFillColor(){return this._getRollColor(this.bubble.color??(0,o.O_)(this.fillColor))}getMass(){return this.getRadius()**a.dm*Math.PI*a.MX}getOpacity(){let t=this.options.zIndex,i=a.RV-this.zIndexFactor,e=i**t.opacityRate,r=this.bubble.opacity??(0,s.VG)(this.opacity?.value??a.hv),n=this.fillOpacity??a.hv,o=this.strokeOpacity??a.hv;return this._cachedOpacityData.fillOpacity=r*n*e,this._cachedOpacityData.opacity=r*e,this._cachedOpacityData.strokeOpacity=r*o*e,this._cachedOpacityData}getPosition(){return this._cachedPosition.x=this.position.x+this.offset.x,this._cachedPosition.y=this.position.y+this.offset.y,this._cachedPosition.z=this.position.z,this._cachedPosition}getRadius(){return this.bubble.radius??this.size.value}getRotateData(){let t=this.getAngle();return this._cachedRotateData.sin=Math.sin(t),this._cachedRotateData.cos=Math.cos(t),this._cachedRotateData}getStrokeColor(){return this._getRollColor(this.bubble.color??(0,o.O_)(this.strokeColor))}getTransformData(t){let i=this.getRotateData(),e=this.isRotating;return this._cachedTransform.a=i.cos*(t.a??a.Ug.a),this._cachedTransform.b=e?i.sin*(t.b??a.D_):t.b??a.Ug.b,this._cachedTransform.c=e?-i.sin*(t.c??a.D_):t.c??a.Ug.c,this._cachedTransform.d=i.cos*(t.d??a.Ug.d),this._cachedTransform}init(t,i,e,r){var o,l,h,c;let d,p,u,_,g=this.container;this.id=t,this.group=r,this.effectClose=!0,this.shapeClose=!0,this.pathRotation=!1,this.lastPathTime=0,this.destroyed=!1,this.unbreakable=!1,this.isRotating=!1,this.rotation=0,this.misplaced=!1,this.retina={maxDistance:{}},this.outType=P.x.normal,this.ignoresResizeRatio=!0;let f=g.retina.pixelRatio,y=g.actualOptions,w=(0,m.y)(this._engine,g,y.particles),v=w.reduceDuplicates,z=w.effect.type,b=w.shape.type;this.effect=(0,n.TA)(z,this.id,v),this.shape=(0,n.TA)(b,this.id,v);let S=w.effect,C=w.shape;if(e){if(e.effect?.type){let t=e.effect.type,i=(0,n.TA)(t,this.id,v);i&&(this.effect=i,S.load(e.effect))}if(e.shape?.type){let t=e.shape.type,i=(0,n.TA)(t,this.id,v);i&&(this.shape=i,C.load(e.shape))}}if(this.effect===a.mR){let t=[...this.container.particles.effectDrawers.keys()];this.effect=t[Math.floor((0,s.G0)()*t.length)]}if(this.shape===a.mR){let t=[...this.container.particles.shapeDrawers.keys()];this.shape=t[Math.floor((0,s.G0)()*t.length)]}this.effectData=this.effect?(o=this.effect,l=this.id,u=S.options[o],(0,n.zw)({close:S.close},(0,n.TA)(u,l,v))):void 0,this.shapeData=this.shape?(h=this.shape,c=this.id,_=C.options[h],(0,n.zw)({close:C.close},(0,n.TA)(_,c,v))):void 0,w.load(e);let x=this.effectData;x&&w.load(x.particles);let D=this.shapeData;D&&w.load(D.particles),this.effectClose=x?.close??w.effect.close,this.shapeClose=D?.close??w.shape.close,this.options=w,g.retina.initParticle(this),this.size=(0,n.Xs)(this.options.size,f),this.bubble={inRange:!1},this.slow={inRange:!1,factor:1},this._initPosition(i),this.initialVelocity=this._calculateVelocity(),this.velocity=this.initialVelocity.copy();let O=g.particles;O.setLastZIndex(this.position.z),this.zIndexFactor=this.position.z/g.zLayers,this.sides=24,this.effect&&(d=g.particles.effectDrawers.get(this.effect)),d?.loadEffect&&d.loadEffect(this),this.shape&&(p=g.particles.shapeDrawers.get(this.shape)),p?.loadShape&&p.loadShape(this);let R=p?.getSidesCount;for(let t of(R&&(this.sides=R(this)),this.spawning=!1,O.updaters))t.init(this);for(let t of(d?.particleInit?.(g,this),p?.particleInit?.(g,this),g.particleCreatedPlugins))t.particleCreated?.(this)}isInsideCanvas(){let t=this.getRadius(),i=this.container.canvas.size,e=this.position;return e.x>=-t&&e.y>=-t&&e.y<=i.height+t&&e.x<=i.width+t}isShowingBack(){if(!this.roll)return!1;let t=this.roll.angle;if(this.roll.horizontal&&this.roll.vertical){let i=t%a.R1,e=i<a.tA?i+a.R1:i;return e>=Math.PI*a.MX&&e<Math.PI*a.Nu*a.MX}if(this.roll.horizontal){let i=(t+Math.PI*a.MX)%(Math.PI*a.gd),e=i<a.tA?i+Math.PI*a.gd:i;return e>=Math.PI&&e<Math.PI*a.gd}if(this.roll.vertical){let i=t%(Math.PI*a.gd),e=i<a.tA?i+Math.PI*a.gd:i;return e>=Math.PI&&e<Math.PI*a.gd}return!1}isVisible(){return!this.destroyed&&!this.spawning&&this.isInsideCanvas()}reset(){for(let t of this.container.particles.updaters)t.reset?.(this)}_calcPosition=(t,i)=>{let e=a.rq,r=t?_.p.create(t.x,t.y,i):void 0,n=this.container,o=n.particlePositionPlugins,l=this.options.move.outModes,h=this.getRadius(),c=n.canvas.size,{signal:d}=new AbortController;for(;!d.aborted;){for(let t of o){let e=t.particlePosition?.(r,this);if(e)return _.p.create(e.x,e.y,i)}let t=(0,s.Nx)({size:c,position:r}),d=_.p.create(t.x,t.y,i);this._fixHorizontal(d,h,l.left??l.default),this._fixHorizontal(d,h,l.right??l.default),this._fixVertical(d,h,l.top??l.default),this._fixVertical(d,h,l.bottom??l.default);let p=!0;for(let t of n.particles.checkParticlePositionPlugins)if(!(p=t.checkParticlePosition?.(this,d,e)??!0))break;if(p)return d;e+=a.Eo,r=void 0}return r};_calculateVelocity=()=>{let t=(0,s.$m)(this.direction).copy(),i=this.options.move;if(i.direction===g.F.inside||i.direction===g.F.outside)return t;let e=(0,s.pu)((0,s.VG)(i.angle.value)),r=(0,s.pu)((0,s.VG)(i.angle.offset)),n={left:r-e*a.MX,right:r+e*a.MX};return i.straight||(t.angle+=(0,s.vE)((0,s.DT)(n.left,n.right))),i.random&&"number"==typeof i.speed&&(t.length*=(0,s.G0)()),t};_fixHorizontal=(t,i,e)=>{y({outMode:e,checkModes:[f.Y.bounce],coord:t.x,maxCoord:this.container.canvas.size.width,setCb:i=>t.x+=i,radius:i})};_fixVertical=(t,i,e)=>{y({outMode:e,checkModes:[f.Y.bounce],coord:t.y,maxCoord:this.container.canvas.size.height,setCb:i=>t.y+=i,radius:i})};_getRollColor=t=>t&&this.roll&&(this.backColor||this.roll.alter)&&this.isShowingBack()?this.backColor?this.backColor:this.roll.alter?(0,o.yx)(t,this.roll.alter.type,this.roll.alter.value):t:t;_initPosition=t=>{let i=this.container,e=(0,s.VG)(this.options.zIndex.value),r=this._calcPosition(t,(0,s.qE)(e,a.X_,i.zLayers));if(!r)throw Error("a valid position cannot be found for particle");this.position=r,this.initialPosition=this.position.copy();let o=i.canvas.size;switch(this.moveCenter={...(0,n.E9)(this.options.move.center,o),radius:this.options.move.center.radius,mode:this.options.move.center.mode},this.direction=(0,s.JY)(this.options.move.direction,this.position,this.moveCenter),this.options.move.direction){case g.F.inside:this.outType=P.x.inside;break;case g.F.outside:this.outType=P.x.outside}this.offset=_.M.origin}}var v=e(5821);class z{_cellSize;_cells=new Map;_circlePool=[];_circlePoolIdx;_pendingCellSize;_rectanglePool=[];_rectanglePoolIdx;constructor(t){this._cellSize=t,this._circlePoolIdx=0,this._rectanglePoolIdx=0}clear(){this._cells.clear();let t=this._pendingCellSize;t&&(this._cellSize=t),this._pendingCellSize=void 0}insert(t){let{x:i,y:e}=t.getPosition(),s=this._cellKeyFromCoords(i,e);this._cells.has(s)||this._cells.set(s,[]),this._cells.get(s)?.push(t)}query(t,i,e=[]){let s=this._getRangeBounds(t);if(!s)return e;let a=Math.floor(s.minX/this._cellSize),r=Math.floor(s.maxX/this._cellSize),n=Math.floor(s.minY/this._cellSize),o=Math.floor(s.maxY/this._cellSize);for(let s=a;s<=r;s++)for(let a=n;a<=o;a++){let r=`${s}_${a}`,n=this._cells.get(r);if(n)for(let s of n)(!i||i(s))&&t.contains(s.getPosition())&&e.push(s)}return e}queryCircle(t,i,e,s=[]){let a=this._acquireCircle(t.x,t.y,i),r=this.query(a,e,s);return this._releaseShapes(),r}queryRectangle(t,i,e,s=[]){let a=this._acquireRectangle(t.x,t.y,i.width,i.height),r=this.query(a,e,s);return this._releaseShapes(),r}setCellSize(t){this._pendingCellSize=t}_acquireCircle(t,i,e){return(this._circlePool[this._circlePoolIdx++]??=new v.jl(t,i,e)).reset(t,i,e)}_acquireRectangle(t,i,e,s){return(this._rectanglePool[this._rectanglePoolIdx++]??=new v.M_(t,i,e,s)).reset(t,i,e,s)}_cellKeyFromCoords(t,i){let e=Math.floor(t/this._cellSize),s=Math.floor(i/this._cellSize);return`${e}_${s}`}_getRangeBounds(t){if(t instanceof v.jl){let i=t.radius,{x:e,y:s}=t.position;return{minX:e-i,maxX:e+i,minY:s-i,maxY:s+i}}if(t instanceof v.M_){let{x:i,y:e}=t.position,{width:s,height:a}=t.size;return{minX:i,maxX:i+s,minY:e,maxY:e+a}}return null}_releaseShapes(){this._circlePoolIdx=0,this._rectanglePoolIdx=0}}var b=e(3112);class S{checkParticlePositionPlugins;effectDrawers;grid;shapeDrawers;updaters;_array;_container;_engine;_groupLimits;_limit;_maxZIndex;_minZIndex;_needsSort;_nextId;_particleResetPlugins;_particleUpdatePlugins;_pool;_postParticleUpdatePlugins;_postUpdatePlugins;_resizeFactor;_updatePlugins;_zArray;constructor(t,i){this._engine=t,this._container=i,this._nextId=0,this._array=[],this._zArray=[],this._pool=[],this._limit=0,this._groupLimits=new Map,this._needsSort=!1,this._minZIndex=0,this._maxZIndex=0,this.grid=new z(a.iX),this.effectDrawers=new Map,this.shapeDrawers=new Map,this.updaters=[],this.checkParticlePositionPlugins=[],this._particleResetPlugins=[],this._particleUpdatePlugins=[],this._postUpdatePlugins=[],this._postParticleUpdatePlugins=[],this._updatePlugins=[]}get count(){return this._array.length}addParticle(t,i,e,s){let r=this._container.actualOptions.particles.number.limit.mode,n=void 0===e?this._limit:this._groupLimits.get(e)??this._limit,o=this.count;if(n>a.ou)switch(r){case u.d.delete:{let t=o+a.nq-n;t>a.wM&&this.removeQuantity(t);break}case u.d.wait:if(o>=n)return}try{let a=this._pool.pop()??new w(this._engine,this._container);a.init(this._nextId,t,i,e);let r=!0;if(s&&(r=s(a)),!r)return void this._pool.push(a);return this._array.push(a),this._zArray.push(a),this._nextId++,this._engine.dispatchEvent(d.B.particleAdded,{container:this._container,data:{particle:a}}),a}catch(t){(0,b.t)().warning(`error adding particle: ${t}`)}}clear(){this._array=[],this._zArray=[]}destroy(){let t=this._container;for(let[,i]of this.effectDrawers)i.destroy?.(t);for(let[,i]of this.shapeDrawers)i.destroy?.(t);this._array=[],this._pool.length=0,this._zArray=[],this.effectDrawers=new Map,this.shapeDrawers=new Map,this.updaters=[],this.checkParticlePositionPlugins=[],this._particleResetPlugins=[],this._particleUpdatePlugins=[],this._postUpdatePlugins=[],this._postParticleUpdatePlugins=[],this._updatePlugins=[]}drawParticles(t){for(let i of this._zArray)i.draw(t)}filter(t){return this._array.filter(t)}find(t){return this._array.find(t)}get(t){return this._array[t]}async init(){let t=this._container,i=t.actualOptions;for(let i of(this._minZIndex=0,this._maxZIndex=0,this._needsSort=!1,this.checkParticlePositionPlugins=[],this._updatePlugins=[],this._particleUpdatePlugins=[],this._postUpdatePlugins=[],this._particleResetPlugins=[],this._postParticleUpdatePlugins=[],this.grid=new z(a.iX*t.retina.pixelRatio),t.plugins))i.redrawInit&&await i.redrawInit(),i.checkParticlePosition&&this.checkParticlePositionPlugins.push(i),i.update&&this._updatePlugins.push(i),i.particleUpdate&&this._particleUpdatePlugins.push(i),i.postUpdate&&this._postUpdatePlugins.push(i),i.particleReset&&this._particleResetPlugins.push(i),i.postParticleUpdate&&this._postParticleUpdatePlugins.push(i);for(let i of(await this.initPlugins(),this.effectDrawers.values()))await i.init?.(t);for(let i of this.shapeDrawers.values())await i.init?.(t);let e=!1;for(let i of t.plugins)if(e=i.particlesInitialization?.()??e)break;if(!e){let t=i.particles,e=t.groups;for(let i in e){let s=e[i];if(s)for(let e=this.count,a=0;a<s.number.value&&e<t.number.value;e++,a++)this.addParticle(void 0,s,i)}for(let i=this.count;i<t.number.value;i++)this.addParticle()}}async initPlugins(){let t=this._container;this.effectDrawers=await this._engine.getEffectDrawers(t,!0),this.shapeDrawers=await this._engine.getShapeDrawers(t,!0),this.updaters=await this._engine.getUpdaters(t,!0)}push(t,i,e,s){for(let a=0;a<t;a++)this.addParticle(i,e,s)}async redraw(){this.clear(),await this.init(),this._container.canvas.drawParticles({value:0,factor:0})}remove(t,i,e){this.removeAt(this._array.indexOf(t),void 0,i,e)}removeAt(t,i=a.xd,e,s){if(t<a.z9||t>this.count)return;let r=0;for(let a=t;r<i&&a<this.count;a++)this._removeParticle(a,e,s)&&(a--,r++)}removeQuantity(t,i){this.removeAt(a.z9,t,i)}setDensity(){let t=this._container.actualOptions,i=t.particles.groups,e=0;for(let t of this._container.plugins)t.particlesDensityCount&&(e+=t.particlesDensityCount());for(let t in i){let s=i[t];if(!s)continue;let a=(0,m.y)(this._engine,this._container,s);this._applyDensity(a,e,t)}this._applyDensity(t.particles,e)}setLastZIndex(t){this._needsSort||=t>=this._maxZIndex||t>this._minZIndex&&t<this._maxZIndex}setResizeFactor(t){this._resizeFactor=t}update(t){let i=new Set;for(let i of(this.grid.clear(),this._updatePlugins))i.update?.(t);let e=this._resizeFactor;for(let s of this._array){for(let t of(e&&!s.ignoresResizeRatio&&(s.position.x*=e.width,s.position.y*=e.height,s.initialPosition.x*=e.width,s.initialPosition.y*=e.height),s.ignoresResizeRatio=!1,this._particleResetPlugins))t.particleReset?.(s);for(let i of this._particleUpdatePlugins){if(s.destroyed)break;i.particleUpdate?.(s,t)}if(s.destroyed){i.add(s);continue}this.grid.insert(s)}if(i.size){let t=t=>!i.has(t);for(let e of(this._array=this.filter(t),this._zArray=this._zArray.filter(t),i))this._engine.dispatchEvent(d.B.particleRemoved,{container:this._container,data:{particle:e}});this._addToPool(...i)}for(let i of this._postUpdatePlugins)i.postUpdate?.(t);for(let i of this._array){for(let e of this.updaters)e.update(i,t);if(!i.destroyed&&!i.spawning)for(let e of this._postParticleUpdatePlugins)e.postParticleUpdate?.(i,t)}if(delete this._resizeFactor,this._needsSort){let t=this._zArray;t.sort((t,i)=>i.position.z-t.position.z||t.id-i.id);let i=t[a.z9],e=t[t.length-a.K3];if(!i||!e)return;this._maxZIndex=i.position.z,this._minZIndex=e.position.z,this._needsSort=!1}}_addToPool=(...t)=>{this._pool.push(...t)};_applyDensity=(t,i,e,s)=>{let r=t.number;if(!r.density.enable)return void(void 0===e?this._limit=r.limit.value:(s?.number.limit.value??r.limit.value)&&this._groupLimits.set(e,s?.number.limit.value??r.limit.value));let n=this._initDensityFactor(r.density),o=r.value,l=r.limit.value>a.ou?r.limit.value:o,h=Math.min(o,l)*n+i,c=Math.min(this.count,this.filter(t=>t.group===e).length);void 0===e?this._limit=r.limit.value*n:this._groupLimits.set(e,r.limit.value*n),c<h?this.push(Math.abs(h-c),void 0,t,e):c>h&&this.removeQuantity(c-h,e)};_initDensityFactor=t=>{let i=this._container;if(!i.canvas.element||!t.enable)return a.lA;let e=i.canvas.element,s=i.retina.pixelRatio;return e.width*e.height/(t.height*t.width*s**a.dm)};_removeParticle=(t,i,e)=>{let s=this._array[t];if(!s||s.group!==i)return!1;let r=this._zArray.indexOf(s);return this._array.splice(t,a.LD),this._zArray.splice(r,a.LD),s.destroy(e),this._engine.dispatchEvent(d.B.particleRemoved,{container:this._container,data:{particle:s}}),this._addToPool(s),!0}}class C{container;maxSpeed;pixelRatio;reduceFactor;sizeAnimationSpeed;constructor(t){this.container=t,this.pixelRatio=a.$x,this.reduceFactor=a.Zp}init(){let t=this.container,i=t.actualOptions;this.pixelRatio=i.detectRetina?devicePixelRatio:a.$x,this.reduceFactor=a.Zp;let e=this.pixelRatio,r=t.canvas;if(r.element){let t=r.element;r.size.width=t.offsetWidth*e,r.size.height=t.offsetHeight*e}let n=i.particles,o=n.move;this.maxSpeed=(0,s.VG)(o.gravity.maxSpeed)*e,this.sizeAnimationSpeed=(0,s.VG)(n.size.animation.speed)*e}initParticle(t){let i=t.options,e=this.pixelRatio,a=i.move,r=a.distance,n=t.retina;n.moveDrift=(0,s.VG)(a.drift)*e,n.moveSpeed=(0,s.VG)(a.speed)*e,n.sizeAnimationSpeed=(0,s.VG)(i.size.animation.speed)*e;let o=n.maxDistance;o.horizontal=void 0!==r.horizontal?r.horizontal*e:void 0,o.vertical=void 0!==r.vertical?r.vertical*e:void 0,n.maxSpeed=(0,s.VG)(a.gravity.maxSpeed)*e}}function x(t){return!t.destroyed}function D(t,i,...e){let s=new p.J(t,i);return(0,m.Z)(s,...e),s}class O{actualOptions;canvas;destroyed;fpsLimit;hdr;id;pageHidden;particleCreatedPlugins;particleDestroyedPlugins;particlePositionPlugins;particles;plugins;retina;started;zLayers;_delay;_delayTimeout;_delta={value:0,factor:0};_drawAnimationFrame;_duration;_engine;_eventListeners;_firstStart;_initialSourceOptions;_lastFrameTime;_lifeTime;_options;_paused;_smooth;_sourceOptions;constructor(t,i,e){this._engine=t,this.id=Symbol(i),this.fpsLimit=120,this.hdr=!1,this._smooth=!1,this._delay=0,this._duration=0,this._lifeTime=0,this._firstStart=!0,this.started=!1,this.destroyed=!1,this._paused=!0,this._lastFrameTime=0,this.zLayers=100,this.pageHidden=!1,this._sourceOptions=e,this._initialSourceOptions=e,this.retina=new C(this),this.canvas=new h(this,this._engine),this.particles=new S(this._engine,this),this.plugins=[],this.particleDestroyedPlugins=[],this.particleCreatedPlugins=[],this.particlePositionPlugins=[],this._options=D(this._engine,this),this.actualOptions=D(this._engine,this),this._eventListeners=new c(this),this._engine.dispatchEvent(d.B.containerBuilt,{container:this})}get animationStatus(){return!this._paused&&!this.pageHidden&&x(this)}get options(){return this._options}get sourceOptions(){return this._sourceOptions}addLifeTime(t){this._lifeTime+=t}alive(){return!this._duration||this._lifeTime<=this._duration}destroy(t=!0){if(x(this)){for(let t of(this.stop(),this.particles.destroy(),this.canvas.destroy(),this.plugins))t.destroy?.();if(this.plugins.length=0,this._engine.clearPlugins(this),this.destroyed=!0,t){let t=this._engine.items,i=t.indexOf(this);i>=a.vF&&t.splice(i,a.JC)}this._engine.dispatchEvent(d.B.containerDestroyed,{container:this})}}draw(t){if(!x(this))return;let i=t;this._drawAnimationFrame=(0,s.i0)(t=>{i&&(this._lastFrameTime=void 0,i=!1),this._nextFrame(t)})}async export(t,i={}){for(let e of this.plugins){if(!e.export)continue;let s=await e.export(t,i);if(s.supported)return s.blob}(0,b.t)().error(`Export plugin with type ${t} not found`)}async init(){if(!x(this))return;let t=new Map;for(let i of this._engine.plugins){let e=await i.getPlugin(this);e.preInit&&await e.preInit(),t.set(i,e)}for(let[i,e]of(await this.particles.initPlugins(),this._options=D(this._engine,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=D(this._engine,this,this._options),this.plugins.length=0,this.particleDestroyedPlugins.length=0,this.particleCreatedPlugins.length=0,this.particlePositionPlugins.length=0,t))i.needsPlugin(this.actualOptions)&&(this.plugins.push(e),e.particleCreated&&this.particleCreatedPlugins.push(e),e.particleDestroyed&&this.particleDestroyedPlugins.push(e),e.particlePosition&&this.particlePositionPlugins.push(e));this.retina.init(),this.canvas.init(),this.updateActualOptions(),this.canvas.initBackground(),this.canvas.resize();let{delay:i,duration:e,fpsLimit:r,hdr:n,smooth:o,zLayers:l}=this.actualOptions;for(let t of(this.hdr=n,this.zLayers=l,this._duration=(0,s.VG)(e)*a.Xu,this._delay=(0,s.VG)(i)*a.Xu,this._lifeTime=0,this.fpsLimit=r>a.DN?r:a.i8,this._smooth=o,this.plugins))await t.init?.();for(let t of(await this.particles.init(),this._engine.dispatchEvent(d.B.containerInit,{container:this}),this.particles.setDensity(),this.plugins))t.particlesSetup?.();this._engine.dispatchEvent(d.B.particlesSetup,{container:this})}pause(){if(x(this)&&(void 0!==this._drawAnimationFrame&&((0,s.px)(this._drawAnimationFrame),delete this._drawAnimationFrame),!this._paused)){for(let t of this.plugins)t.pause?.();this.pageHidden||(this._paused=!0),this._engine.dispatchEvent(d.B.containerPaused,{container:this})}}play(t){if(!x(this))return;let i=this._paused||t;if(this._firstStart&&!this.actualOptions.autoPlay){this._firstStart=!1;return}if(this._paused&&(this._paused=!1),i)for(let t of this.plugins)t.play&&t.play();this._engine.dispatchEvent(d.B.containerPlay,{container:this}),this.draw(i??!1)}async refresh(){if(x(this))return this.stop(),this.start()}async reset(t){if(x(this))return this._initialSourceOptions=t,this._sourceOptions=t,this._options=D(this._engine,this,this._initialSourceOptions,this.sourceOptions),this.actualOptions=D(this._engine,this,this._options),this.refresh()}async start(){x(this)&&!this.started&&(await this.init(),this.started=!0,await new Promise(t=>{let i=async()=>{for(let t of(this._eventListeners.addListeners(),this.plugins))await t.start?.();this._engine.dispatchEvent(d.B.containerStarted,{container:this}),this.play(),t()};this._delayTimeout=setTimeout(()=>void i(),this._delay)}))}stop(){if(x(this)&&this.started){for(let t of(this._delayTimeout&&(clearTimeout(this._delayTimeout),delete this._delayTimeout),this._firstStart=!0,this.started=!1,this._eventListeners.removeListeners(),this.pause(),this.particles.clear(),this.canvas.stop(),this.plugins))t.stop?.();this.particleCreatedPlugins.length=0,this.particleDestroyedPlugins.length=0,this.particlePositionPlugins.length=0,this._sourceOptions=this._options,this._engine.dispatchEvent(d.B.containerStopped,{container:this})}}updateActualOptions(){let t=!1;for(let i of this.plugins)i.updateActualOptions&&(t=i.updateActualOptions()||t);return t}_nextFrame=t=>{try{if(!this._smooth&&void 0!==this._lastFrameTime&&t<this._lastFrameTime+a.Xu/this.fpsLimit||(this._lastFrameTime??=t,!function(t,i,e=a.z$,s=!1){t.value=i,t.factor=s?a.z$/e:a.z$*i/a.Xu}(this._delta,t-this._lastFrameTime,this.fpsLimit,this._smooth),this.addLifeTime(this._delta.value),this._lastFrameTime=t,this._delta.value>a.Xu))return void this.draw(!1);if(this.canvas.drawParticles(this._delta),!this.alive())return void this.destroy();this.animationStatus&&this.draw(!1)}catch(t){(0,b.t)().error("error in animation loop",t)}}}}}]);
|