@tsparticles/engine 3.9.1 → 4.0.0-alpha.1
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/638.min.js +2 -0
- package/638.min.js.LICENSE.txt +1 -0
- package/browser/Core/Canvas.js +126 -181
- package/browser/Core/Container.js +22 -18
- package/browser/Core/Engine.js +64 -54
- package/browser/Core/Particle.js +43 -48
- package/browser/Core/Particles.js +33 -24
- package/browser/Core/Retina.js +2 -3
- package/browser/Core/Utils/Constants.js +2 -2
- package/browser/Core/Utils/EventListeners.js +74 -64
- package/browser/Core/Utils/QuadTree.js +1 -1
- package/browser/Core/Utils/Ranges.js +2 -2
- package/browser/Core/Utils/Vectors.js +15 -21
- package/browser/Options/Classes/AnimatableColor.js +3 -3
- package/browser/Options/Classes/AnimationOptions.js +1 -1
- package/browser/Options/Classes/ColorAnimation.js +1 -1
- package/browser/Options/Classes/Options.js +13 -10
- package/browser/Options/Classes/Particles/Move/Move.js +1 -4
- package/browser/Options/Classes/Particles/Move/MoveAngle.js +1 -1
- package/browser/Options/Classes/Particles/Move/MoveAttract.js +1 -1
- package/browser/Options/Classes/Particles/Move/MoveGravity.js +1 -1
- package/browser/Options/Classes/Particles/Move/Spin.js +1 -1
- package/browser/Options/Classes/Particles/ParticlesOptions.js +0 -6
- package/browser/Options/Classes/Particles/Stroke.js +1 -1
- package/browser/Options/Classes/ValueWithRandom.js +1 -1
- package/browser/Utils/CanvasUtils.js +65 -21
- package/browser/Utils/ColorUtils.js +61 -45
- package/browser/Utils/EventDispatcher.js +3 -1
- package/browser/Utils/LogUtils.js +22 -0
- package/browser/Utils/{NumberUtils.js → MathUtils.js} +14 -7
- package/browser/Utils/Utils.js +23 -125
- package/browser/bundle.js +3 -3
- package/browser/export-types.js +1 -99
- package/browser/exports.js +2 -9
- package/browser/index.js +3 -7
- package/browser/initEngine.js +4 -0
- package/cjs/Core/Canvas.js +136 -195
- package/cjs/Core/Container.js +57 -57
- package/cjs/Core/Engine.js +77 -71
- package/cjs/Core/Interfaces/Colors.js +1 -2
- package/cjs/Core/Interfaces/IBounds.js +1 -2
- package/cjs/Core/Interfaces/IBubbleParticleData.js +1 -2
- package/cjs/Core/Interfaces/ICircleBouncer.js +1 -2
- package/cjs/Core/Interfaces/IColorManager.js +1 -2
- package/cjs/Core/Interfaces/IContainerInteractivity.js +1 -2
- package/cjs/Core/Interfaces/IContainerPlugin.js +1 -2
- package/cjs/Core/Interfaces/ICoordinates.js +1 -2
- package/cjs/Core/Interfaces/IDelta.js +1 -2
- package/cjs/Core/Interfaces/IDimension.js +1 -2
- package/cjs/Core/Interfaces/IDistance.js +1 -2
- package/cjs/Core/Interfaces/IDrawParticleParams.js +1 -2
- package/cjs/Core/Interfaces/IEffectDrawer.js +1 -2
- package/cjs/Core/Interfaces/IExternalInteractor.js +1 -2
- package/cjs/Core/Interfaces/IInteractor.js +1 -2
- package/cjs/Core/Interfaces/ILoadParams.js +1 -2
- package/cjs/Core/Interfaces/IMouseData.js +1 -2
- package/cjs/Core/Interfaces/IMovePathGenerator.js +1 -2
- package/cjs/Core/Interfaces/IParticleColorStyle.js +1 -2
- package/cjs/Core/Interfaces/IParticleHslAnimation.js +1 -2
- package/cjs/Core/Interfaces/IParticleLife.js +1 -2
- package/cjs/Core/Interfaces/IParticleMover.js +1 -2
- package/cjs/Core/Interfaces/IParticleRetinaProps.js +1 -2
- package/cjs/Core/Interfaces/IParticleRoll.js +1 -2
- package/cjs/Core/Interfaces/IParticleTransformValues.js +1 -2
- package/cjs/Core/Interfaces/IParticleUpdater.js +1 -2
- package/cjs/Core/Interfaces/IParticleValueAnimation.js +1 -2
- package/cjs/Core/Interfaces/IParticlesInteractor.js +1 -2
- package/cjs/Core/Interfaces/IPlugin.js +1 -2
- package/cjs/Core/Interfaces/IPositionFromSizeParams.js +1 -2
- package/cjs/Core/Interfaces/IRangeValue.js +1 -2
- package/cjs/Core/Interfaces/IShapeDrawData.js +1 -2
- package/cjs/Core/Interfaces/IShapeDrawer.js +1 -2
- package/cjs/Core/Interfaces/IShapeValues.js +1 -2
- package/cjs/Core/Interfaces/ISlowParticleData.js +1 -2
- package/cjs/Core/Particle.js +99 -108
- package/cjs/Core/Particles.js +63 -58
- package/cjs/Core/Retina.js +13 -18
- package/cjs/Core/Utils/Constants.js +3 -7
- package/cjs/Core/Utils/EventListeners.js +94 -88
- package/cjs/Core/Utils/ExternalInteractorBase.js +3 -7
- package/cjs/Core/Utils/InteractionManager.js +4 -8
- package/cjs/Core/Utils/ParticlesInteractorBase.js +3 -7
- package/cjs/Core/Utils/Point.js +1 -5
- package/cjs/Core/Utils/QuadTree.js +10 -14
- package/cjs/Core/Utils/Ranges.js +14 -20
- package/cjs/Core/Utils/Vectors.js +24 -35
- package/cjs/Enums/AnimationStatus.js +2 -5
- package/cjs/Enums/Directions/MoveDirection.js +2 -5
- package/cjs/Enums/Directions/OutModeDirection.js +2 -5
- package/cjs/Enums/Directions/RotateDirection.js +2 -5
- package/cjs/Enums/InteractivityDetect.js +2 -5
- package/cjs/Enums/Modes/AnimationMode.js +2 -5
- package/cjs/Enums/Modes/LimitMode.js +2 -5
- package/cjs/Enums/Modes/OutMode.js +2 -5
- package/cjs/Enums/Modes/PixelMode.js +2 -5
- package/cjs/Enums/Modes/ResponsiveMode.js +2 -5
- package/cjs/Enums/Modes/ThemeMode.js +2 -5
- package/cjs/Enums/Types/AlterType.js +2 -5
- package/cjs/Enums/Types/DestroyType.js +2 -5
- package/cjs/Enums/Types/DivType.js +2 -5
- package/cjs/Enums/Types/EasingType.js +2 -5
- package/cjs/Enums/Types/EventType.js +2 -5
- package/cjs/Enums/Types/GradientType.js +2 -5
- package/cjs/Enums/Types/InteractorType.js +2 -5
- package/cjs/Enums/Types/ParticleOutType.js +2 -5
- package/cjs/Enums/Types/StartValueType.js +2 -5
- package/cjs/Options/Classes/AnimatableColor.js +10 -14
- package/cjs/Options/Classes/AnimationOptions.js +14 -19
- package/cjs/Options/Classes/Background/Background.js +6 -10
- package/cjs/Options/Classes/ColorAnimation.js +6 -10
- package/cjs/Options/Classes/FullScreen/FullScreen.js +3 -7
- package/cjs/Options/Classes/HslAnimation.js +7 -11
- package/cjs/Options/Classes/Interactivity/Events/ClickEvent.js +3 -7
- package/cjs/Options/Classes/Interactivity/Events/DivEvent.js +5 -9
- package/cjs/Options/Classes/Interactivity/Events/Events.js +14 -18
- package/cjs/Options/Classes/Interactivity/Events/HoverEvent.js +5 -9
- package/cjs/Options/Classes/Interactivity/Events/Parallax.js +3 -7
- package/cjs/Options/Classes/Interactivity/Events/ResizeEvent.js +3 -7
- package/cjs/Options/Classes/Interactivity/Interactivity.js +9 -13
- package/cjs/Options/Classes/Interactivity/Modes/Modes.js +3 -7
- package/cjs/Options/Classes/ManualParticle.js +10 -14
- package/cjs/Options/Classes/Options.js +41 -42
- package/cjs/Options/Classes/OptionsColor.js +5 -9
- package/cjs/Options/Classes/Particles/Bounce/ParticlesBounce.js +6 -10
- package/cjs/Options/Classes/Particles/Bounce/ParticlesBounceFactor.js +2 -6
- package/cjs/Options/Classes/Particles/Effect/Effect.js +5 -9
- package/cjs/Options/Classes/Particles/Move/Move.js +26 -33
- package/cjs/Options/Classes/Particles/Move/MoveAngle.js +6 -10
- package/cjs/Options/Classes/Particles/Move/MoveAttract.js +5 -9
- package/cjs/Options/Classes/Particles/Move/MoveCenter.js +5 -9
- package/cjs/Options/Classes/Particles/Move/MoveGravity.js +6 -10
- package/cjs/Options/Classes/Particles/Move/OutModes.js +5 -9
- package/cjs/Options/Classes/Particles/Move/Path/MovePath.js +7 -11
- package/cjs/Options/Classes/Particles/Move/Spin.js +7 -11
- package/cjs/Options/Classes/Particles/Number/ParticlesDensity.js +3 -7
- package/cjs/Options/Classes/Particles/Number/ParticlesNumber.js +7 -11
- package/cjs/Options/Classes/Particles/Number/ParticlesNumberLimit.js +5 -9
- package/cjs/Options/Classes/Particles/Opacity/Opacity.js +6 -10
- package/cjs/Options/Classes/Particles/Opacity/OpacityAnimation.js +6 -10
- package/cjs/Options/Classes/Particles/ParticlesOptions.js +29 -39
- package/cjs/Options/Classes/Particles/Shape/Shape.js +5 -9
- package/cjs/Options/Classes/Particles/Size/Size.js +6 -10
- package/cjs/Options/Classes/Particles/Size/SizeAnimation.js +6 -10
- package/cjs/Options/Classes/Particles/Stroke.js +8 -12
- package/cjs/Options/Classes/Particles/ZIndex/ZIndex.js +4 -8
- package/cjs/Options/Classes/Responsive.js +13 -17
- package/cjs/Options/Classes/Theme/Theme.js +7 -11
- package/cjs/Options/Classes/Theme/ThemeDefault.js +5 -9
- package/cjs/Options/Classes/ValueWithRandom.js +12 -18
- package/cjs/Options/Interfaces/Background/IBackground.js +1 -2
- package/cjs/Options/Interfaces/FullScreen/IFullScreen.js +1 -2
- package/cjs/Options/Interfaces/IAnimatable.js +1 -2
- package/cjs/Options/Interfaces/IAnimatableColor.js +1 -2
- package/cjs/Options/Interfaces/IAnimation.js +1 -2
- package/cjs/Options/Interfaces/IColorAnimation.js +1 -2
- package/cjs/Options/Interfaces/IHslAnimation.js +1 -2
- package/cjs/Options/Interfaces/IManualParticle.js +1 -2
- package/cjs/Options/Interfaces/IOptionLoader.js +1 -2
- package/cjs/Options/Interfaces/IOptions.js +1 -2
- package/cjs/Options/Interfaces/IOptionsColor.js +1 -2
- package/cjs/Options/Interfaces/IResponsive.js +1 -2
- package/cjs/Options/Interfaces/IValueWithRandom.js +1 -2
- package/cjs/Options/Interfaces/Interactivity/Events/IClickEvent.js +1 -2
- package/cjs/Options/Interfaces/Interactivity/Events/IDivEvent.js +1 -2
- package/cjs/Options/Interfaces/Interactivity/Events/IEvents.js +1 -2
- package/cjs/Options/Interfaces/Interactivity/Events/IHoverEvent.js +1 -2
- package/cjs/Options/Interfaces/Interactivity/Events/IParallax.js +1 -2
- package/cjs/Options/Interfaces/Interactivity/Events/IResizeEvent.js +1 -2
- package/cjs/Options/Interfaces/Interactivity/IInteractivity.js +1 -2
- package/cjs/Options/Interfaces/Interactivity/Modes/IModeDiv.js +1 -2
- package/cjs/Options/Interfaces/Interactivity/Modes/IModes.js +1 -2
- package/cjs/Options/Interfaces/Particles/Bounce/IParticlesBounce.js +1 -2
- package/cjs/Options/Interfaces/Particles/Effect/IEffect.js +1 -2
- package/cjs/Options/Interfaces/Particles/IParticlesOptions.js +1 -2
- package/cjs/Options/Interfaces/Particles/IStroke.js +1 -2
- package/cjs/Options/Interfaces/Particles/Move/IMove.js +1 -2
- package/cjs/Options/Interfaces/Particles/Move/IMoveAngle.js +1 -2
- package/cjs/Options/Interfaces/Particles/Move/IMoveAttract.js +1 -2
- package/cjs/Options/Interfaces/Particles/Move/IMoveCenter.js +1 -2
- package/cjs/Options/Interfaces/Particles/Move/IMoveGravity.js +1 -2
- package/cjs/Options/Interfaces/Particles/Move/IOutModes.js +1 -2
- package/cjs/Options/Interfaces/Particles/Move/ISpin.js +1 -2
- package/cjs/Options/Interfaces/Particles/Move/Path/IMovePath.js +1 -2
- package/cjs/Options/Interfaces/Particles/Number/IParticlesDensity.js +1 -2
- package/cjs/Options/Interfaces/Particles/Number/IParticlesNumber.js +1 -2
- package/cjs/Options/Interfaces/Particles/Number/IParticlesNumberLimit.js +1 -2
- package/cjs/Options/Interfaces/Particles/Opacity/IOpacity.js +1 -2
- package/cjs/Options/Interfaces/Particles/Opacity/IOpacityAnimation.js +1 -2
- package/cjs/Options/Interfaces/Particles/Shape/IShape.js +1 -2
- package/cjs/Options/Interfaces/Particles/Size/ISize.js +1 -2
- package/cjs/Options/Interfaces/Particles/Size/ISizeAnimation.js +1 -2
- package/cjs/Options/Interfaces/Particles/ZIndex/IZIndex.js +1 -2
- package/cjs/Options/Interfaces/Theme/ITheme.js +1 -2
- package/cjs/Options/Interfaces/Theme/IThemeDefault.js +1 -2
- package/cjs/Types/CustomEventArgs.js +1 -2
- package/cjs/Types/CustomEventListener.js +1 -2
- package/cjs/Types/EasingFunction.js +1 -2
- package/cjs/Types/ExportResult.js +1 -2
- package/cjs/Types/ISourceOptions.js +1 -2
- package/cjs/Types/ParticlesGroups.js +1 -2
- package/cjs/Types/PathOptions.js +1 -2
- package/cjs/Types/RangeValue.js +1 -2
- package/cjs/Types/RecursivePartial.js +1 -2
- package/cjs/Types/ShapeData.js +1 -2
- package/cjs/Types/SingleOrMultiple.js +1 -2
- package/cjs/Utils/CanvasUtils.js +86 -55
- package/cjs/Utils/ColorUtils.js +136 -141
- package/cjs/Utils/EventDispatcher.js +8 -10
- package/cjs/Utils/LogUtils.js +22 -0
- package/{esm/Utils/NumberUtils.js → cjs/Utils/MathUtils.js} +14 -7
- package/cjs/Utils/OptionsUtils.js +4 -8
- package/cjs/Utils/TypeUtils.js +7 -16
- package/cjs/Utils/Utils.js +104 -239
- package/cjs/bundle.js +5 -22
- package/cjs/export-types.js +1 -115
- package/cjs/exports.js +77 -100
- package/cjs/index.js +5 -26
- package/cjs/initEngine.js +4 -0
- package/dist_browser_Core_Container_js.js +102 -0
- package/esm/Core/Canvas.js +126 -181
- package/esm/Core/Container.js +22 -18
- package/esm/Core/Engine.js +64 -54
- package/esm/Core/Particle.js +43 -48
- package/esm/Core/Particles.js +33 -24
- package/esm/Core/Retina.js +2 -3
- package/esm/Core/Utils/Constants.js +2 -2
- package/esm/Core/Utils/EventListeners.js +74 -64
- package/esm/Core/Utils/QuadTree.js +1 -1
- package/esm/Core/Utils/Ranges.js +2 -2
- package/esm/Core/Utils/Vectors.js +15 -21
- package/esm/Enums/RangeType.js +5 -0
- package/esm/Options/Classes/AnimatableColor.js +3 -3
- package/esm/Options/Classes/AnimationOptions.js +1 -1
- package/esm/Options/Classes/ColorAnimation.js +1 -1
- package/esm/Options/Classes/Options.js +13 -10
- package/esm/Options/Classes/Particles/Move/Move.js +1 -4
- package/esm/Options/Classes/Particles/Move/MoveAngle.js +1 -1
- package/esm/Options/Classes/Particles/Move/MoveAttract.js +1 -1
- package/esm/Options/Classes/Particles/Move/MoveGravity.js +1 -1
- package/esm/Options/Classes/Particles/Move/Spin.js +1 -1
- package/esm/Options/Classes/Particles/ParticlesOptions.js +0 -6
- package/esm/Options/Classes/Particles/Stroke.js +1 -1
- package/esm/Options/Classes/ValueWithRandom.js +1 -1
- package/esm/Utils/CanvasUtils.js +65 -21
- package/esm/Utils/ColorUtils.js +61 -45
- package/esm/Utils/EventDispatcher.js +3 -1
- package/esm/Utils/LogUtils.js +22 -0
- package/esm/Utils/MathUtils.js +158 -0
- package/esm/Utils/Utils.js +23 -125
- package/esm/bundle.js +3 -3
- package/esm/export-types.js +1 -99
- package/esm/exports.js +2 -9
- package/esm/index.js +3 -7
- package/esm/initEngine.js +4 -0
- package/package.json +3 -2
- package/report.html +5 -4
- package/scripts/install.js +204 -118
- package/tsparticles.engine.js +492 -451
- package/tsparticles.engine.min.js +1 -1
- package/tsparticles.engine.min.js.LICENSE.txt +1 -1
- package/types/Core/Canvas.d.ts +6 -9
- package/types/Core/Container.d.ts +1 -0
- package/types/Core/Engine.d.ts +20 -16
- package/types/Core/Interfaces/Colors.d.ts +46 -2
- package/types/Core/Interfaces/IColorManager.d.ts +1 -1
- package/types/Core/Interfaces/IContainerPlugin.d.ts +4 -0
- package/types/Core/Interfaces/IDrawParticleParams.d.ts +0 -4
- package/types/Core/Interfaces/IEffectDrawer.d.ts +2 -1
- package/types/Core/Interfaces/IShapeDrawData.d.ts +2 -0
- package/types/Core/Interfaces/IShapeDrawer.d.ts +1 -0
- package/types/Core/Particle.d.ts +4 -5
- package/types/Core/Particles.d.ts +1 -1
- package/types/Core/Utils/Constants.d.ts +2 -2
- package/types/Core/Utils/EventListeners.d.ts +1 -0
- package/types/Core/Utils/Vectors.d.ts +3 -3
- package/types/Options/Classes/Options.d.ts +1 -2
- package/types/Options/Classes/OptionsColor.d.ts +2 -2
- package/types/Options/Classes/Particles/Move/Move.d.ts +0 -2
- package/types/Options/Classes/Particles/ParticlesOptions.d.ts +0 -4
- package/types/Options/Interfaces/IOptions.d.ts +1 -2
- package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +0 -4
- package/types/Options/Interfaces/Particles/Move/IMove.d.ts +0 -2
- package/types/Utils/CanvasUtils.d.ts +4 -1
- package/types/Utils/ColorUtils.d.ts +2 -2
- package/types/Utils/LogUtils.d.ts +11 -0
- package/types/Utils/{NumberUtils.d.ts → MathUtils.d.ts} +2 -1
- package/types/Utils/TypeUtils.d.ts +2 -2
- package/types/Utils/Utils.d.ts +4 -16
- package/types/export-types.d.ts +91 -101
- package/types/exports.d.ts +2 -9
- package/types/index.d.ts +1 -1
- package/types/initEngine.d.ts +2 -0
- package/umd/Core/Canvas.js +123 -178
- package/umd/Core/Container.js +25 -21
- package/umd/Core/Engine.js +97 -53
- package/umd/Core/Particle.js +54 -59
- package/umd/Core/Particles.js +33 -24
- package/umd/Core/Retina.js +9 -10
- package/umd/Core/Utils/Constants.js +3 -3
- package/umd/Core/Utils/EventListeners.js +72 -62
- package/umd/Core/Utils/QuadTree.js +3 -3
- package/umd/Core/Utils/Ranges.js +4 -4
- package/umd/Core/Utils/Vectors.js +15 -21
- package/umd/Options/Classes/AnimatableColor.js +3 -3
- package/umd/Options/Classes/AnimationOptions.js +6 -6
- package/umd/Options/Classes/ColorAnimation.js +3 -3
- package/umd/Options/Classes/Options.js +16 -13
- package/umd/Options/Classes/Particles/Move/Move.js +5 -8
- package/umd/Options/Classes/Particles/Move/MoveAngle.js +4 -4
- package/umd/Options/Classes/Particles/Move/MoveAttract.js +3 -3
- package/umd/Options/Classes/Particles/Move/MoveGravity.js +4 -4
- package/umd/Options/Classes/Particles/Move/Spin.js +3 -3
- package/umd/Options/Classes/Particles/ParticlesOptions.js +1 -7
- package/umd/Options/Classes/Particles/Stroke.js +4 -4
- package/umd/Options/Classes/ValueWithRandom.js +3 -3
- package/umd/Utils/CanvasUtils.js +69 -22
- package/umd/Utils/ColorUtils.js +72 -56
- package/umd/Utils/EventDispatcher.js +3 -1
- package/umd/Utils/LogUtils.js +36 -0
- package/umd/Utils/{NumberUtils.js → MathUtils.js} +16 -8
- package/umd/Utils/Utils.js +36 -141
- package/umd/bundle.js +4 -4
- package/umd/export-types.js +1 -114
- package/umd/exports.js +3 -10
- package/umd/index.js +4 -8
- package/umd/{init.js → initEngine.js} +3 -5
- package/browser/Core/Interfaces/IRectSideResult.js +0 -1
- package/browser/Core/Interfaces/ITrailFillData.js +0 -1
- package/browser/Enums/Modes/CollisionMode.js +0 -6
- package/browser/Options/Classes/BackgroundMask/BackgroundMask.js +0 -24
- package/browser/Options/Classes/BackgroundMask/BackgroundMaskCover.js +0 -21
- package/browser/Options/Classes/Particles/Collisions/Collisions.js +0 -33
- package/browser/Options/Classes/Particles/Collisions/CollisionsAbsorb.js +0 -14
- package/browser/Options/Classes/Particles/Collisions/CollisionsOverlap.js +0 -18
- package/browser/Options/Classes/Particles/Move/MoveTrail.js +0 -23
- package/browser/Options/Classes/Particles/Move/MoveTrailFill.js +0 -15
- package/browser/Options/Classes/Particles/Shadow.js +0 -35
- package/browser/Options/Interfaces/BackgroundMask/IBackgroundMask.js +0 -1
- package/browser/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.js +0 -1
- package/browser/Options/Interfaces/Particles/Collisions/ICollisions.js +0 -1
- package/browser/Options/Interfaces/Particles/Collisions/ICollisionsAbsorb.js +0 -1
- package/browser/Options/Interfaces/Particles/Collisions/ICollisionsOverlap.js +0 -1
- package/browser/Options/Interfaces/Particles/IShadow.js +0 -1
- package/browser/Options/Interfaces/Particles/Move/IMoveTrail.js +0 -1
- package/browser/Options/Interfaces/Particles/Move/IMoveTrailFill.js +0 -1
- package/browser/init.js +0 -6
- package/cjs/Core/Interfaces/IRectSideResult.js +0 -2
- package/cjs/Core/Interfaces/ITrailFillData.js +0 -2
- package/cjs/Enums/Modes/CollisionMode.js +0 -9
- package/cjs/Options/Classes/BackgroundMask/BackgroundMask.js +0 -28
- package/cjs/Options/Classes/BackgroundMask/BackgroundMaskCover.js +0 -25
- package/cjs/Options/Classes/Particles/Collisions/Collisions.js +0 -37
- package/cjs/Options/Classes/Particles/Collisions/CollisionsAbsorb.js +0 -18
- package/cjs/Options/Classes/Particles/Collisions/CollisionsOverlap.js +0 -22
- package/cjs/Options/Classes/Particles/Move/MoveTrail.js +0 -27
- package/cjs/Options/Classes/Particles/Move/MoveTrailFill.js +0 -19
- package/cjs/Options/Classes/Particles/Shadow.js +0 -39
- package/cjs/Options/Interfaces/BackgroundMask/IBackgroundMask.js +0 -2
- package/cjs/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.js +0 -2
- package/cjs/Options/Interfaces/Particles/Collisions/ICollisions.js +0 -2
- package/cjs/Options/Interfaces/Particles/Collisions/ICollisionsAbsorb.js +0 -2
- package/cjs/Options/Interfaces/Particles/Collisions/ICollisionsOverlap.js +0 -2
- package/cjs/Options/Interfaces/Particles/IShadow.js +0 -2
- package/cjs/Options/Interfaces/Particles/Move/IMoveTrail.js +0 -2
- package/cjs/Options/Interfaces/Particles/Move/IMoveTrailFill.js +0 -2
- package/cjs/Types/RangeType.js +0 -8
- package/cjs/Utils/NumberUtils.js +0 -177
- package/cjs/init.js +0 -9
- package/esm/Core/Interfaces/IRectSideResult.js +0 -1
- package/esm/Core/Interfaces/ITrailFillData.js +0 -1
- package/esm/Enums/Modes/CollisionMode.js +0 -6
- package/esm/Options/Classes/BackgroundMask/BackgroundMask.js +0 -24
- package/esm/Options/Classes/BackgroundMask/BackgroundMaskCover.js +0 -21
- package/esm/Options/Classes/Particles/Collisions/Collisions.js +0 -33
- package/esm/Options/Classes/Particles/Collisions/CollisionsAbsorb.js +0 -14
- package/esm/Options/Classes/Particles/Collisions/CollisionsOverlap.js +0 -18
- package/esm/Options/Classes/Particles/Move/MoveTrail.js +0 -23
- package/esm/Options/Classes/Particles/Move/MoveTrailFill.js +0 -15
- package/esm/Options/Classes/Particles/Shadow.js +0 -35
- package/esm/Options/Interfaces/BackgroundMask/IBackgroundMask.js +0 -1
- package/esm/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.js +0 -1
- package/esm/Options/Interfaces/Particles/Collisions/ICollisions.js +0 -1
- package/esm/Options/Interfaces/Particles/Collisions/ICollisionsAbsorb.js +0 -1
- package/esm/Options/Interfaces/Particles/Collisions/ICollisionsOverlap.js +0 -1
- package/esm/Options/Interfaces/Particles/IShadow.js +0 -1
- package/esm/Options/Interfaces/Particles/Move/IMoveTrail.js +0 -1
- package/esm/Options/Interfaces/Particles/Move/IMoveTrailFill.js +0 -1
- package/esm/init.js +0 -6
- package/types/Core/Interfaces/IRectSideResult.d.ts +0 -5
- package/types/Core/Interfaces/ITrailFillData.d.ts +0 -6
- package/types/Enums/Modes/CollisionMode.d.ts +0 -5
- package/types/Options/Classes/BackgroundMask/BackgroundMask.d.ts +0 -11
- package/types/Options/Classes/BackgroundMask/BackgroundMaskCover.d.ts +0 -11
- package/types/Options/Classes/Particles/Collisions/Collisions.d.ts +0 -18
- package/types/Options/Classes/Particles/Collisions/CollisionsAbsorb.d.ts +0 -8
- package/types/Options/Classes/Particles/Collisions/CollisionsOverlap.d.ts +0 -9
- package/types/Options/Classes/Particles/Move/MoveTrail.d.ts +0 -11
- package/types/Options/Classes/Particles/Move/MoveTrailFill.d.ts +0 -9
- package/types/Options/Classes/Particles/Shadow.d.ts +0 -13
- package/types/Options/Interfaces/BackgroundMask/IBackgroundMask.d.ts +0 -8
- package/types/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.d.ts +0 -6
- package/types/Options/Interfaces/Particles/Collisions/ICollisions.d.ts +0 -13
- package/types/Options/Interfaces/Particles/Collisions/ICollisionsAbsorb.d.ts +0 -3
- package/types/Options/Interfaces/Particles/Collisions/ICollisionsOverlap.d.ts +0 -4
- package/types/Options/Interfaces/Particles/IShadow.d.ts +0 -8
- package/types/Options/Interfaces/Particles/Move/IMoveTrail.d.ts +0 -6
- package/types/Options/Interfaces/Particles/Move/IMoveTrailFill.d.ts +0 -5
- package/types/init.d.ts +0 -2
- package/umd/Core/Interfaces/IRectSideResult.js +0 -12
- package/umd/Core/Interfaces/ITrailFillData.js +0 -12
- package/umd/Enums/Modes/CollisionMode.js +0 -19
- package/umd/Options/Classes/BackgroundMask/BackgroundMask.js +0 -38
- package/umd/Options/Classes/BackgroundMask/BackgroundMaskCover.js +0 -35
- package/umd/Options/Classes/Particles/Collisions/Collisions.js +0 -47
- package/umd/Options/Classes/Particles/Collisions/CollisionsAbsorb.js +0 -28
- package/umd/Options/Classes/Particles/Collisions/CollisionsOverlap.js +0 -32
- package/umd/Options/Classes/Particles/Move/MoveTrail.js +0 -37
- package/umd/Options/Classes/Particles/Move/MoveTrailFill.js +0 -29
- package/umd/Options/Classes/Particles/Shadow.js +0 -49
- package/umd/Options/Interfaces/BackgroundMask/IBackgroundMask.js +0 -12
- package/umd/Options/Interfaces/BackgroundMask/IBackgroundMaskCover.js +0 -12
- package/umd/Options/Interfaces/Particles/Collisions/ICollisions.js +0 -12
- package/umd/Options/Interfaces/Particles/Collisions/ICollisionsAbsorb.js +0 -12
- package/umd/Options/Interfaces/Particles/Collisions/ICollisionsOverlap.js +0 -12
- package/umd/Options/Interfaces/Particles/IShadow.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMoveTrail.js +0 -12
- package/umd/Options/Interfaces/Particles/Move/IMoveTrailFill.js +0 -12
- /package/browser/{Types → Enums}/RangeType.js +0 -0
- /package/{esm/Types → cjs/Enums}/RangeType.js +0 -0
- /package/types/{Types → Enums}/RangeType.d.ts +0 -0
- /package/umd/{Types → Enums}/RangeType.js +0 -0
package/umd/Core/Engine.js
CHANGED
|
@@ -1,21 +1,55 @@
|
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
if (k2 === undefined) k2 = k;
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
13
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
14
|
+
}) : function(o, v) {
|
|
15
|
+
o["default"] = v;
|
|
16
|
+
});
|
|
17
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
18
|
+
var ownKeys = function(o) {
|
|
19
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
20
|
+
var ar = [];
|
|
21
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
22
|
+
return ar;
|
|
23
|
+
};
|
|
24
|
+
return ownKeys(o);
|
|
25
|
+
};
|
|
26
|
+
return function (mod) {
|
|
27
|
+
if (mod && mod.__esModule) return mod;
|
|
28
|
+
var result = {};
|
|
29
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
30
|
+
__setModuleDefault(result, mod);
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
})();
|
|
1
34
|
(function (factory) {
|
|
2
35
|
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
36
|
var v = factory(require, exports);
|
|
4
37
|
if (v !== undefined) module.exports = v;
|
|
5
38
|
}
|
|
6
39
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./Utils/Constants.js", "../Utils/Utils.js", "
|
|
40
|
+
define(["require", "exports", "./Utils/Constants.js", "../Utils/Utils.js", "../Utils/EventDispatcher.js", "../Enums/Types/EventType.js", "../Utils/LogUtils.js", "../Utils/MathUtils.js"], factory);
|
|
8
41
|
}
|
|
9
42
|
})(function (require, exports) {
|
|
10
43
|
"use strict";
|
|
44
|
+
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
|
|
11
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
46
|
exports.Engine = void 0;
|
|
13
47
|
const Constants_js_1 = require("./Utils/Constants.js");
|
|
14
48
|
const Utils_js_1 = require("../Utils/Utils.js");
|
|
15
|
-
const Container_js_1 = require("./Container.js");
|
|
16
49
|
const EventDispatcher_js_1 = require("../Utils/EventDispatcher.js");
|
|
17
50
|
const EventType_js_1 = require("../Enums/Types/EventType.js");
|
|
18
|
-
const
|
|
51
|
+
const LogUtils_js_1 = require("../Utils/LogUtils.js");
|
|
52
|
+
const MathUtils_js_1 = require("../Utils/MathUtils.js");
|
|
19
53
|
async function getItemsFromInitializer(container, map, initializers, force = false) {
|
|
20
54
|
let res = map.get(container);
|
|
21
55
|
if (!res || force) {
|
|
@@ -33,25 +67,23 @@
|
|
|
33
67
|
if (response.ok) {
|
|
34
68
|
return (await response.json());
|
|
35
69
|
}
|
|
36
|
-
(0,
|
|
70
|
+
(0, LogUtils_js_1.getLogger)().error(`${response.status.toString()} while retrieving config file`);
|
|
37
71
|
return data.fallback;
|
|
38
72
|
}
|
|
39
73
|
const getCanvasFromContainer = (domContainer) => {
|
|
40
74
|
let canvasEl;
|
|
41
75
|
if (domContainer instanceof HTMLCanvasElement || domContainer.tagName.toLowerCase() === Constants_js_1.canvasTag) {
|
|
42
76
|
canvasEl = domContainer;
|
|
43
|
-
|
|
44
|
-
canvasEl.dataset[Constants_js_1.generatedAttribute] = Constants_js_1.generatedFalse;
|
|
45
|
-
}
|
|
77
|
+
canvasEl.dataset[Constants_js_1.generatedAttribute] ??= Constants_js_1.generatedFalse;
|
|
46
78
|
}
|
|
47
79
|
else {
|
|
48
|
-
const existingCanvases = domContainer.getElementsByTagName(Constants_js_1.canvasTag);
|
|
49
|
-
if (
|
|
50
|
-
canvasEl =
|
|
80
|
+
const existingCanvases = domContainer.getElementsByTagName(Constants_js_1.canvasTag), foundCanvas = existingCanvases[Constants_js_1.canvasFirstIndex];
|
|
81
|
+
if (foundCanvas) {
|
|
82
|
+
canvasEl = foundCanvas;
|
|
51
83
|
canvasEl.dataset[Constants_js_1.generatedAttribute] = Constants_js_1.generatedFalse;
|
|
52
84
|
}
|
|
53
85
|
else {
|
|
54
|
-
canvasEl =
|
|
86
|
+
canvasEl = (0, Utils_js_1.safeDocument)().createElement(Constants_js_1.canvasTag);
|
|
55
87
|
canvasEl.dataset[Constants_js_1.generatedAttribute] = Constants_js_1.generatedTrue;
|
|
56
88
|
domContainer.appendChild(canvasEl);
|
|
57
89
|
}
|
|
@@ -65,14 +97,14 @@
|
|
|
65
97
|
}
|
|
66
98
|
return canvasEl;
|
|
67
99
|
}, getDomContainer = (id, source) => {
|
|
68
|
-
let domContainer = source ??
|
|
100
|
+
let domContainer = source ?? (0, Utils_js_1.safeDocument)().getElementById(id);
|
|
69
101
|
if (domContainer) {
|
|
70
102
|
return domContainer;
|
|
71
103
|
}
|
|
72
|
-
domContainer =
|
|
104
|
+
domContainer = (0, Utils_js_1.safeDocument)().createElement("div");
|
|
73
105
|
domContainer.id = id;
|
|
74
106
|
domContainer.dataset[Constants_js_1.generatedAttribute] = Constants_js_1.generatedTrue;
|
|
75
|
-
|
|
107
|
+
(0, Utils_js_1.safeDocument)().body.append(domContainer);
|
|
76
108
|
return domContainer;
|
|
77
109
|
};
|
|
78
110
|
class Engine {
|
|
@@ -81,6 +113,7 @@
|
|
|
81
113
|
this._domArray = [];
|
|
82
114
|
this._eventDispatcher = new EventDispatcher_js_1.EventDispatcher();
|
|
83
115
|
this._initialized = false;
|
|
116
|
+
this._loadPromises = new Set();
|
|
84
117
|
this.plugins = [];
|
|
85
118
|
this.colorManagers = new Map();
|
|
86
119
|
this.easingFunctions = new Map();
|
|
@@ -108,73 +141,65 @@
|
|
|
108
141
|
return this._domArray;
|
|
109
142
|
}
|
|
110
143
|
get version() {
|
|
111
|
-
return "
|
|
144
|
+
return "4.0.0-alpha.1";
|
|
112
145
|
}
|
|
113
|
-
|
|
146
|
+
addColorManager(manager) {
|
|
114
147
|
this.colorManagers.set(manager.key, manager);
|
|
115
|
-
await this.refresh(refresh);
|
|
116
148
|
}
|
|
117
149
|
addConfig(config) {
|
|
118
150
|
const key = config.key ?? config.name ?? "default";
|
|
119
151
|
this._configs.set(key, config);
|
|
120
152
|
this._eventDispatcher.dispatchEvent(EventType_js_1.EventType.configAdded, { data: { name: key, config } });
|
|
121
153
|
}
|
|
122
|
-
|
|
123
|
-
if (this.
|
|
154
|
+
addEasing(name, easing) {
|
|
155
|
+
if (this.easingFunctions.get(name)) {
|
|
124
156
|
return;
|
|
125
157
|
}
|
|
126
158
|
this.easingFunctions.set(name, easing);
|
|
127
|
-
await this.refresh(refresh);
|
|
128
159
|
}
|
|
129
|
-
|
|
130
|
-
(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
});
|
|
135
|
-
await this.refresh(refresh);
|
|
160
|
+
addEffect(effect, drawer) {
|
|
161
|
+
if (this.getEffectDrawer(effect)) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
this.effectDrawers.set(effect, drawer);
|
|
136
165
|
}
|
|
137
166
|
addEventListener(type, listener) {
|
|
138
167
|
this._eventDispatcher.addEventListener(type, listener);
|
|
139
168
|
}
|
|
140
|
-
|
|
169
|
+
addInteractor(name, interactorInitializer) {
|
|
141
170
|
this._initializers.interactors.set(name, interactorInitializer);
|
|
142
|
-
await this.refresh(refresh);
|
|
143
171
|
}
|
|
144
|
-
|
|
172
|
+
addMover(name, moverInitializer) {
|
|
145
173
|
this._initializers.movers.set(name, moverInitializer);
|
|
146
|
-
await this.refresh(refresh);
|
|
147
174
|
}
|
|
148
|
-
|
|
175
|
+
addParticleUpdater(name, updaterInitializer) {
|
|
149
176
|
this._initializers.updaters.set(name, updaterInitializer);
|
|
150
|
-
await this.refresh(refresh);
|
|
151
177
|
}
|
|
152
|
-
|
|
153
|
-
if (
|
|
154
|
-
|
|
178
|
+
addPathGenerator(name, generator) {
|
|
179
|
+
if (this.getPathGenerator(name)) {
|
|
180
|
+
return;
|
|
155
181
|
}
|
|
156
|
-
|
|
182
|
+
this.pathGenerators.set(name, generator);
|
|
157
183
|
}
|
|
158
|
-
|
|
159
|
-
if (
|
|
160
|
-
|
|
184
|
+
addPlugin(plugin) {
|
|
185
|
+
if (this.getPlugin(plugin.id)) {
|
|
186
|
+
return;
|
|
161
187
|
}
|
|
162
|
-
|
|
188
|
+
this.plugins.push(plugin);
|
|
163
189
|
}
|
|
164
|
-
|
|
165
|
-
if (override || !this.getPreset(preset)) {
|
|
166
|
-
|
|
190
|
+
addPreset(preset, options, override = false) {
|
|
191
|
+
if (!(override || !this.getPreset(preset))) {
|
|
192
|
+
return;
|
|
167
193
|
}
|
|
168
|
-
|
|
194
|
+
this.presets.set(preset, options);
|
|
169
195
|
}
|
|
170
|
-
|
|
196
|
+
addShape(drawer) {
|
|
171
197
|
for (const validType of drawer.validTypes) {
|
|
172
198
|
if (this.getShapeDrawer(validType)) {
|
|
173
199
|
continue;
|
|
174
200
|
}
|
|
175
201
|
this.shapeDrawers.set(validType, drawer);
|
|
176
202
|
}
|
|
177
|
-
await this.refresh(refresh);
|
|
178
203
|
}
|
|
179
204
|
checkVersion(pluginVersion) {
|
|
180
205
|
if (this.version === pluginVersion) {
|
|
@@ -238,22 +263,29 @@
|
|
|
238
263
|
async getUpdaters(container, force = false) {
|
|
239
264
|
return getItemsFromInitializer(container, this.updaters, this._initializers.updaters, force);
|
|
240
265
|
}
|
|
241
|
-
init() {
|
|
266
|
+
async init() {
|
|
242
267
|
if (this._initialized) {
|
|
243
268
|
return;
|
|
244
269
|
}
|
|
270
|
+
for (const loadPromise of this._loadPromises) {
|
|
271
|
+
await loadPromise(this);
|
|
272
|
+
}
|
|
273
|
+
this._loadPromises.clear();
|
|
245
274
|
this._initialized = true;
|
|
246
275
|
}
|
|
247
276
|
item(index) {
|
|
248
277
|
const { items } = this, item = items[index];
|
|
249
|
-
if (
|
|
278
|
+
if (item?.destroyed) {
|
|
250
279
|
items.splice(index, Constants_js_1.removeDeleteCount);
|
|
251
280
|
return;
|
|
252
281
|
}
|
|
253
282
|
return item;
|
|
254
283
|
}
|
|
255
284
|
async load(params) {
|
|
256
|
-
|
|
285
|
+
await this.init();
|
|
286
|
+
const { Container } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./Container.js"))) : new Promise((resolve_1, reject_1) => { require(["./Container.js"], resolve_1, reject_1); }).then(__importStar)), id = params.id ??
|
|
287
|
+
params.element?.id ??
|
|
288
|
+
`tsparticles${Math.floor((0, MathUtils_js_1.getRandom)() * Constants_js_1.loadRandomFactor).toString()}`, { index, url } = params, options = url ? await getDataFromUrl({ fallback: params.options, url, index }) : params.options, currentOptions = (0, Utils_js_1.itemFromSingleOrMultiple)(options, index), { items } = this, oldIndex = items.findIndex(v => v.id.description === id), newItem = new Container(this, id, currentOptions);
|
|
257
289
|
if (oldIndex >= Constants_js_1.loadMinIndex) {
|
|
258
290
|
const old = this.item(oldIndex), deleteCount = old ? Constants_js_1.one : Constants_js_1.none;
|
|
259
291
|
if (old && !old.destroyed) {
|
|
@@ -270,7 +302,9 @@
|
|
|
270
302
|
return newItem;
|
|
271
303
|
}
|
|
272
304
|
loadOptions(options, sourceOptions) {
|
|
273
|
-
this.plugins.forEach(plugin =>
|
|
305
|
+
this.plugins.forEach(plugin => {
|
|
306
|
+
plugin.loadOptions(options, sourceOptions);
|
|
307
|
+
});
|
|
274
308
|
}
|
|
275
309
|
loadParticlesOptions(container, options, ...sourceOptions) {
|
|
276
310
|
const updaters = this.updaters.get(container);
|
|
@@ -285,15 +319,25 @@
|
|
|
285
319
|
}
|
|
286
320
|
await Promise.all(this.items.map(t => t.refresh()));
|
|
287
321
|
}
|
|
322
|
+
register(...loadPromises) {
|
|
323
|
+
if (this._initialized) {
|
|
324
|
+
throw new Error(`Register plugins can only be done before calling tsParticles.load()`);
|
|
325
|
+
}
|
|
326
|
+
for (const loadPromise of loadPromises) {
|
|
327
|
+
this._loadPromises.add(loadPromise);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
288
330
|
removeEventListener(type, listener) {
|
|
289
331
|
this._eventDispatcher.removeEventListener(type, listener);
|
|
290
332
|
}
|
|
291
333
|
setOnClickHandler(callback) {
|
|
292
334
|
const { items } = this;
|
|
293
335
|
if (!items.length) {
|
|
294
|
-
throw new Error(
|
|
336
|
+
throw new Error("Click handlers can only be set after calling tsParticles.load()");
|
|
295
337
|
}
|
|
296
|
-
items.forEach(item =>
|
|
338
|
+
items.forEach(item => {
|
|
339
|
+
item.addClickHandler(callback);
|
|
340
|
+
});
|
|
297
341
|
}
|
|
298
342
|
}
|
|
299
343
|
exports.Engine = Engine;
|
package/umd/Core/Particle.js
CHANGED
|
@@ -4,30 +4,26 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./Utils/Vectors.js", "../Utils/
|
|
7
|
+
define(["require", "exports", "./Utils/Vectors.js", "../Utils/MathUtils.js", "./Utils/Constants.js", "../Utils/Utils.js", "../Enums/Types/EventType.js", "../Options/Classes/Interactivity/Interactivity.js", "../Enums/Directions/MoveDirection.js", "../Enums/Modes/OutMode.js", "../Enums/Types/ParticleOutType.js", "../Utils/CanvasUtils.js", "../Utils/ColorUtils.js", "../Utils/OptionsUtils.js"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
"use strict";
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Particle = void 0;
|
|
13
13
|
const Vectors_js_1 = require("./Utils/Vectors.js");
|
|
14
|
-
const
|
|
14
|
+
const MathUtils_js_1 = require("../Utils/MathUtils.js");
|
|
15
15
|
const Constants_js_1 = require("./Utils/Constants.js");
|
|
16
16
|
const Utils_js_1 = require("../Utils/Utils.js");
|
|
17
|
-
const ColorUtils_js_1 = require("../Utils/ColorUtils.js");
|
|
18
17
|
const EventType_js_1 = require("../Enums/Types/EventType.js");
|
|
19
18
|
const Interactivity_js_1 = require("../Options/Classes/Interactivity/Interactivity.js");
|
|
20
19
|
const MoveDirection_js_1 = require("../Enums/Directions/MoveDirection.js");
|
|
21
20
|
const OutMode_js_1 = require("../Enums/Modes/OutMode.js");
|
|
22
21
|
const ParticleOutType_js_1 = require("../Enums/Types/ParticleOutType.js");
|
|
23
|
-
const PixelMode_js_1 = require("../Enums/Modes/PixelMode.js");
|
|
24
22
|
const CanvasUtils_js_1 = require("../Utils/CanvasUtils.js");
|
|
23
|
+
const ColorUtils_js_1 = require("../Utils/ColorUtils.js");
|
|
25
24
|
const OptionsUtils_js_1 = require("../Utils/OptionsUtils.js");
|
|
26
25
|
function loadEffectData(effect, effectOptions, id, reduceDuplicates) {
|
|
27
26
|
const effectData = effectOptions.options[effect];
|
|
28
|
-
if (!effectData) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
27
|
return (0, Utils_js_1.deepExtend)({
|
|
32
28
|
close: effectOptions.close,
|
|
33
29
|
fill: effectOptions.fill,
|
|
@@ -35,9 +31,6 @@
|
|
|
35
31
|
}
|
|
36
32
|
function loadShapeData(shape, shapeOptions, id, reduceDuplicates) {
|
|
37
33
|
const shapeData = shapeOptions.options[shape];
|
|
38
|
-
if (!shapeData) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
34
|
return (0, Utils_js_1.deepExtend)({
|
|
42
35
|
close: shapeOptions.close,
|
|
43
36
|
fill: shapeOptions.fill,
|
|
@@ -59,13 +52,14 @@
|
|
|
59
52
|
constructor(engine, container) {
|
|
60
53
|
this.container = container;
|
|
61
54
|
this._calcPosition = (container, position, zIndex, tryCount = Constants_js_1.defaultRetryCount) => {
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
const plugins = container.plugins.values();
|
|
56
|
+
for (const plugin of plugins) {
|
|
57
|
+
const pluginPos = plugin.particlePosition?.(position, this);
|
|
64
58
|
if (pluginPos) {
|
|
65
59
|
return Vectors_js_1.Vector3d.create(pluginPos.x, pluginPos.y, zIndex);
|
|
66
60
|
}
|
|
67
61
|
}
|
|
68
|
-
const canvasSize = container.canvas.size, exactPosition = (0,
|
|
62
|
+
const canvasSize = container.canvas.size, exactPosition = (0, MathUtils_js_1.calcExactPositionOrRandomFromSize)({
|
|
69
63
|
size: canvasSize,
|
|
70
64
|
position: position,
|
|
71
65
|
}), pos = Vectors_js_1.Vector3d.create(exactPosition.x, exactPosition.y, zIndex), radius = this.getRadius(), outModes = this.options.move.outModes, fixHorizontal = (outMode) => {
|
|
@@ -91,48 +85,40 @@
|
|
|
91
85
|
fixHorizontal(outModes.right ?? outModes.default);
|
|
92
86
|
fixVertical(outModes.top ?? outModes.default);
|
|
93
87
|
fixVertical(outModes.bottom ?? outModes.default);
|
|
94
|
-
|
|
88
|
+
let isValidPosition = true;
|
|
89
|
+
for (const plugin of plugins) {
|
|
90
|
+
isValidPosition = plugin.checkParticlePosition?.(this, pos, tryCount);
|
|
91
|
+
if (isValidPosition === false) {
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (!isValidPosition) {
|
|
95
96
|
return this._calcPosition(container, undefined, zIndex, tryCount + Constants_js_1.tryCountIncrement);
|
|
96
97
|
}
|
|
97
98
|
return pos;
|
|
98
99
|
};
|
|
99
100
|
this._calculateVelocity = () => {
|
|
100
|
-
const baseVelocity = (0,
|
|
101
|
+
const baseVelocity = (0, MathUtils_js_1.getParticleBaseVelocity)(this.direction), res = baseVelocity.copy(), moveOptions = this.options.move;
|
|
101
102
|
if (moveOptions.direction === MoveDirection_js_1.MoveDirection.inside || moveOptions.direction === MoveDirection_js_1.MoveDirection.outside) {
|
|
102
103
|
return res;
|
|
103
104
|
}
|
|
104
|
-
const rad = (0,
|
|
105
|
+
const rad = (0, MathUtils_js_1.degToRad)((0, MathUtils_js_1.getRangeValue)(moveOptions.angle.value)), radOffset = (0, MathUtils_js_1.degToRad)((0, MathUtils_js_1.getRangeValue)(moveOptions.angle.offset)), range = {
|
|
105
106
|
left: radOffset - rad * Constants_js_1.half,
|
|
106
107
|
right: radOffset + rad * Constants_js_1.half,
|
|
107
108
|
};
|
|
108
109
|
if (!moveOptions.straight) {
|
|
109
|
-
res.angle += (0,
|
|
110
|
+
res.angle += (0, MathUtils_js_1.randomInRangeValue)((0, MathUtils_js_1.setRangeValue)(range.left, range.right));
|
|
110
111
|
}
|
|
111
112
|
if (moveOptions.random && typeof moveOptions.speed === "number") {
|
|
112
|
-
res.length *= (0,
|
|
113
|
+
res.length *= (0, MathUtils_js_1.getRandom)();
|
|
113
114
|
}
|
|
114
115
|
return res;
|
|
115
116
|
};
|
|
116
|
-
this._checkOverlap = (pos, tryCount = Constants_js_1.defaultRetryCount) => {
|
|
117
|
-
const collisionsOptions = this.options.collisions, radius = this.getRadius();
|
|
118
|
-
if (!collisionsOptions.enable) {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
const overlapOptions = collisionsOptions.overlap;
|
|
122
|
-
if (overlapOptions.enable) {
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
const retries = overlapOptions.retries;
|
|
126
|
-
if (retries >= Constants_js_1.minRetries && tryCount > retries) {
|
|
127
|
-
throw new Error(`${Constants_js_1.errorPrefix} particle is overlapping and can't be placed`);
|
|
128
|
-
}
|
|
129
|
-
return !!this.container.particles.find(particle => (0, NumberUtils_js_1.getDistance)(pos, particle.position) < radius + particle.getRadius());
|
|
130
|
-
};
|
|
131
117
|
this._getRollColor = color => {
|
|
132
118
|
if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
|
|
133
119
|
return color;
|
|
134
120
|
}
|
|
135
|
-
const backFactor = this.roll.horizontal && this.roll.vertical ? Constants_js_1.double * Constants_js_1.rollFactor : Constants_js_1.rollFactor, backSum = this.roll.horizontal ? Math.PI * Constants_js_1.half : Constants_js_1.none, rolled = Math.floor((
|
|
121
|
+
const backFactor = this.roll.horizontal && this.roll.vertical ? Constants_js_1.double * Constants_js_1.rollFactor : Constants_js_1.rollFactor, backSum = this.roll.horizontal ? Math.PI * Constants_js_1.half : Constants_js_1.none, rolled = Math.floor((this.roll.angle + backSum) / (Math.PI / backFactor)) % Constants_js_1.double;
|
|
136
122
|
if (!rolled) {
|
|
137
123
|
return color;
|
|
138
124
|
}
|
|
@@ -145,16 +131,16 @@
|
|
|
145
131
|
return color;
|
|
146
132
|
};
|
|
147
133
|
this._initPosition = position => {
|
|
148
|
-
const container = this.container, zIndexValue = (0,
|
|
149
|
-
this.position = this._calcPosition(container, position, (0,
|
|
134
|
+
const container = this.container, zIndexValue = (0, MathUtils_js_1.getRangeValue)(this.options.zIndex.value);
|
|
135
|
+
this.position = this._calcPosition(container, position, (0, MathUtils_js_1.clamp)(zIndexValue, Constants_js_1.minZ, container.zLayers));
|
|
150
136
|
this.initialPosition = this.position.copy();
|
|
151
137
|
const canvasSize = container.canvas.size;
|
|
152
138
|
this.moveCenter = {
|
|
153
139
|
...(0, Utils_js_1.getPosition)(this.options.move.center, canvasSize),
|
|
154
|
-
radius: this.options.move.center.radius
|
|
155
|
-
mode: this.options.move.center.mode
|
|
140
|
+
radius: this.options.move.center.radius,
|
|
141
|
+
mode: this.options.move.center.mode,
|
|
156
142
|
};
|
|
157
|
-
this.direction = (0,
|
|
143
|
+
this.direction = (0, MathUtils_js_1.getParticleDirectionAngle)(this.options.move.direction, this.position, this.moveCenter);
|
|
158
144
|
switch (this.options.move.direction) {
|
|
159
145
|
case MoveDirection_js_1.MoveDirection.inside:
|
|
160
146
|
this.outType = ParticleOutType_js_1.ParticleOutType.inside;
|
|
@@ -174,7 +160,7 @@
|
|
|
174
160
|
this.destroyed = true;
|
|
175
161
|
this.bubble.inRange = false;
|
|
176
162
|
this.slow.inRange = false;
|
|
177
|
-
const container = this.container, pathGenerator = this.pathGenerator, shapeDrawer = container.shapeDrawers.get(this.shape);
|
|
163
|
+
const container = this.container, pathGenerator = this.pathGenerator, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
|
|
178
164
|
shapeDrawer?.particleDestroy?.(this);
|
|
179
165
|
for (const plugin of container.plugins.values()) {
|
|
180
166
|
plugin.particleDestroyed?.(this, override);
|
|
@@ -197,6 +183,9 @@
|
|
|
197
183
|
}
|
|
198
184
|
canvas.drawParticle(this, delta);
|
|
199
185
|
}
|
|
186
|
+
getAngle() {
|
|
187
|
+
return this.rotation + (this.pathRotation ? this.velocity.angle : Constants_js_1.defaultAngle);
|
|
188
|
+
}
|
|
200
189
|
getFillColor() {
|
|
201
190
|
return this._getRollColor(this.bubble.color ?? (0, ColorUtils_js_1.getHslFromAnimation)(this.color));
|
|
202
191
|
}
|
|
@@ -236,7 +225,7 @@
|
|
|
236
225
|
};
|
|
237
226
|
this.outType = ParticleOutType_js_1.ParticleOutType.normal;
|
|
238
227
|
this.ignoresResizeRatio = true;
|
|
239
|
-
const pxRatio = container.retina.pixelRatio, mainOptions = container.actualOptions, particlesOptions = (0, OptionsUtils_js_1.loadParticlesOptions)(this._engine, container, mainOptions.particles),
|
|
228
|
+
const pxRatio = container.retina.pixelRatio, mainOptions = container.actualOptions, particlesOptions = (0, OptionsUtils_js_1.loadParticlesOptions)(this._engine, container, mainOptions.particles), reduceDuplicates = particlesOptions.reduceDuplicates, effectType = particlesOptions.effect.type, shapeType = particlesOptions.shape.type;
|
|
240
229
|
this.effect = (0, Utils_js_1.itemFromSingleOrMultiple)(effectType, this.id, reduceDuplicates);
|
|
241
230
|
this.shape = (0, Utils_js_1.itemFromSingleOrMultiple)(shapeType, this.id, reduceDuplicates);
|
|
242
231
|
const effectOptions = particlesOptions.effect, shapeOptions = particlesOptions.shape;
|
|
@@ -258,14 +247,16 @@
|
|
|
258
247
|
}
|
|
259
248
|
if (this.effect === Constants_js_1.randomColorValue) {
|
|
260
249
|
const availableEffects = [...this.container.effectDrawers.keys()];
|
|
261
|
-
this.effect = availableEffects[Math.floor((0,
|
|
250
|
+
this.effect = availableEffects[Math.floor((0, MathUtils_js_1.getRandom)() * availableEffects.length)];
|
|
262
251
|
}
|
|
263
252
|
if (this.shape === Constants_js_1.randomColorValue) {
|
|
264
253
|
const availableShapes = [...this.container.shapeDrawers.keys()];
|
|
265
|
-
this.shape = availableShapes[Math.floor((0,
|
|
254
|
+
this.shape = availableShapes[Math.floor((0, MathUtils_js_1.getRandom)() * availableShapes.length)];
|
|
266
255
|
}
|
|
267
|
-
this.effectData =
|
|
268
|
-
|
|
256
|
+
this.effectData = this.effect
|
|
257
|
+
? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates)
|
|
258
|
+
: undefined;
|
|
259
|
+
this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;
|
|
269
260
|
particlesOptions.load(overrideOptions);
|
|
270
261
|
const effectData = this.effectData;
|
|
271
262
|
if (effectData) {
|
|
@@ -285,7 +276,7 @@
|
|
|
285
276
|
this.shapeClose = shapeData?.close ?? particlesOptions.shape.close;
|
|
286
277
|
this.options = particlesOptions;
|
|
287
278
|
const pathOptions = this.options.move.path;
|
|
288
|
-
this.pathDelay = (0,
|
|
279
|
+
this.pathDelay = (0, MathUtils_js_1.getRangeValue)(pathOptions.delay.value) * Constants_js_1.millisecondsToSeconds;
|
|
289
280
|
if (pathOptions.generator) {
|
|
290
281
|
this.pathGenerator = this._engine.getPathGenerator(pathOptions.generator);
|
|
291
282
|
if (this.pathGenerator && container.addPath(pathOptions.generator, this.pathGenerator)) {
|
|
@@ -304,26 +295,31 @@
|
|
|
304
295
|
this._initPosition(position);
|
|
305
296
|
this.initialVelocity = this._calculateVelocity();
|
|
306
297
|
this.velocity = this.initialVelocity.copy();
|
|
307
|
-
this.moveDecay = Constants_js_1.decayOffset - (0,
|
|
298
|
+
this.moveDecay = Constants_js_1.decayOffset - (0, MathUtils_js_1.getRangeValue)(this.options.move.decay);
|
|
308
299
|
const particles = container.particles;
|
|
309
300
|
particles.setLastZIndex(this.position.z);
|
|
310
301
|
this.zIndexFactor = this.position.z / container.zLayers;
|
|
311
302
|
this.sides = 24;
|
|
312
|
-
let effectDrawer
|
|
313
|
-
if (
|
|
314
|
-
effectDrawer =
|
|
315
|
-
if (effectDrawer) {
|
|
316
|
-
|
|
303
|
+
let effectDrawer, shapeDrawer;
|
|
304
|
+
if (this.effect) {
|
|
305
|
+
effectDrawer = container.effectDrawers.get(this.effect);
|
|
306
|
+
if (!effectDrawer) {
|
|
307
|
+
effectDrawer = this._engine.getEffectDrawer(this.effect);
|
|
308
|
+
if (effectDrawer) {
|
|
309
|
+
container.effectDrawers.set(this.effect, effectDrawer);
|
|
310
|
+
}
|
|
317
311
|
}
|
|
318
312
|
}
|
|
319
313
|
if (effectDrawer?.loadEffect) {
|
|
320
314
|
effectDrawer.loadEffect(this);
|
|
321
315
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
316
|
+
if (this.shape) {
|
|
317
|
+
shapeDrawer = container.shapeDrawers.get(this.shape);
|
|
318
|
+
if (!shapeDrawer) {
|
|
319
|
+
shapeDrawer = this._engine.getShapeDrawer(this.shape);
|
|
320
|
+
if (shapeDrawer) {
|
|
321
|
+
container.shapeDrawers.set(this.shape, shapeDrawer);
|
|
322
|
+
}
|
|
327
323
|
}
|
|
328
324
|
}
|
|
329
325
|
if (shapeDrawer?.loadShape) {
|
|
@@ -334,12 +330,11 @@
|
|
|
334
330
|
this.sides = sideCountFunc(this);
|
|
335
331
|
}
|
|
336
332
|
this.spawning = false;
|
|
337
|
-
this.shadowColor = (0, ColorUtils_js_1.rangeColorToRgb)(this._engine, this.options.shadow.color);
|
|
338
333
|
for (const updater of particles.updaters) {
|
|
339
334
|
updater.init(this);
|
|
340
335
|
}
|
|
341
336
|
for (const mover of particles.movers) {
|
|
342
|
-
mover.init
|
|
337
|
+
mover.init(this);
|
|
343
338
|
}
|
|
344
339
|
effectDrawer?.particleInit?.(container, this);
|
|
345
340
|
shapeDrawer?.particleInit?.(container, this);
|