@tsparticles/engine 4.0.0-alpha.1 → 4.0.0-alpha.14
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/219.min.js +1 -0
- package/README.md +2 -5
- package/browser/Core/Canvas.js +238 -154
- package/browser/Core/Container.js +111 -227
- package/browser/Core/Engine.js +84 -124
- package/browser/Core/Particle.js +236 -140
- package/browser/Core/Particles.js +212 -123
- package/browser/Core/Retina.js +5 -0
- package/browser/Core/Utils/Constants.js +2 -2
- package/browser/Core/Utils/EventListeners.js +69 -310
- package/browser/Core/Utils/Point.js +2 -0
- package/browser/Core/Utils/QuadTree.js +13 -8
- package/browser/Core/Utils/Ranges.js +4 -0
- package/browser/Core/Utils/Vectors.js +7 -4
- package/browser/Enums/Types/EasingType.js +18 -3
- package/browser/Options/Classes/AnimatableColor.js +1 -0
- package/browser/Options/Classes/AnimationOptions.js +8 -0
- package/browser/Options/Classes/Background/Background.js +6 -0
- package/browser/Options/Classes/ColorAnimation.js +1 -0
- package/browser/Options/Classes/FullScreen/FullScreen.js +2 -0
- package/browser/Options/Classes/HslAnimation.js +3 -5
- package/browser/Options/Classes/Options.js +32 -78
- package/browser/Options/Classes/OptionsColor.js +1 -0
- package/browser/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
- package/browser/Options/Classes/Particles/Effect/Effect.js +4 -0
- package/browser/Options/Classes/Particles/Move/Move.js +18 -0
- package/browser/Options/Classes/Particles/Move/MoveAngle.js +2 -0
- package/browser/Options/Classes/Particles/Move/MoveAttract.js +3 -0
- package/browser/Options/Classes/Particles/Move/MoveCenter.js +4 -0
- package/browser/Options/Classes/Particles/Move/MoveGravity.js +4 -0
- package/browser/Options/Classes/Particles/Move/OutModes.js +5 -0
- package/browser/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
- package/browser/Options/Classes/Particles/Move/Spin.js +3 -0
- package/browser/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
- package/browser/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
- package/browser/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
- package/browser/Options/Classes/Particles/Opacity/Opacity.js +1 -0
- package/browser/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
- package/browser/Options/Classes/Particles/ParticlesOptions.js +19 -11
- package/browser/Options/Classes/Particles/Shape/Shape.js +4 -0
- package/browser/Options/Classes/Particles/Size/Size.js +1 -0
- package/browser/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
- package/browser/Options/Classes/Particles/Stroke.js +3 -0
- package/browser/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
- package/{esm/Options/Classes/Interactivity/Events → browser/Options/Classes}/ResizeEvent.js +3 -1
- package/browser/Options/Classes/ValueWithRandom.js +3 -4
- package/browser/Utils/CanvasUtils.js +31 -106
- package/browser/Utils/ColorUtils.js +17 -2
- package/browser/Utils/EventDispatcher.js +1 -0
- package/browser/Utils/MathUtils.js +3 -2
- package/browser/Utils/Utils.js +53 -44
- package/browser/exports.js +1 -21
- package/cjs/Core/Canvas.js +238 -154
- package/cjs/Core/Container.js +111 -227
- package/cjs/Core/Engine.js +84 -124
- package/cjs/Core/Particle.js +236 -140
- package/cjs/Core/Particles.js +212 -123
- package/cjs/Core/Retina.js +5 -0
- package/cjs/Core/Utils/Constants.js +2 -2
- package/cjs/Core/Utils/EventListeners.js +69 -310
- package/cjs/Core/Utils/Point.js +2 -0
- package/cjs/Core/Utils/QuadTree.js +13 -8
- package/cjs/Core/Utils/Ranges.js +4 -0
- package/cjs/Core/Utils/Vectors.js +7 -4
- package/cjs/Enums/Types/EasingType.js +18 -3
- package/cjs/Options/Classes/AnimatableColor.js +1 -0
- package/cjs/Options/Classes/AnimationOptions.js +8 -0
- package/cjs/Options/Classes/Background/Background.js +6 -0
- package/cjs/Options/Classes/ColorAnimation.js +1 -0
- package/cjs/Options/Classes/FullScreen/FullScreen.js +2 -0
- package/cjs/Options/Classes/HslAnimation.js +3 -5
- package/cjs/Options/Classes/Options.js +32 -78
- package/cjs/Options/Classes/OptionsColor.js +1 -0
- package/cjs/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
- package/cjs/Options/Classes/Particles/Effect/Effect.js +4 -0
- package/cjs/Options/Classes/Particles/Move/Move.js +18 -0
- package/cjs/Options/Classes/Particles/Move/MoveAngle.js +2 -0
- package/cjs/Options/Classes/Particles/Move/MoveAttract.js +3 -0
- package/cjs/Options/Classes/Particles/Move/MoveCenter.js +4 -0
- package/cjs/Options/Classes/Particles/Move/MoveGravity.js +4 -0
- package/cjs/Options/Classes/Particles/Move/OutModes.js +5 -0
- package/cjs/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
- package/cjs/Options/Classes/Particles/Move/Spin.js +3 -0
- package/cjs/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
- package/cjs/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
- package/cjs/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
- package/cjs/Options/Classes/Particles/Opacity/Opacity.js +1 -0
- package/cjs/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
- package/cjs/Options/Classes/Particles/ParticlesOptions.js +19 -11
- package/cjs/Options/Classes/Particles/Shape/Shape.js +4 -0
- package/cjs/Options/Classes/Particles/Size/Size.js +1 -0
- package/cjs/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
- package/cjs/Options/Classes/Particles/Stroke.js +3 -0
- package/cjs/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
- package/cjs/Options/Classes/{Interactivity/Events/ResizeEvent.js → ResizeEvent.js} +3 -1
- package/cjs/Options/Classes/ValueWithRandom.js +3 -4
- package/cjs/Utils/CanvasUtils.js +31 -106
- package/cjs/Utils/ColorUtils.js +17 -2
- package/cjs/Utils/EventDispatcher.js +1 -0
- package/cjs/Utils/MathUtils.js +3 -2
- package/cjs/Utils/Utils.js +53 -44
- package/cjs/exports.js +1 -21
- package/dist_browser_Core_Container_js.js +8 -18
- package/esm/Core/Canvas.js +238 -154
- package/esm/Core/Container.js +111 -227
- package/esm/Core/Engine.js +84 -124
- package/esm/Core/Particle.js +236 -140
- package/esm/Core/Particles.js +212 -123
- package/esm/Core/Retina.js +5 -0
- package/esm/Core/Utils/Constants.js +2 -2
- package/esm/Core/Utils/EventListeners.js +69 -310
- package/esm/Core/Utils/Point.js +2 -0
- package/esm/Core/Utils/QuadTree.js +13 -8
- package/esm/Core/Utils/Ranges.js +4 -0
- package/esm/Core/Utils/Vectors.js +7 -4
- package/esm/Enums/Types/EasingType.js +18 -3
- package/esm/Options/Classes/AnimatableColor.js +1 -0
- package/esm/Options/Classes/AnimationOptions.js +8 -0
- package/esm/Options/Classes/Background/Background.js +6 -0
- package/esm/Options/Classes/ColorAnimation.js +1 -0
- package/esm/Options/Classes/FullScreen/FullScreen.js +2 -0
- package/esm/Options/Classes/HslAnimation.js +3 -5
- package/esm/Options/Classes/Options.js +32 -78
- package/esm/Options/Classes/OptionsColor.js +1 -0
- package/esm/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
- package/esm/Options/Classes/Particles/Effect/Effect.js +4 -0
- package/esm/Options/Classes/Particles/Move/Move.js +18 -0
- package/esm/Options/Classes/Particles/Move/MoveAngle.js +2 -0
- package/esm/Options/Classes/Particles/Move/MoveAttract.js +3 -0
- package/esm/Options/Classes/Particles/Move/MoveCenter.js +4 -0
- package/esm/Options/Classes/Particles/Move/MoveGravity.js +4 -0
- package/esm/Options/Classes/Particles/Move/OutModes.js +5 -0
- package/esm/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
- package/esm/Options/Classes/Particles/Move/Spin.js +3 -0
- package/esm/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
- package/esm/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
- package/esm/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
- package/esm/Options/Classes/Particles/Opacity/Opacity.js +1 -0
- package/esm/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
- package/esm/Options/Classes/Particles/ParticlesOptions.js +19 -11
- package/esm/Options/Classes/Particles/Shape/Shape.js +4 -0
- package/esm/Options/Classes/Particles/Size/Size.js +1 -0
- package/esm/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
- package/esm/Options/Classes/Particles/Stroke.js +3 -0
- package/esm/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
- package/{browser/Options/Classes/Interactivity/Events → esm/Options/Classes}/ResizeEvent.js +3 -1
- package/esm/Options/Classes/ValueWithRandom.js +3 -4
- package/esm/Utils/CanvasUtils.js +31 -106
- package/esm/Utils/ColorUtils.js +17 -2
- package/esm/Utils/EventDispatcher.js +1 -0
- package/esm/Utils/MathUtils.js +3 -2
- package/esm/Utils/Utils.js +53 -44
- package/esm/exports.js +1 -21
- package/package.json +1 -1
- package/report.html +3 -3
- package/scripts/install.js +28 -9
- package/tsparticles.engine.js +67 -247
- package/tsparticles.engine.min.js +2 -2
- package/types/Core/Canvas.d.ts +15 -4
- package/types/Core/Container.d.ts +5 -20
- package/types/Core/Engine.d.ts +18 -32
- package/types/Core/Interfaces/IColorManager.d.ts +0 -1
- package/types/Core/Interfaces/IContainerPlugin.d.ts +12 -2
- package/types/Core/Interfaces/IDrawParticleParams.d.ts +1 -1
- package/types/Core/Interfaces/IMovePathGenerator.d.ts +1 -2
- package/types/Core/Interfaces/IParticleOpacityData.d.ts +4 -0
- package/types/Core/Interfaces/IParticleRotateData.d.ts +4 -0
- package/types/Core/Interfaces/IParticleTransformValues.d.ts +4 -4
- package/types/Core/Interfaces/IParticleUpdater.d.ts +1 -1
- package/types/Core/Interfaces/IPlugin.d.ts +5 -1
- package/types/Core/Interfaces/IShapeDrawer.d.ts +0 -1
- package/types/Core/Particle.d.ts +13 -2
- package/types/Core/Particles.d.ts +17 -8
- package/types/Core/Utils/Constants.d.ts +2 -2
- package/types/Core/Utils/EventListeners.d.ts +0 -14
- package/types/Enums/Types/EasingType.d.ts +20 -5
- package/types/Options/Classes/HslAnimation.d.ts +3 -4
- package/types/Options/Classes/Options.d.ts +2 -11
- package/types/Options/Classes/Particles/ParticlesOptions.d.ts +0 -2
- package/types/Options/Classes/ResizeEvent.d.ts +9 -0
- package/types/Options/Classes/ValueWithRandom.d.ts +0 -1
- package/types/Options/Interfaces/IOptions.d.ts +2 -8
- package/types/Options/Interfaces/Particles/IParticlesOptions.d.ts +0 -3
- package/types/Types/CustomEventListener.d.ts +1 -1
- package/types/Types/EngineInitializers.d.ts +19 -0
- package/types/Utils/CanvasUtils.d.ts +6 -25
- package/types/Utils/EventDispatcher.d.ts +1 -1
- package/types/Utils/Utils.d.ts +5 -7
- package/types/export-types.d.ts +3 -19
- package/types/exports.d.ts +1 -21
- package/umd/Core/Canvas.js +236 -152
- package/umd/Core/Container.js +111 -227
- package/umd/Core/Engine.js +83 -123
- package/umd/Core/Particle.js +236 -140
- package/umd/Core/Particles.js +213 -124
- package/umd/Core/Retina.js +5 -0
- package/umd/Core/Utils/Constants.js +3 -3
- package/umd/Core/Utils/EventListeners.js +69 -310
- package/umd/Core/Utils/Point.js +2 -0
- package/umd/Core/Utils/QuadTree.js +13 -8
- package/umd/Core/Utils/Ranges.js +4 -0
- package/umd/Core/Utils/Vectors.js +7 -4
- package/umd/Enums/Types/EasingType.js +18 -3
- package/umd/Options/Classes/AnimatableColor.js +1 -0
- package/umd/Options/Classes/AnimationOptions.js +8 -0
- package/umd/Options/Classes/Background/Background.js +6 -0
- package/umd/Options/Classes/ColorAnimation.js +1 -0
- package/umd/Options/Classes/FullScreen/FullScreen.js +2 -0
- package/umd/Options/Classes/HslAnimation.js +3 -5
- package/umd/Options/Classes/Options.js +32 -78
- package/umd/Options/Classes/OptionsColor.js +1 -0
- package/umd/Options/Classes/Particles/Bounce/ParticlesBounce.js +2 -0
- package/umd/Options/Classes/Particles/Effect/Effect.js +4 -0
- package/umd/Options/Classes/Particles/Move/Move.js +18 -0
- package/umd/Options/Classes/Particles/Move/MoveAngle.js +2 -0
- package/umd/Options/Classes/Particles/Move/MoveAttract.js +3 -0
- package/umd/Options/Classes/Particles/Move/MoveCenter.js +4 -0
- package/umd/Options/Classes/Particles/Move/MoveGravity.js +4 -0
- package/umd/Options/Classes/Particles/Move/OutModes.js +5 -0
- package/umd/Options/Classes/Particles/Move/Path/MovePath.js +5 -0
- package/umd/Options/Classes/Particles/Move/Spin.js +3 -0
- package/umd/Options/Classes/Particles/Number/ParticlesDensity.js +3 -0
- package/umd/Options/Classes/Particles/Number/ParticlesNumber.js +3 -0
- package/umd/Options/Classes/Particles/Number/ParticlesNumberLimit.js +2 -0
- package/umd/Options/Classes/Particles/Opacity/Opacity.js +1 -0
- package/umd/Options/Classes/Particles/Opacity/OpacityAnimation.js +1 -0
- package/umd/Options/Classes/Particles/ParticlesOptions.js +19 -11
- package/umd/Options/Classes/Particles/Shape/Shape.js +4 -0
- package/umd/Options/Classes/Particles/Size/Size.js +1 -0
- package/umd/Options/Classes/Particles/Size/SizeAnimation.js +1 -0
- package/umd/Options/Classes/Particles/Stroke.js +3 -0
- package/umd/Options/Classes/Particles/ZIndex/ZIndex.js +3 -0
- package/umd/Options/Classes/{Interactivity/Events/ResizeEvent.js → ResizeEvent.js} +4 -2
- package/umd/Options/Classes/ValueWithRandom.js +3 -4
- package/umd/Utils/CanvasUtils.js +30 -108
- package/umd/Utils/ColorUtils.js +17 -2
- package/umd/Utils/EventDispatcher.js +1 -0
- package/umd/Utils/MathUtils.js +3 -2
- package/umd/Utils/Utils.js +55 -48
- package/umd/exports.js +2 -22
- package/638.min.js +0 -2
- package/638.min.js.LICENSE.txt +0 -1
- package/browser/Core/Utils/ExternalInteractorBase.js +0 -7
- package/browser/Core/Utils/InteractionManager.js +0 -60
- package/browser/Core/Utils/ParticlesInteractorBase.js +0 -7
- package/browser/Enums/InteractivityDetect.js +0 -6
- package/browser/Enums/Modes/ResponsiveMode.js +0 -5
- package/browser/Enums/Modes/ThemeMode.js +0 -6
- package/browser/Enums/Types/DivType.js +0 -5
- package/browser/Enums/Types/InteractorType.js +0 -5
- package/browser/Options/Classes/Interactivity/Events/ClickEvent.js +0 -18
- package/browser/Options/Classes/Interactivity/Events/DivEvent.js +0 -27
- package/browser/Options/Classes/Interactivity/Events/Events.js +0 -30
- package/browser/Options/Classes/Interactivity/Events/HoverEvent.js +0 -21
- package/browser/Options/Classes/Interactivity/Events/Parallax.js +0 -22
- package/browser/Options/Classes/Interactivity/Interactivity.js +0 -22
- package/browser/Options/Classes/Interactivity/Modes/Modes.js +0 -25
- package/browser/Options/Classes/ManualParticle.js +0 -21
- package/browser/Options/Classes/Responsive.js +0 -29
- package/browser/Options/Classes/Theme/Theme.js +0 -21
- package/browser/Options/Classes/Theme/ThemeDefault.js +0 -23
- package/browser/Options/Interfaces/Interactivity/Events/IEvents.js +0 -1
- package/browser/Options/Interfaces/Interactivity/Events/IHoverEvent.js +0 -1
- package/browser/Options/Interfaces/Interactivity/Events/IParallax.js +0 -1
- package/browser/Options/Interfaces/Interactivity/IInteractivity.js +0 -1
- package/browser/Options/Interfaces/Interactivity/Modes/IModeDiv.js +0 -1
- package/browser/Options/Interfaces/Interactivity/Modes/IModes.js +0 -1
- package/browser/Options/Interfaces/Theme/ITheme.js +0 -1
- package/browser/Options/Interfaces/Theme/IThemeDefault.js +0 -1
- package/cjs/Core/Interfaces/IContainerInteractivity.js +0 -1
- package/cjs/Core/Interfaces/IExternalInteractor.js +0 -1
- package/cjs/Core/Interfaces/IInteractor.js +0 -1
- package/cjs/Core/Interfaces/IMouseData.js +0 -1
- package/cjs/Core/Interfaces/IParticlesInteractor.js +0 -1
- package/cjs/Core/Utils/ExternalInteractorBase.js +0 -7
- package/cjs/Core/Utils/InteractionManager.js +0 -60
- package/cjs/Core/Utils/ParticlesInteractorBase.js +0 -7
- package/cjs/Enums/InteractivityDetect.js +0 -6
- package/cjs/Enums/Modes/ResponsiveMode.js +0 -5
- package/cjs/Enums/Modes/ThemeMode.js +0 -6
- package/cjs/Enums/Types/DivType.js +0 -5
- package/cjs/Enums/Types/InteractorType.js +0 -5
- package/cjs/Options/Classes/Interactivity/Events/ClickEvent.js +0 -18
- package/cjs/Options/Classes/Interactivity/Events/DivEvent.js +0 -27
- package/cjs/Options/Classes/Interactivity/Events/Events.js +0 -30
- package/cjs/Options/Classes/Interactivity/Events/HoverEvent.js +0 -21
- package/cjs/Options/Classes/Interactivity/Events/Parallax.js +0 -22
- package/cjs/Options/Classes/Interactivity/Interactivity.js +0 -22
- package/cjs/Options/Classes/Interactivity/Modes/Modes.js +0 -25
- package/cjs/Options/Classes/ManualParticle.js +0 -21
- package/cjs/Options/Classes/Responsive.js +0 -29
- package/cjs/Options/Classes/Theme/Theme.js +0 -21
- package/cjs/Options/Classes/Theme/ThemeDefault.js +0 -23
- package/cjs/Options/Interfaces/IManualParticle.js +0 -1
- package/cjs/Options/Interfaces/IResponsive.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/Events/IClickEvent.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/Events/IDivEvent.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/Events/IEvents.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/Events/IHoverEvent.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/Events/IParallax.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/IInteractivity.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/Modes/IModeDiv.js +0 -1
- package/cjs/Options/Interfaces/Interactivity/Modes/IModes.js +0 -1
- package/cjs/Options/Interfaces/Theme/ITheme.js +0 -1
- package/cjs/Options/Interfaces/Theme/IThemeDefault.js +0 -1
- package/esm/Core/Interfaces/IContainerInteractivity.js +0 -1
- package/esm/Core/Interfaces/IExternalInteractor.js +0 -1
- package/esm/Core/Interfaces/IInteractor.js +0 -1
- package/esm/Core/Interfaces/IMouseData.js +0 -1
- package/esm/Core/Interfaces/IParticlesInteractor.js +0 -1
- package/esm/Core/Utils/ExternalInteractorBase.js +0 -7
- package/esm/Core/Utils/InteractionManager.js +0 -60
- package/esm/Core/Utils/ParticlesInteractorBase.js +0 -7
- package/esm/Enums/InteractivityDetect.js +0 -6
- package/esm/Enums/Modes/ResponsiveMode.js +0 -5
- package/esm/Enums/Modes/ThemeMode.js +0 -6
- package/esm/Enums/Types/DivType.js +0 -5
- package/esm/Enums/Types/InteractorType.js +0 -5
- package/esm/Options/Classes/Interactivity/Events/ClickEvent.js +0 -18
- package/esm/Options/Classes/Interactivity/Events/DivEvent.js +0 -27
- package/esm/Options/Classes/Interactivity/Events/Events.js +0 -30
- package/esm/Options/Classes/Interactivity/Events/HoverEvent.js +0 -21
- package/esm/Options/Classes/Interactivity/Events/Parallax.js +0 -22
- package/esm/Options/Classes/Interactivity/Interactivity.js +0 -22
- package/esm/Options/Classes/Interactivity/Modes/Modes.js +0 -25
- package/esm/Options/Classes/ManualParticle.js +0 -21
- package/esm/Options/Classes/Responsive.js +0 -29
- package/esm/Options/Classes/Theme/Theme.js +0 -21
- package/esm/Options/Classes/Theme/ThemeDefault.js +0 -23
- package/esm/Options/Interfaces/IManualParticle.js +0 -1
- package/esm/Options/Interfaces/IResponsive.js +0 -1
- package/esm/Options/Interfaces/Interactivity/Events/IClickEvent.js +0 -1
- package/esm/Options/Interfaces/Interactivity/Events/IDivEvent.js +0 -1
- package/esm/Options/Interfaces/Interactivity/Events/IEvents.js +0 -1
- package/esm/Options/Interfaces/Interactivity/Events/IHoverEvent.js +0 -1
- package/esm/Options/Interfaces/Interactivity/Events/IParallax.js +0 -1
- package/esm/Options/Interfaces/Interactivity/IInteractivity.js +0 -1
- package/esm/Options/Interfaces/Interactivity/Modes/IModeDiv.js +0 -1
- package/esm/Options/Interfaces/Interactivity/Modes/IModes.js +0 -1
- package/esm/Options/Interfaces/Theme/ITheme.js +0 -1
- package/esm/Options/Interfaces/Theme/IThemeDefault.js +0 -1
- package/tsparticles.engine.min.js.LICENSE.txt +0 -1
- package/types/Core/Interfaces/IContainerInteractivity.d.ts +0 -6
- package/types/Core/Interfaces/IExternalInteractor.d.ts +0 -12
- package/types/Core/Interfaces/IInteractor.d.ts +0 -16
- package/types/Core/Interfaces/IMouseData.d.ts +0 -9
- package/types/Core/Interfaces/IParticlesInteractor.d.ts +0 -7
- package/types/Core/Utils/ExternalInteractorBase.d.ts +0 -15
- package/types/Core/Utils/InteractionManager.d.ts +0 -17
- package/types/Core/Utils/ParticlesInteractorBase.d.ts +0 -15
- package/types/Enums/InteractivityDetect.d.ts +0 -5
- package/types/Enums/Modes/ResponsiveMode.d.ts +0 -4
- package/types/Enums/Modes/ThemeMode.d.ts +0 -5
- package/types/Enums/Types/DivType.d.ts +0 -4
- package/types/Enums/Types/InteractorType.d.ts +0 -4
- package/types/Options/Classes/Interactivity/Events/ClickEvent.d.ts +0 -10
- package/types/Options/Classes/Interactivity/Events/DivEvent.d.ts +0 -13
- package/types/Options/Classes/Interactivity/Events/Events.d.ts +0 -16
- package/types/Options/Classes/Interactivity/Events/HoverEvent.d.ts +0 -12
- package/types/Options/Classes/Interactivity/Events/Parallax.d.ts +0 -10
- package/types/Options/Classes/Interactivity/Events/ResizeEvent.d.ts +0 -9
- package/types/Options/Classes/Interactivity/Interactivity.d.ts +0 -16
- package/types/Options/Classes/Interactivity/Modes/Modes.d.ts +0 -12
- package/types/Options/Classes/ManualParticle.d.ts +0 -10
- package/types/Options/Classes/Responsive.d.ts +0 -12
- package/types/Options/Classes/Theme/Theme.d.ts +0 -12
- package/types/Options/Classes/Theme/ThemeDefault.d.ts +0 -11
- package/types/Options/Interfaces/IManualParticle.d.ts +0 -7
- package/types/Options/Interfaces/IResponsive.d.ts +0 -7
- package/types/Options/Interfaces/Interactivity/Events/IClickEvent.d.ts +0 -5
- package/types/Options/Interfaces/Interactivity/Events/IDivEvent.d.ts +0 -8
- package/types/Options/Interfaces/Interactivity/Events/IEvents.d.ts +0 -11
- package/types/Options/Interfaces/Interactivity/Events/IHoverEvent.d.ts +0 -7
- package/types/Options/Interfaces/Interactivity/Events/IParallax.d.ts +0 -5
- package/types/Options/Interfaces/Interactivity/IInteractivity.d.ts +0 -9
- package/types/Options/Interfaces/Interactivity/Modes/IModeDiv.d.ts +0 -4
- package/types/Options/Interfaces/Interactivity/Modes/IModes.d.ts +0 -1
- package/types/Options/Interfaces/Theme/ITheme.d.ts +0 -7
- package/types/Options/Interfaces/Theme/IThemeDefault.d.ts +0 -6
- package/umd/Core/Interfaces/IMouseData.js +0 -12
- package/umd/Core/Interfaces/IParticlesInteractor.js +0 -12
- package/umd/Core/Utils/ExternalInteractorBase.js +0 -21
- package/umd/Core/Utils/InteractionManager.js +0 -74
- package/umd/Core/Utils/ParticlesInteractorBase.js +0 -21
- package/umd/Enums/InteractivityDetect.js +0 -19
- package/umd/Enums/Modes/ResponsiveMode.js +0 -18
- package/umd/Enums/Modes/ThemeMode.js +0 -19
- package/umd/Enums/Types/DivType.js +0 -18
- package/umd/Enums/Types/InteractorType.js +0 -18
- package/umd/Options/Classes/Interactivity/Events/ClickEvent.js +0 -32
- package/umd/Options/Classes/Interactivity/Events/DivEvent.js +0 -41
- package/umd/Options/Classes/Interactivity/Events/Events.js +0 -44
- package/umd/Options/Classes/Interactivity/Events/HoverEvent.js +0 -35
- package/umd/Options/Classes/Interactivity/Events/Parallax.js +0 -36
- package/umd/Options/Classes/Interactivity/Interactivity.js +0 -36
- package/umd/Options/Classes/Interactivity/Modes/Modes.js +0 -39
- package/umd/Options/Classes/ManualParticle.js +0 -35
- package/umd/Options/Classes/Responsive.js +0 -43
- package/umd/Options/Classes/Theme/Theme.js +0 -35
- package/umd/Options/Classes/Theme/ThemeDefault.js +0 -37
- package/umd/Options/Interfaces/IManualParticle.js +0 -12
- package/umd/Options/Interfaces/IResponsive.js +0 -12
- package/umd/Options/Interfaces/Interactivity/Events/IClickEvent.js +0 -12
- package/umd/Options/Interfaces/Interactivity/Events/IDivEvent.js +0 -12
- package/umd/Options/Interfaces/Interactivity/Events/IEvents.js +0 -12
- package/umd/Options/Interfaces/Interactivity/Events/IHoverEvent.js +0 -12
- package/umd/Options/Interfaces/Interactivity/Events/IParallax.js +0 -12
- package/umd/Options/Interfaces/Interactivity/IInteractivity.js +0 -12
- package/umd/Options/Interfaces/Interactivity/Modes/IModeDiv.js +0 -12
- package/umd/Options/Interfaces/Interactivity/Modes/IModes.js +0 -12
- package/umd/Options/Interfaces/Theme/ITheme.js +0 -12
- package/umd/Options/Interfaces/Theme/IThemeDefault.js +0 -12
- /package/browser/Core/Interfaces/{IContainerInteractivity.js → IParticleOpacityData.js} +0 -0
- /package/browser/Core/Interfaces/{IExternalInteractor.js → IParticleRotateData.js} +0 -0
- /package/browser/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
- /package/browser/{Core/Interfaces/IInteractor.js → Types/EngineInitializers.js} +0 -0
- /package/{browser/Core/Interfaces/IMouseData.js → cjs/Core/Interfaces/IParticleOpacityData.js} +0 -0
- /package/{browser/Core/Interfaces/IParticlesInteractor.js → cjs/Core/Interfaces/IParticleRotateData.js} +0 -0
- /package/cjs/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
- /package/{browser/Options/Interfaces/IManualParticle.js → cjs/Types/EngineInitializers.js} +0 -0
- /package/{browser/Options/Interfaces/IResponsive.js → esm/Core/Interfaces/IParticleOpacityData.js} +0 -0
- /package/{browser/Options/Interfaces/Interactivity/Events/IClickEvent.js → esm/Core/Interfaces/IParticleRotateData.js} +0 -0
- /package/esm/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
- /package/{browser/Options/Interfaces/Interactivity/Events/IDivEvent.js → esm/Types/EngineInitializers.js} +0 -0
- /package/types/Options/Interfaces/{Interactivity/Events/IResizeEvent.d.ts → IResizeEvent.d.ts} +0 -0
- /package/umd/Core/Interfaces/{IContainerInteractivity.js → IParticleOpacityData.js} +0 -0
- /package/umd/Core/Interfaces/{IExternalInteractor.js → IParticleRotateData.js} +0 -0
- /package/umd/Options/Interfaces/{Interactivity/Events/IResizeEvent.js → IResizeEvent.js} +0 -0
- /package/umd/{Core/Interfaces/IInteractor.js → Types/EngineInitializers.js} +0 -0
package/umd/Core/Particle.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
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/MathUtils.js", "./Utils/Constants.js", "../Utils/Utils.js", "../Enums/Types/EventType.js", "../
|
|
7
|
+
define(["require", "exports", "./Utils/Vectors.js", "../Utils/MathUtils.js", "./Utils/Constants.js", "../Utils/Utils.js", "../Enums/Types/EventType.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";
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
const Constants_js_1 = require("./Utils/Constants.js");
|
|
16
16
|
const Utils_js_1 = require("../Utils/Utils.js");
|
|
17
17
|
const EventType_js_1 = require("../Enums/Types/EventType.js");
|
|
18
|
-
const Interactivity_js_1 = require("../Options/Classes/Interactivity/Interactivity.js");
|
|
19
18
|
const MoveDirection_js_1 = require("../Enums/Directions/MoveDirection.js");
|
|
20
19
|
const OutMode_js_1 = require("../Enums/Modes/OutMode.js");
|
|
21
20
|
const ParticleOutType_js_1 = require("../Enums/Types/ParticleOutType.js");
|
|
@@ -49,108 +48,67 @@
|
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
class Particle {
|
|
51
|
+
container;
|
|
52
|
+
backColor;
|
|
53
|
+
bubble;
|
|
54
|
+
color;
|
|
55
|
+
destroyed;
|
|
56
|
+
direction;
|
|
57
|
+
effect;
|
|
58
|
+
effectClose;
|
|
59
|
+
effectData;
|
|
60
|
+
effectFill;
|
|
61
|
+
group;
|
|
62
|
+
id;
|
|
63
|
+
ignoresResizeRatio;
|
|
64
|
+
initialPosition;
|
|
65
|
+
initialVelocity;
|
|
66
|
+
isRotating;
|
|
67
|
+
lastPathTime;
|
|
68
|
+
misplaced;
|
|
69
|
+
moveCenter;
|
|
70
|
+
moveDecay;
|
|
71
|
+
offset;
|
|
72
|
+
opacity;
|
|
73
|
+
options;
|
|
74
|
+
outType;
|
|
75
|
+
pathDelay;
|
|
76
|
+
pathGenerator;
|
|
77
|
+
pathRotation;
|
|
78
|
+
position;
|
|
79
|
+
randomIndexData;
|
|
80
|
+
retina;
|
|
81
|
+
roll;
|
|
82
|
+
rotation;
|
|
83
|
+
shape;
|
|
84
|
+
shapeClose;
|
|
85
|
+
shapeData;
|
|
86
|
+
shapeFill;
|
|
87
|
+
sides;
|
|
88
|
+
size;
|
|
89
|
+
slow;
|
|
90
|
+
spawning;
|
|
91
|
+
strokeColor;
|
|
92
|
+
strokeOpacity;
|
|
93
|
+
strokeWidth;
|
|
94
|
+
unbreakable;
|
|
95
|
+
velocity;
|
|
96
|
+
zIndexFactor;
|
|
97
|
+
_cachedOpacityData = {
|
|
98
|
+
opacity: Constants_js_1.defaultOpacity,
|
|
99
|
+
strokeOpacity: Constants_js_1.defaultOpacity,
|
|
100
|
+
};
|
|
101
|
+
_cachedPosition = Vectors_js_1.Vector3d.origin;
|
|
102
|
+
_cachedRotateData = { sin: 0, cos: 0 };
|
|
103
|
+
_cachedTransform = {
|
|
104
|
+
a: 1,
|
|
105
|
+
b: 0,
|
|
106
|
+
c: 0,
|
|
107
|
+
d: 1,
|
|
108
|
+
};
|
|
109
|
+
_engine;
|
|
52
110
|
constructor(engine, container) {
|
|
53
111
|
this.container = container;
|
|
54
|
-
this._calcPosition = (container, position, zIndex, tryCount = Constants_js_1.defaultRetryCount) => {
|
|
55
|
-
const plugins = container.plugins.values();
|
|
56
|
-
for (const plugin of plugins) {
|
|
57
|
-
const pluginPos = plugin.particlePosition?.(position, this);
|
|
58
|
-
if (pluginPos) {
|
|
59
|
-
return Vectors_js_1.Vector3d.create(pluginPos.x, pluginPos.y, zIndex);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
const canvasSize = container.canvas.size, exactPosition = (0, MathUtils_js_1.calcExactPositionOrRandomFromSize)({
|
|
63
|
-
size: canvasSize,
|
|
64
|
-
position: position,
|
|
65
|
-
}), pos = Vectors_js_1.Vector3d.create(exactPosition.x, exactPosition.y, zIndex), radius = this.getRadius(), outModes = this.options.move.outModes, fixHorizontal = (outMode) => {
|
|
66
|
-
fixOutMode({
|
|
67
|
-
outMode,
|
|
68
|
-
checkModes: [OutMode_js_1.OutMode.bounce],
|
|
69
|
-
coord: pos.x,
|
|
70
|
-
maxCoord: container.canvas.size.width,
|
|
71
|
-
setCb: (value) => (pos.x += value),
|
|
72
|
-
radius,
|
|
73
|
-
});
|
|
74
|
-
}, fixVertical = (outMode) => {
|
|
75
|
-
fixOutMode({
|
|
76
|
-
outMode,
|
|
77
|
-
checkModes: [OutMode_js_1.OutMode.bounce],
|
|
78
|
-
coord: pos.y,
|
|
79
|
-
maxCoord: container.canvas.size.height,
|
|
80
|
-
setCb: (value) => (pos.y += value),
|
|
81
|
-
radius,
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
fixHorizontal(outModes.left ?? outModes.default);
|
|
85
|
-
fixHorizontal(outModes.right ?? outModes.default);
|
|
86
|
-
fixVertical(outModes.top ?? outModes.default);
|
|
87
|
-
fixVertical(outModes.bottom ?? outModes.default);
|
|
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) {
|
|
96
|
-
return this._calcPosition(container, undefined, zIndex, tryCount + Constants_js_1.tryCountIncrement);
|
|
97
|
-
}
|
|
98
|
-
return pos;
|
|
99
|
-
};
|
|
100
|
-
this._calculateVelocity = () => {
|
|
101
|
-
const baseVelocity = (0, MathUtils_js_1.getParticleBaseVelocity)(this.direction), res = baseVelocity.copy(), moveOptions = this.options.move;
|
|
102
|
-
if (moveOptions.direction === MoveDirection_js_1.MoveDirection.inside || moveOptions.direction === MoveDirection_js_1.MoveDirection.outside) {
|
|
103
|
-
return res;
|
|
104
|
-
}
|
|
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 = {
|
|
106
|
-
left: radOffset - rad * Constants_js_1.half,
|
|
107
|
-
right: radOffset + rad * Constants_js_1.half,
|
|
108
|
-
};
|
|
109
|
-
if (!moveOptions.straight) {
|
|
110
|
-
res.angle += (0, MathUtils_js_1.randomInRangeValue)((0, MathUtils_js_1.setRangeValue)(range.left, range.right));
|
|
111
|
-
}
|
|
112
|
-
if (moveOptions.random && typeof moveOptions.speed === "number") {
|
|
113
|
-
res.length *= (0, MathUtils_js_1.getRandom)();
|
|
114
|
-
}
|
|
115
|
-
return res;
|
|
116
|
-
};
|
|
117
|
-
this._getRollColor = color => {
|
|
118
|
-
if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
|
|
119
|
-
return color;
|
|
120
|
-
}
|
|
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;
|
|
122
|
-
if (!rolled) {
|
|
123
|
-
return color;
|
|
124
|
-
}
|
|
125
|
-
if (this.backColor) {
|
|
126
|
-
return this.backColor;
|
|
127
|
-
}
|
|
128
|
-
if (this.roll.alter) {
|
|
129
|
-
return (0, CanvasUtils_js_1.alterHsl)(color, this.roll.alter.type, this.roll.alter.value);
|
|
130
|
-
}
|
|
131
|
-
return color;
|
|
132
|
-
};
|
|
133
|
-
this._initPosition = position => {
|
|
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));
|
|
136
|
-
this.initialPosition = this.position.copy();
|
|
137
|
-
const canvasSize = container.canvas.size;
|
|
138
|
-
this.moveCenter = {
|
|
139
|
-
...(0, Utils_js_1.getPosition)(this.options.move.center, canvasSize),
|
|
140
|
-
radius: this.options.move.center.radius,
|
|
141
|
-
mode: this.options.move.center.mode,
|
|
142
|
-
};
|
|
143
|
-
this.direction = (0, MathUtils_js_1.getParticleDirectionAngle)(this.options.move.direction, this.position, this.moveCenter);
|
|
144
|
-
switch (this.options.move.direction) {
|
|
145
|
-
case MoveDirection_js_1.MoveDirection.inside:
|
|
146
|
-
this.outType = ParticleOutType_js_1.ParticleOutType.inside;
|
|
147
|
-
break;
|
|
148
|
-
case MoveDirection_js_1.MoveDirection.outside:
|
|
149
|
-
this.outType = ParticleOutType_js_1.ParticleOutType.outside;
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
this.offset = Vectors_js_1.Vector.origin;
|
|
153
|
-
};
|
|
154
112
|
this._engine = engine;
|
|
155
113
|
}
|
|
156
114
|
destroy(override) {
|
|
@@ -160,9 +118,9 @@
|
|
|
160
118
|
this.destroyed = true;
|
|
161
119
|
this.bubble.inRange = false;
|
|
162
120
|
this.slow.inRange = false;
|
|
163
|
-
const container = this.container, pathGenerator = this.pathGenerator, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
|
|
121
|
+
const container = this.container, pathGenerator = this.pathGenerator, shapeDrawer = this.shape ? container.particles.shapeDrawers.get(this.shape) : undefined;
|
|
164
122
|
shapeDrawer?.particleDestroy?.(this);
|
|
165
|
-
for (const plugin of container.
|
|
123
|
+
for (const plugin of container.particleDestroyedPlugins) {
|
|
166
124
|
plugin.particleDestroyed?.(this, override);
|
|
167
125
|
}
|
|
168
126
|
for (const updater of container.particles.updaters) {
|
|
@@ -178,9 +136,7 @@
|
|
|
178
136
|
}
|
|
179
137
|
draw(delta) {
|
|
180
138
|
const container = this.container, canvas = container.canvas;
|
|
181
|
-
|
|
182
|
-
canvas.drawParticlePlugin(plugin, this, delta);
|
|
183
|
-
}
|
|
139
|
+
canvas.drawParticlePlugins(this, delta);
|
|
184
140
|
canvas.drawParticle(this, delta);
|
|
185
141
|
}
|
|
186
142
|
getAngle() {
|
|
@@ -192,21 +148,44 @@
|
|
|
192
148
|
getMass() {
|
|
193
149
|
return this.getRadius() ** Constants_js_1.squareExp * Math.PI * Constants_js_1.half;
|
|
194
150
|
}
|
|
151
|
+
getOpacity() {
|
|
152
|
+
const zIndexOptions = this.options.zIndex, zIndexFactor = Constants_js_1.zIndexFactorOffset - this.zIndexFactor, zOpacityFactor = zIndexFactor ** zIndexOptions.opacityRate, opacity = this.bubble.opacity ?? (0, MathUtils_js_1.getRangeValue)(this.opacity?.value ?? Constants_js_1.defaultOpacity), strokeOpacity = this.strokeOpacity ?? opacity;
|
|
153
|
+
this._cachedOpacityData.opacity = opacity * zOpacityFactor;
|
|
154
|
+
this._cachedOpacityData.strokeOpacity = strokeOpacity * zOpacityFactor;
|
|
155
|
+
return this._cachedOpacityData;
|
|
156
|
+
}
|
|
195
157
|
getPosition() {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
};
|
|
158
|
+
this._cachedPosition.x = this.position.x + this.offset.x;
|
|
159
|
+
this._cachedPosition.y = this.position.y + this.offset.y;
|
|
160
|
+
this._cachedPosition.z = this.position.z;
|
|
161
|
+
return this._cachedPosition;
|
|
201
162
|
}
|
|
202
163
|
getRadius() {
|
|
203
164
|
return this.bubble.radius ?? this.size.value;
|
|
204
165
|
}
|
|
166
|
+
getRotateData() {
|
|
167
|
+
const angle = this.getAngle();
|
|
168
|
+
this._cachedRotateData.sin = Math.sin(angle);
|
|
169
|
+
this._cachedRotateData.cos = Math.cos(angle);
|
|
170
|
+
return this._cachedRotateData;
|
|
171
|
+
}
|
|
205
172
|
getStrokeColor() {
|
|
206
173
|
return this._getRollColor(this.bubble.color ?? (0, ColorUtils_js_1.getHslFromAnimation)(this.strokeColor));
|
|
207
174
|
}
|
|
175
|
+
getTransformData(externalTransform) {
|
|
176
|
+
const rotateData = this.getRotateData(), rotating = this.isRotating;
|
|
177
|
+
this._cachedTransform.a = rotateData.cos * (externalTransform.a ?? Constants_js_1.defaultTransform.a);
|
|
178
|
+
this._cachedTransform.b = rotating
|
|
179
|
+
? rotateData.sin * (externalTransform.b ?? Constants_js_1.identity)
|
|
180
|
+
: (externalTransform.b ?? Constants_js_1.defaultTransform.b);
|
|
181
|
+
this._cachedTransform.c = rotating
|
|
182
|
+
? -rotateData.sin * (externalTransform.c ?? Constants_js_1.identity)
|
|
183
|
+
: (externalTransform.c ?? Constants_js_1.defaultTransform.c);
|
|
184
|
+
this._cachedTransform.d = rotateData.cos * (externalTransform.d ?? Constants_js_1.defaultTransform.d);
|
|
185
|
+
return this._cachedTransform;
|
|
186
|
+
}
|
|
208
187
|
init(id, position, overrideOptions, group) {
|
|
209
|
-
const container = this.container
|
|
188
|
+
const container = this.container;
|
|
210
189
|
this.id = id;
|
|
211
190
|
this.group = group;
|
|
212
191
|
this.effectClose = true;
|
|
@@ -246,16 +225,14 @@
|
|
|
246
225
|
}
|
|
247
226
|
}
|
|
248
227
|
if (this.effect === Constants_js_1.randomColorValue) {
|
|
249
|
-
const availableEffects = [...this.container.effectDrawers.keys()];
|
|
228
|
+
const availableEffects = [...this.container.particles.effectDrawers.keys()];
|
|
250
229
|
this.effect = availableEffects[Math.floor((0, MathUtils_js_1.getRandom)() * availableEffects.length)];
|
|
251
230
|
}
|
|
252
231
|
if (this.shape === Constants_js_1.randomColorValue) {
|
|
253
|
-
const availableShapes = [...this.container.shapeDrawers.keys()];
|
|
232
|
+
const availableShapes = [...this.container.particles.shapeDrawers.keys()];
|
|
254
233
|
this.shape = availableShapes[Math.floor((0, MathUtils_js_1.getRandom)() * availableShapes.length)];
|
|
255
234
|
}
|
|
256
|
-
this.effectData = this.effect
|
|
257
|
-
? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates)
|
|
258
|
-
: undefined;
|
|
235
|
+
this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;
|
|
259
236
|
this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;
|
|
260
237
|
particlesOptions.load(overrideOptions);
|
|
261
238
|
const effectData = this.effectData;
|
|
@@ -266,10 +243,6 @@
|
|
|
266
243
|
if (shapeData) {
|
|
267
244
|
particlesOptions.load(shapeData.particles);
|
|
268
245
|
}
|
|
269
|
-
const interactivity = new Interactivity_js_1.Interactivity(engine, container);
|
|
270
|
-
interactivity.load(container.actualOptions.interactivity);
|
|
271
|
-
interactivity.load(particlesOptions.interactivity);
|
|
272
|
-
this.interactivity = interactivity;
|
|
273
246
|
this.effectFill = effectData?.fill ?? particlesOptions.effect.fill;
|
|
274
247
|
this.effectClose = effectData?.close ?? particlesOptions.effect.close;
|
|
275
248
|
this.shapeFill = shapeData?.fill ?? particlesOptions.shape.fill;
|
|
@@ -278,10 +251,15 @@
|
|
|
278
251
|
const pathOptions = this.options.move.path;
|
|
279
252
|
this.pathDelay = (0, MathUtils_js_1.getRangeValue)(pathOptions.delay.value) * Constants_js_1.millisecondsToSeconds;
|
|
280
253
|
if (pathOptions.generator) {
|
|
281
|
-
|
|
282
|
-
if (
|
|
283
|
-
this.
|
|
254
|
+
let pathGenerator = this.container.particles.pathGenerators.get(pathOptions.generator);
|
|
255
|
+
if (!pathGenerator) {
|
|
256
|
+
pathGenerator = this.container.particles.availablePathGenerators.get(pathOptions.generator);
|
|
257
|
+
if (pathGenerator) {
|
|
258
|
+
this.container.particles.pathGenerators.set(pathOptions.generator, pathGenerator);
|
|
259
|
+
pathGenerator.init();
|
|
260
|
+
}
|
|
284
261
|
}
|
|
262
|
+
this.pathGenerator = pathGenerator;
|
|
285
263
|
}
|
|
286
264
|
container.retina.initParticle(this);
|
|
287
265
|
this.size = (0, Utils_js_1.initParticleNumericAnimationValue)(this.options.size, pxRatio);
|
|
@@ -302,25 +280,13 @@
|
|
|
302
280
|
this.sides = 24;
|
|
303
281
|
let effectDrawer, shapeDrawer;
|
|
304
282
|
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
|
-
}
|
|
311
|
-
}
|
|
283
|
+
effectDrawer = container.particles.effectDrawers.get(this.effect);
|
|
312
284
|
}
|
|
313
285
|
if (effectDrawer?.loadEffect) {
|
|
314
286
|
effectDrawer.loadEffect(this);
|
|
315
287
|
}
|
|
316
288
|
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
|
-
}
|
|
323
|
-
}
|
|
289
|
+
shapeDrawer = container.particles.shapeDrawers.get(this.shape);
|
|
324
290
|
}
|
|
325
291
|
if (shapeDrawer?.loadShape) {
|
|
326
292
|
shapeDrawer.loadShape(this);
|
|
@@ -338,7 +304,7 @@
|
|
|
338
304
|
}
|
|
339
305
|
effectDrawer?.particleInit?.(container, this);
|
|
340
306
|
shapeDrawer?.particleInit?.(container, this);
|
|
341
|
-
for (const plugin of container.
|
|
307
|
+
for (const plugin of container.particleCreatedPlugins) {
|
|
342
308
|
plugin.particleCreated?.(this);
|
|
343
309
|
}
|
|
344
310
|
}
|
|
@@ -349,6 +315,25 @@
|
|
|
349
315
|
position.y <= canvasSize.height + radius &&
|
|
350
316
|
position.x <= canvasSize.width + radius);
|
|
351
317
|
}
|
|
318
|
+
isShowingBack() {
|
|
319
|
+
if (!this.roll) {
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
const angle = this.roll.angle;
|
|
323
|
+
if (this.roll.horizontal && this.roll.vertical) {
|
|
324
|
+
const normalizedAngle = angle % Constants_js_1.doublePI, adjustedAngle = normalizedAngle < Constants_js_1.defaultAngle ? normalizedAngle + Constants_js_1.doublePI : normalizedAngle;
|
|
325
|
+
return adjustedAngle >= Math.PI * Constants_js_1.half && adjustedAngle < Math.PI * Constants_js_1.triple * Constants_js_1.half;
|
|
326
|
+
}
|
|
327
|
+
if (this.roll.horizontal) {
|
|
328
|
+
const normalizedAngle = (angle + Math.PI * Constants_js_1.half) % (Math.PI * Constants_js_1.double), adjustedAngle = normalizedAngle < Constants_js_1.defaultAngle ? normalizedAngle + Math.PI * Constants_js_1.double : normalizedAngle;
|
|
329
|
+
return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * Constants_js_1.double;
|
|
330
|
+
}
|
|
331
|
+
if (this.roll.vertical) {
|
|
332
|
+
const normalizedAngle = angle % (Math.PI * Constants_js_1.double), adjustedAngle = normalizedAngle < Constants_js_1.defaultAngle ? normalizedAngle + Math.PI * Constants_js_1.double : normalizedAngle;
|
|
333
|
+
return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * Constants_js_1.double;
|
|
334
|
+
}
|
|
335
|
+
return false;
|
|
336
|
+
}
|
|
352
337
|
isVisible() {
|
|
353
338
|
return !this.destroyed && !this.spawning && this.isInsideCanvas();
|
|
354
339
|
}
|
|
@@ -357,6 +342,117 @@
|
|
|
357
342
|
updater.reset?.(this);
|
|
358
343
|
}
|
|
359
344
|
}
|
|
345
|
+
_calcPosition = (position, zIndex) => {
|
|
346
|
+
let tryCount = Constants_js_1.defaultRetryCount, posVec = position ? Vectors_js_1.Vector3d.create(position.x, position.y, zIndex) : undefined;
|
|
347
|
+
const container = this.container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
|
|
348
|
+
while (!signal.aborted) {
|
|
349
|
+
for (const plugin of plugins) {
|
|
350
|
+
const pluginPos = plugin.particlePosition?.(posVec, this);
|
|
351
|
+
if (pluginPos) {
|
|
352
|
+
return Vectors_js_1.Vector3d.create(pluginPos.x, pluginPos.y, zIndex);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
const exactPosition = (0, MathUtils_js_1.calcExactPositionOrRandomFromSize)({
|
|
356
|
+
size: canvasSize,
|
|
357
|
+
position: posVec,
|
|
358
|
+
}), pos = Vectors_js_1.Vector3d.create(exactPosition.x, exactPosition.y, zIndex);
|
|
359
|
+
this._fixHorizontal(pos, radius, outModes.left ?? outModes.default);
|
|
360
|
+
this._fixHorizontal(pos, radius, outModes.right ?? outModes.default);
|
|
361
|
+
this._fixVertical(pos, radius, outModes.top ?? outModes.default);
|
|
362
|
+
this._fixVertical(pos, radius, outModes.bottom ?? outModes.default);
|
|
363
|
+
let isValidPosition = true;
|
|
364
|
+
for (const plugin of container.particles.checkParticlePositionPlugins) {
|
|
365
|
+
isValidPosition = plugin.checkParticlePosition?.(this, pos, tryCount) ?? true;
|
|
366
|
+
if (!isValidPosition) {
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if (isValidPosition) {
|
|
371
|
+
return pos;
|
|
372
|
+
}
|
|
373
|
+
tryCount += Constants_js_1.tryCountIncrement;
|
|
374
|
+
posVec = undefined;
|
|
375
|
+
}
|
|
376
|
+
return posVec;
|
|
377
|
+
};
|
|
378
|
+
_calculateVelocity = () => {
|
|
379
|
+
const baseVelocity = (0, MathUtils_js_1.getParticleBaseVelocity)(this.direction), res = baseVelocity.copy(), moveOptions = this.options.move;
|
|
380
|
+
if (moveOptions.direction === MoveDirection_js_1.MoveDirection.inside || moveOptions.direction === MoveDirection_js_1.MoveDirection.outside) {
|
|
381
|
+
return res;
|
|
382
|
+
}
|
|
383
|
+
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 = {
|
|
384
|
+
left: radOffset - rad * Constants_js_1.half,
|
|
385
|
+
right: radOffset + rad * Constants_js_1.half,
|
|
386
|
+
};
|
|
387
|
+
if (!moveOptions.straight) {
|
|
388
|
+
res.angle += (0, MathUtils_js_1.randomInRangeValue)((0, MathUtils_js_1.setRangeValue)(range.left, range.right));
|
|
389
|
+
}
|
|
390
|
+
if (moveOptions.random && typeof moveOptions.speed === "number") {
|
|
391
|
+
res.length *= (0, MathUtils_js_1.getRandom)();
|
|
392
|
+
}
|
|
393
|
+
return res;
|
|
394
|
+
};
|
|
395
|
+
_fixHorizontal = (pos, radius, outMode) => {
|
|
396
|
+
fixOutMode({
|
|
397
|
+
outMode,
|
|
398
|
+
checkModes: [OutMode_js_1.OutMode.bounce],
|
|
399
|
+
coord: pos.x,
|
|
400
|
+
maxCoord: this.container.canvas.size.width,
|
|
401
|
+
setCb: (value) => (pos.x += value),
|
|
402
|
+
radius,
|
|
403
|
+
});
|
|
404
|
+
};
|
|
405
|
+
_fixVertical = (pos, radius, outMode) => {
|
|
406
|
+
fixOutMode({
|
|
407
|
+
outMode,
|
|
408
|
+
checkModes: [OutMode_js_1.OutMode.bounce],
|
|
409
|
+
coord: pos.y,
|
|
410
|
+
maxCoord: this.container.canvas.size.height,
|
|
411
|
+
setCb: (value) => (pos.y += value),
|
|
412
|
+
radius,
|
|
413
|
+
});
|
|
414
|
+
};
|
|
415
|
+
_getRollColor = color => {
|
|
416
|
+
if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
|
|
417
|
+
return color;
|
|
418
|
+
}
|
|
419
|
+
if (!this.isShowingBack()) {
|
|
420
|
+
return color;
|
|
421
|
+
}
|
|
422
|
+
if (this.backColor) {
|
|
423
|
+
return this.backColor;
|
|
424
|
+
}
|
|
425
|
+
if (this.roll.alter) {
|
|
426
|
+
return (0, CanvasUtils_js_1.alterHsl)(color, this.roll.alter.type, this.roll.alter.value);
|
|
427
|
+
}
|
|
428
|
+
return color;
|
|
429
|
+
};
|
|
430
|
+
_initPosition = position => {
|
|
431
|
+
const container = this.container, zIndexValue = (0, MathUtils_js_1.getRangeValue)(this.options.zIndex.value), initialPosition = this._calcPosition(position, (0, MathUtils_js_1.clamp)(zIndexValue, Constants_js_1.minZ, container.zLayers));
|
|
432
|
+
if (!initialPosition) {
|
|
433
|
+
throw new Error("a valid position cannot be found for particle");
|
|
434
|
+
}
|
|
435
|
+
this.position = initialPosition;
|
|
436
|
+
this.initialPosition = this.position.copy();
|
|
437
|
+
const canvasSize = container.canvas.size;
|
|
438
|
+
this.moveCenter = {
|
|
439
|
+
...(0, Utils_js_1.getPosition)(this.options.move.center, canvasSize),
|
|
440
|
+
radius: this.options.move.center.radius,
|
|
441
|
+
mode: this.options.move.center.mode,
|
|
442
|
+
};
|
|
443
|
+
this.direction = (0, MathUtils_js_1.getParticleDirectionAngle)(this.options.move.direction, this.position, this.moveCenter);
|
|
444
|
+
switch (this.options.move.direction) {
|
|
445
|
+
case MoveDirection_js_1.MoveDirection.inside:
|
|
446
|
+
this.outType = ParticleOutType_js_1.ParticleOutType.inside;
|
|
447
|
+
break;
|
|
448
|
+
case MoveDirection_js_1.MoveDirection.outside:
|
|
449
|
+
this.outType = ParticleOutType_js_1.ParticleOutType.outside;
|
|
450
|
+
break;
|
|
451
|
+
default:
|
|
452
|
+
break;
|
|
453
|
+
}
|
|
454
|
+
this.offset = Vectors_js_1.Vector.origin;
|
|
455
|
+
};
|
|
360
456
|
}
|
|
361
457
|
exports.Particle = Particle;
|
|
362
458
|
});
|