@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/esm/Core/Particle.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Vector, Vector3d } from "./Utils/Vectors.js";
|
|
2
2
|
import { calcExactPositionOrRandomFromSize, clamp, degToRad, getParticleBaseVelocity, getParticleDirectionAngle, getRandom, getRangeValue, randomInRangeValue, setRangeValue, } from "../Utils/MathUtils.js";
|
|
3
|
-
import { decayOffset, defaultAngle, defaultRetryCount, double, half, millisecondsToSeconds, minZ,
|
|
3
|
+
import { decayOffset, defaultAngle, defaultOpacity, defaultRetryCount, defaultTransform, double, doublePI, half, identity, millisecondsToSeconds, minZ, randomColorValue, squareExp, triple, tryCountIncrement, zIndexFactorOffset, } from "./Utils/Constants.js";
|
|
4
4
|
import { deepExtend, getPosition, initParticleNumericAnimationValue, isInArray, itemFromSingleOrMultiple, } from "../Utils/Utils.js";
|
|
5
5
|
import { EventType } from "../Enums/Types/EventType.js";
|
|
6
|
-
import { Interactivity } from "../Options/Classes/Interactivity/Interactivity.js";
|
|
7
6
|
import { MoveDirection } from "../Enums/Directions/MoveDirection.js";
|
|
8
7
|
import { OutMode } from "../Enums/Modes/OutMode.js";
|
|
9
8
|
import { ParticleOutType } from "../Enums/Types/ParticleOutType.js";
|
|
@@ -37,108 +36,67 @@ function fixOutMode(data) {
|
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
export class Particle {
|
|
39
|
+
container;
|
|
40
|
+
backColor;
|
|
41
|
+
bubble;
|
|
42
|
+
color;
|
|
43
|
+
destroyed;
|
|
44
|
+
direction;
|
|
45
|
+
effect;
|
|
46
|
+
effectClose;
|
|
47
|
+
effectData;
|
|
48
|
+
effectFill;
|
|
49
|
+
group;
|
|
50
|
+
id;
|
|
51
|
+
ignoresResizeRatio;
|
|
52
|
+
initialPosition;
|
|
53
|
+
initialVelocity;
|
|
54
|
+
isRotating;
|
|
55
|
+
lastPathTime;
|
|
56
|
+
misplaced;
|
|
57
|
+
moveCenter;
|
|
58
|
+
moveDecay;
|
|
59
|
+
offset;
|
|
60
|
+
opacity;
|
|
61
|
+
options;
|
|
62
|
+
outType;
|
|
63
|
+
pathDelay;
|
|
64
|
+
pathGenerator;
|
|
65
|
+
pathRotation;
|
|
66
|
+
position;
|
|
67
|
+
randomIndexData;
|
|
68
|
+
retina;
|
|
69
|
+
roll;
|
|
70
|
+
rotation;
|
|
71
|
+
shape;
|
|
72
|
+
shapeClose;
|
|
73
|
+
shapeData;
|
|
74
|
+
shapeFill;
|
|
75
|
+
sides;
|
|
76
|
+
size;
|
|
77
|
+
slow;
|
|
78
|
+
spawning;
|
|
79
|
+
strokeColor;
|
|
80
|
+
strokeOpacity;
|
|
81
|
+
strokeWidth;
|
|
82
|
+
unbreakable;
|
|
83
|
+
velocity;
|
|
84
|
+
zIndexFactor;
|
|
85
|
+
_cachedOpacityData = {
|
|
86
|
+
opacity: defaultOpacity,
|
|
87
|
+
strokeOpacity: defaultOpacity,
|
|
88
|
+
};
|
|
89
|
+
_cachedPosition = Vector3d.origin;
|
|
90
|
+
_cachedRotateData = { sin: 0, cos: 0 };
|
|
91
|
+
_cachedTransform = {
|
|
92
|
+
a: 1,
|
|
93
|
+
b: 0,
|
|
94
|
+
c: 0,
|
|
95
|
+
d: 1,
|
|
96
|
+
};
|
|
97
|
+
_engine;
|
|
40
98
|
constructor(engine, container) {
|
|
41
99
|
this.container = container;
|
|
42
|
-
this._calcPosition = (container, position, zIndex, tryCount = defaultRetryCount) => {
|
|
43
|
-
const plugins = container.plugins.values();
|
|
44
|
-
for (const plugin of plugins) {
|
|
45
|
-
const pluginPos = plugin.particlePosition?.(position, this);
|
|
46
|
-
if (pluginPos) {
|
|
47
|
-
return Vector3d.create(pluginPos.x, pluginPos.y, zIndex);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
const canvasSize = container.canvas.size, exactPosition = calcExactPositionOrRandomFromSize({
|
|
51
|
-
size: canvasSize,
|
|
52
|
-
position: position,
|
|
53
|
-
}), pos = Vector3d.create(exactPosition.x, exactPosition.y, zIndex), radius = this.getRadius(), outModes = this.options.move.outModes, fixHorizontal = (outMode) => {
|
|
54
|
-
fixOutMode({
|
|
55
|
-
outMode,
|
|
56
|
-
checkModes: [OutMode.bounce],
|
|
57
|
-
coord: pos.x,
|
|
58
|
-
maxCoord: container.canvas.size.width,
|
|
59
|
-
setCb: (value) => (pos.x += value),
|
|
60
|
-
radius,
|
|
61
|
-
});
|
|
62
|
-
}, fixVertical = (outMode) => {
|
|
63
|
-
fixOutMode({
|
|
64
|
-
outMode,
|
|
65
|
-
checkModes: [OutMode.bounce],
|
|
66
|
-
coord: pos.y,
|
|
67
|
-
maxCoord: container.canvas.size.height,
|
|
68
|
-
setCb: (value) => (pos.y += value),
|
|
69
|
-
radius,
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
fixHorizontal(outModes.left ?? outModes.default);
|
|
73
|
-
fixHorizontal(outModes.right ?? outModes.default);
|
|
74
|
-
fixVertical(outModes.top ?? outModes.default);
|
|
75
|
-
fixVertical(outModes.bottom ?? outModes.default);
|
|
76
|
-
let isValidPosition = true;
|
|
77
|
-
for (const plugin of plugins) {
|
|
78
|
-
isValidPosition = plugin.checkParticlePosition?.(this, pos, tryCount);
|
|
79
|
-
if (isValidPosition === false) {
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (!isValidPosition) {
|
|
84
|
-
return this._calcPosition(container, undefined, zIndex, tryCount + tryCountIncrement);
|
|
85
|
-
}
|
|
86
|
-
return pos;
|
|
87
|
-
};
|
|
88
|
-
this._calculateVelocity = () => {
|
|
89
|
-
const baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy(), moveOptions = this.options.move;
|
|
90
|
-
if (moveOptions.direction === MoveDirection.inside || moveOptions.direction === MoveDirection.outside) {
|
|
91
|
-
return res;
|
|
92
|
-
}
|
|
93
|
-
const rad = degToRad(getRangeValue(moveOptions.angle.value)), radOffset = degToRad(getRangeValue(moveOptions.angle.offset)), range = {
|
|
94
|
-
left: radOffset - rad * half,
|
|
95
|
-
right: radOffset + rad * half,
|
|
96
|
-
};
|
|
97
|
-
if (!moveOptions.straight) {
|
|
98
|
-
res.angle += randomInRangeValue(setRangeValue(range.left, range.right));
|
|
99
|
-
}
|
|
100
|
-
if (moveOptions.random && typeof moveOptions.speed === "number") {
|
|
101
|
-
res.length *= getRandom();
|
|
102
|
-
}
|
|
103
|
-
return res;
|
|
104
|
-
};
|
|
105
|
-
this._getRollColor = color => {
|
|
106
|
-
if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
|
|
107
|
-
return color;
|
|
108
|
-
}
|
|
109
|
-
const backFactor = this.roll.horizontal && this.roll.vertical ? double * rollFactor : rollFactor, backSum = this.roll.horizontal ? Math.PI * half : none, rolled = Math.floor((this.roll.angle + backSum) / (Math.PI / backFactor)) % double;
|
|
110
|
-
if (!rolled) {
|
|
111
|
-
return color;
|
|
112
|
-
}
|
|
113
|
-
if (this.backColor) {
|
|
114
|
-
return this.backColor;
|
|
115
|
-
}
|
|
116
|
-
if (this.roll.alter) {
|
|
117
|
-
return alterHsl(color, this.roll.alter.type, this.roll.alter.value);
|
|
118
|
-
}
|
|
119
|
-
return color;
|
|
120
|
-
};
|
|
121
|
-
this._initPosition = position => {
|
|
122
|
-
const container = this.container, zIndexValue = getRangeValue(this.options.zIndex.value);
|
|
123
|
-
this.position = this._calcPosition(container, position, clamp(zIndexValue, minZ, container.zLayers));
|
|
124
|
-
this.initialPosition = this.position.copy();
|
|
125
|
-
const canvasSize = container.canvas.size;
|
|
126
|
-
this.moveCenter = {
|
|
127
|
-
...getPosition(this.options.move.center, canvasSize),
|
|
128
|
-
radius: this.options.move.center.radius,
|
|
129
|
-
mode: this.options.move.center.mode,
|
|
130
|
-
};
|
|
131
|
-
this.direction = getParticleDirectionAngle(this.options.move.direction, this.position, this.moveCenter);
|
|
132
|
-
switch (this.options.move.direction) {
|
|
133
|
-
case MoveDirection.inside:
|
|
134
|
-
this.outType = ParticleOutType.inside;
|
|
135
|
-
break;
|
|
136
|
-
case MoveDirection.outside:
|
|
137
|
-
this.outType = ParticleOutType.outside;
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
this.offset = Vector.origin;
|
|
141
|
-
};
|
|
142
100
|
this._engine = engine;
|
|
143
101
|
}
|
|
144
102
|
destroy(override) {
|
|
@@ -148,9 +106,9 @@ export class Particle {
|
|
|
148
106
|
this.destroyed = true;
|
|
149
107
|
this.bubble.inRange = false;
|
|
150
108
|
this.slow.inRange = false;
|
|
151
|
-
const container = this.container, pathGenerator = this.pathGenerator, shapeDrawer = this.shape ? container.shapeDrawers.get(this.shape) : undefined;
|
|
109
|
+
const container = this.container, pathGenerator = this.pathGenerator, shapeDrawer = this.shape ? container.particles.shapeDrawers.get(this.shape) : undefined;
|
|
152
110
|
shapeDrawer?.particleDestroy?.(this);
|
|
153
|
-
for (const plugin of container.
|
|
111
|
+
for (const plugin of container.particleDestroyedPlugins) {
|
|
154
112
|
plugin.particleDestroyed?.(this, override);
|
|
155
113
|
}
|
|
156
114
|
for (const updater of container.particles.updaters) {
|
|
@@ -166,9 +124,7 @@ export class Particle {
|
|
|
166
124
|
}
|
|
167
125
|
draw(delta) {
|
|
168
126
|
const container = this.container, canvas = container.canvas;
|
|
169
|
-
|
|
170
|
-
canvas.drawParticlePlugin(plugin, this, delta);
|
|
171
|
-
}
|
|
127
|
+
canvas.drawParticlePlugins(this, delta);
|
|
172
128
|
canvas.drawParticle(this, delta);
|
|
173
129
|
}
|
|
174
130
|
getAngle() {
|
|
@@ -180,21 +136,44 @@ export class Particle {
|
|
|
180
136
|
getMass() {
|
|
181
137
|
return this.getRadius() ** squareExp * Math.PI * half;
|
|
182
138
|
}
|
|
139
|
+
getOpacity() {
|
|
140
|
+
const zIndexOptions = this.options.zIndex, zIndexFactor = zIndexFactorOffset - this.zIndexFactor, zOpacityFactor = zIndexFactor ** zIndexOptions.opacityRate, opacity = this.bubble.opacity ?? getRangeValue(this.opacity?.value ?? defaultOpacity), strokeOpacity = this.strokeOpacity ?? opacity;
|
|
141
|
+
this._cachedOpacityData.opacity = opacity * zOpacityFactor;
|
|
142
|
+
this._cachedOpacityData.strokeOpacity = strokeOpacity * zOpacityFactor;
|
|
143
|
+
return this._cachedOpacityData;
|
|
144
|
+
}
|
|
183
145
|
getPosition() {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
};
|
|
146
|
+
this._cachedPosition.x = this.position.x + this.offset.x;
|
|
147
|
+
this._cachedPosition.y = this.position.y + this.offset.y;
|
|
148
|
+
this._cachedPosition.z = this.position.z;
|
|
149
|
+
return this._cachedPosition;
|
|
189
150
|
}
|
|
190
151
|
getRadius() {
|
|
191
152
|
return this.bubble.radius ?? this.size.value;
|
|
192
153
|
}
|
|
154
|
+
getRotateData() {
|
|
155
|
+
const angle = this.getAngle();
|
|
156
|
+
this._cachedRotateData.sin = Math.sin(angle);
|
|
157
|
+
this._cachedRotateData.cos = Math.cos(angle);
|
|
158
|
+
return this._cachedRotateData;
|
|
159
|
+
}
|
|
193
160
|
getStrokeColor() {
|
|
194
161
|
return this._getRollColor(this.bubble.color ?? getHslFromAnimation(this.strokeColor));
|
|
195
162
|
}
|
|
163
|
+
getTransformData(externalTransform) {
|
|
164
|
+
const rotateData = this.getRotateData(), rotating = this.isRotating;
|
|
165
|
+
this._cachedTransform.a = rotateData.cos * (externalTransform.a ?? defaultTransform.a);
|
|
166
|
+
this._cachedTransform.b = rotating
|
|
167
|
+
? rotateData.sin * (externalTransform.b ?? identity)
|
|
168
|
+
: (externalTransform.b ?? defaultTransform.b);
|
|
169
|
+
this._cachedTransform.c = rotating
|
|
170
|
+
? -rotateData.sin * (externalTransform.c ?? identity)
|
|
171
|
+
: (externalTransform.c ?? defaultTransform.c);
|
|
172
|
+
this._cachedTransform.d = rotateData.cos * (externalTransform.d ?? defaultTransform.d);
|
|
173
|
+
return this._cachedTransform;
|
|
174
|
+
}
|
|
196
175
|
init(id, position, overrideOptions, group) {
|
|
197
|
-
const container = this.container
|
|
176
|
+
const container = this.container;
|
|
198
177
|
this.id = id;
|
|
199
178
|
this.group = group;
|
|
200
179
|
this.effectClose = true;
|
|
@@ -234,16 +213,14 @@ export class Particle {
|
|
|
234
213
|
}
|
|
235
214
|
}
|
|
236
215
|
if (this.effect === randomColorValue) {
|
|
237
|
-
const availableEffects = [...this.container.effectDrawers.keys()];
|
|
216
|
+
const availableEffects = [...this.container.particles.effectDrawers.keys()];
|
|
238
217
|
this.effect = availableEffects[Math.floor(getRandom() * availableEffects.length)];
|
|
239
218
|
}
|
|
240
219
|
if (this.shape === randomColorValue) {
|
|
241
|
-
const availableShapes = [...this.container.shapeDrawers.keys()];
|
|
220
|
+
const availableShapes = [...this.container.particles.shapeDrawers.keys()];
|
|
242
221
|
this.shape = availableShapes[Math.floor(getRandom() * availableShapes.length)];
|
|
243
222
|
}
|
|
244
|
-
this.effectData = this.effect
|
|
245
|
-
? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates)
|
|
246
|
-
: undefined;
|
|
223
|
+
this.effectData = this.effect ? loadEffectData(this.effect, effectOptions, this.id, reduceDuplicates) : undefined;
|
|
247
224
|
this.shapeData = this.shape ? loadShapeData(this.shape, shapeOptions, this.id, reduceDuplicates) : undefined;
|
|
248
225
|
particlesOptions.load(overrideOptions);
|
|
249
226
|
const effectData = this.effectData;
|
|
@@ -254,10 +231,6 @@ export class Particle {
|
|
|
254
231
|
if (shapeData) {
|
|
255
232
|
particlesOptions.load(shapeData.particles);
|
|
256
233
|
}
|
|
257
|
-
const interactivity = new Interactivity(engine, container);
|
|
258
|
-
interactivity.load(container.actualOptions.interactivity);
|
|
259
|
-
interactivity.load(particlesOptions.interactivity);
|
|
260
|
-
this.interactivity = interactivity;
|
|
261
234
|
this.effectFill = effectData?.fill ?? particlesOptions.effect.fill;
|
|
262
235
|
this.effectClose = effectData?.close ?? particlesOptions.effect.close;
|
|
263
236
|
this.shapeFill = shapeData?.fill ?? particlesOptions.shape.fill;
|
|
@@ -266,10 +239,15 @@ export class Particle {
|
|
|
266
239
|
const pathOptions = this.options.move.path;
|
|
267
240
|
this.pathDelay = getRangeValue(pathOptions.delay.value) * millisecondsToSeconds;
|
|
268
241
|
if (pathOptions.generator) {
|
|
269
|
-
|
|
270
|
-
if (
|
|
271
|
-
this.
|
|
242
|
+
let pathGenerator = this.container.particles.pathGenerators.get(pathOptions.generator);
|
|
243
|
+
if (!pathGenerator) {
|
|
244
|
+
pathGenerator = this.container.particles.availablePathGenerators.get(pathOptions.generator);
|
|
245
|
+
if (pathGenerator) {
|
|
246
|
+
this.container.particles.pathGenerators.set(pathOptions.generator, pathGenerator);
|
|
247
|
+
pathGenerator.init();
|
|
248
|
+
}
|
|
272
249
|
}
|
|
250
|
+
this.pathGenerator = pathGenerator;
|
|
273
251
|
}
|
|
274
252
|
container.retina.initParticle(this);
|
|
275
253
|
this.size = initParticleNumericAnimationValue(this.options.size, pxRatio);
|
|
@@ -290,25 +268,13 @@ export class Particle {
|
|
|
290
268
|
this.sides = 24;
|
|
291
269
|
let effectDrawer, shapeDrawer;
|
|
292
270
|
if (this.effect) {
|
|
293
|
-
effectDrawer = container.effectDrawers.get(this.effect);
|
|
294
|
-
if (!effectDrawer) {
|
|
295
|
-
effectDrawer = this._engine.getEffectDrawer(this.effect);
|
|
296
|
-
if (effectDrawer) {
|
|
297
|
-
container.effectDrawers.set(this.effect, effectDrawer);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
271
|
+
effectDrawer = container.particles.effectDrawers.get(this.effect);
|
|
300
272
|
}
|
|
301
273
|
if (effectDrawer?.loadEffect) {
|
|
302
274
|
effectDrawer.loadEffect(this);
|
|
303
275
|
}
|
|
304
276
|
if (this.shape) {
|
|
305
|
-
shapeDrawer = container.shapeDrawers.get(this.shape);
|
|
306
|
-
if (!shapeDrawer) {
|
|
307
|
-
shapeDrawer = this._engine.getShapeDrawer(this.shape);
|
|
308
|
-
if (shapeDrawer) {
|
|
309
|
-
container.shapeDrawers.set(this.shape, shapeDrawer);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
277
|
+
shapeDrawer = container.particles.shapeDrawers.get(this.shape);
|
|
312
278
|
}
|
|
313
279
|
if (shapeDrawer?.loadShape) {
|
|
314
280
|
shapeDrawer.loadShape(this);
|
|
@@ -326,7 +292,7 @@ export class Particle {
|
|
|
326
292
|
}
|
|
327
293
|
effectDrawer?.particleInit?.(container, this);
|
|
328
294
|
shapeDrawer?.particleInit?.(container, this);
|
|
329
|
-
for (const plugin of container.
|
|
295
|
+
for (const plugin of container.particleCreatedPlugins) {
|
|
330
296
|
plugin.particleCreated?.(this);
|
|
331
297
|
}
|
|
332
298
|
}
|
|
@@ -337,6 +303,25 @@ export class Particle {
|
|
|
337
303
|
position.y <= canvasSize.height + radius &&
|
|
338
304
|
position.x <= canvasSize.width + radius);
|
|
339
305
|
}
|
|
306
|
+
isShowingBack() {
|
|
307
|
+
if (!this.roll) {
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
const angle = this.roll.angle;
|
|
311
|
+
if (this.roll.horizontal && this.roll.vertical) {
|
|
312
|
+
const normalizedAngle = angle % doublePI, adjustedAngle = normalizedAngle < defaultAngle ? normalizedAngle + doublePI : normalizedAngle;
|
|
313
|
+
return adjustedAngle >= Math.PI * half && adjustedAngle < Math.PI * triple * half;
|
|
314
|
+
}
|
|
315
|
+
if (this.roll.horizontal) {
|
|
316
|
+
const normalizedAngle = (angle + Math.PI * half) % (Math.PI * double), adjustedAngle = normalizedAngle < defaultAngle ? normalizedAngle + Math.PI * double : normalizedAngle;
|
|
317
|
+
return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
|
|
318
|
+
}
|
|
319
|
+
if (this.roll.vertical) {
|
|
320
|
+
const normalizedAngle = angle % (Math.PI * double), adjustedAngle = normalizedAngle < defaultAngle ? normalizedAngle + Math.PI * double : normalizedAngle;
|
|
321
|
+
return adjustedAngle >= Math.PI && adjustedAngle < Math.PI * double;
|
|
322
|
+
}
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
340
325
|
isVisible() {
|
|
341
326
|
return !this.destroyed && !this.spawning && this.isInsideCanvas();
|
|
342
327
|
}
|
|
@@ -345,4 +330,115 @@ export class Particle {
|
|
|
345
330
|
updater.reset?.(this);
|
|
346
331
|
}
|
|
347
332
|
}
|
|
333
|
+
_calcPosition = (position, zIndex) => {
|
|
334
|
+
let tryCount = defaultRetryCount, posVec = position ? Vector3d.create(position.x, position.y, zIndex) : undefined;
|
|
335
|
+
const container = this.container, plugins = container.particlePositionPlugins, outModes = this.options.move.outModes, radius = this.getRadius(), canvasSize = container.canvas.size, abortController = new AbortController(), { signal } = abortController;
|
|
336
|
+
while (!signal.aborted) {
|
|
337
|
+
for (const plugin of plugins) {
|
|
338
|
+
const pluginPos = plugin.particlePosition?.(posVec, this);
|
|
339
|
+
if (pluginPos) {
|
|
340
|
+
return Vector3d.create(pluginPos.x, pluginPos.y, zIndex);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
const exactPosition = calcExactPositionOrRandomFromSize({
|
|
344
|
+
size: canvasSize,
|
|
345
|
+
position: posVec,
|
|
346
|
+
}), pos = Vector3d.create(exactPosition.x, exactPosition.y, zIndex);
|
|
347
|
+
this._fixHorizontal(pos, radius, outModes.left ?? outModes.default);
|
|
348
|
+
this._fixHorizontal(pos, radius, outModes.right ?? outModes.default);
|
|
349
|
+
this._fixVertical(pos, radius, outModes.top ?? outModes.default);
|
|
350
|
+
this._fixVertical(pos, radius, outModes.bottom ?? outModes.default);
|
|
351
|
+
let isValidPosition = true;
|
|
352
|
+
for (const plugin of container.particles.checkParticlePositionPlugins) {
|
|
353
|
+
isValidPosition = plugin.checkParticlePosition?.(this, pos, tryCount) ?? true;
|
|
354
|
+
if (!isValidPosition) {
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (isValidPosition) {
|
|
359
|
+
return pos;
|
|
360
|
+
}
|
|
361
|
+
tryCount += tryCountIncrement;
|
|
362
|
+
posVec = undefined;
|
|
363
|
+
}
|
|
364
|
+
return posVec;
|
|
365
|
+
};
|
|
366
|
+
_calculateVelocity = () => {
|
|
367
|
+
const baseVelocity = getParticleBaseVelocity(this.direction), res = baseVelocity.copy(), moveOptions = this.options.move;
|
|
368
|
+
if (moveOptions.direction === MoveDirection.inside || moveOptions.direction === MoveDirection.outside) {
|
|
369
|
+
return res;
|
|
370
|
+
}
|
|
371
|
+
const rad = degToRad(getRangeValue(moveOptions.angle.value)), radOffset = degToRad(getRangeValue(moveOptions.angle.offset)), range = {
|
|
372
|
+
left: radOffset - rad * half,
|
|
373
|
+
right: radOffset + rad * half,
|
|
374
|
+
};
|
|
375
|
+
if (!moveOptions.straight) {
|
|
376
|
+
res.angle += randomInRangeValue(setRangeValue(range.left, range.right));
|
|
377
|
+
}
|
|
378
|
+
if (moveOptions.random && typeof moveOptions.speed === "number") {
|
|
379
|
+
res.length *= getRandom();
|
|
380
|
+
}
|
|
381
|
+
return res;
|
|
382
|
+
};
|
|
383
|
+
_fixHorizontal = (pos, radius, outMode) => {
|
|
384
|
+
fixOutMode({
|
|
385
|
+
outMode,
|
|
386
|
+
checkModes: [OutMode.bounce],
|
|
387
|
+
coord: pos.x,
|
|
388
|
+
maxCoord: this.container.canvas.size.width,
|
|
389
|
+
setCb: (value) => (pos.x += value),
|
|
390
|
+
radius,
|
|
391
|
+
});
|
|
392
|
+
};
|
|
393
|
+
_fixVertical = (pos, radius, outMode) => {
|
|
394
|
+
fixOutMode({
|
|
395
|
+
outMode,
|
|
396
|
+
checkModes: [OutMode.bounce],
|
|
397
|
+
coord: pos.y,
|
|
398
|
+
maxCoord: this.container.canvas.size.height,
|
|
399
|
+
setCb: (value) => (pos.y += value),
|
|
400
|
+
radius,
|
|
401
|
+
});
|
|
402
|
+
};
|
|
403
|
+
_getRollColor = color => {
|
|
404
|
+
if (!color || !this.roll || (!this.backColor && !this.roll.alter)) {
|
|
405
|
+
return color;
|
|
406
|
+
}
|
|
407
|
+
if (!this.isShowingBack()) {
|
|
408
|
+
return color;
|
|
409
|
+
}
|
|
410
|
+
if (this.backColor) {
|
|
411
|
+
return this.backColor;
|
|
412
|
+
}
|
|
413
|
+
if (this.roll.alter) {
|
|
414
|
+
return alterHsl(color, this.roll.alter.type, this.roll.alter.value);
|
|
415
|
+
}
|
|
416
|
+
return color;
|
|
417
|
+
};
|
|
418
|
+
_initPosition = position => {
|
|
419
|
+
const container = this.container, zIndexValue = getRangeValue(this.options.zIndex.value), initialPosition = this._calcPosition(position, clamp(zIndexValue, minZ, container.zLayers));
|
|
420
|
+
if (!initialPosition) {
|
|
421
|
+
throw new Error("a valid position cannot be found for particle");
|
|
422
|
+
}
|
|
423
|
+
this.position = initialPosition;
|
|
424
|
+
this.initialPosition = this.position.copy();
|
|
425
|
+
const canvasSize = container.canvas.size;
|
|
426
|
+
this.moveCenter = {
|
|
427
|
+
...getPosition(this.options.move.center, canvasSize),
|
|
428
|
+
radius: this.options.move.center.radius,
|
|
429
|
+
mode: this.options.move.center.mode,
|
|
430
|
+
};
|
|
431
|
+
this.direction = getParticleDirectionAngle(this.options.move.direction, this.position, this.moveCenter);
|
|
432
|
+
switch (this.options.move.direction) {
|
|
433
|
+
case MoveDirection.inside:
|
|
434
|
+
this.outType = ParticleOutType.inside;
|
|
435
|
+
break;
|
|
436
|
+
case MoveDirection.outside:
|
|
437
|
+
this.outType = ParticleOutType.outside;
|
|
438
|
+
break;
|
|
439
|
+
default:
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
this.offset = Vector.origin;
|
|
443
|
+
};
|
|
348
444
|
}
|