@tsparticles/engine 4.0.0-alpha.0 → 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 +219 -195
- 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/cjs/Core/Canvas.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { clear,
|
|
1
|
+
import { clear, drawParticle, drawParticlePlugin, paintBase, paintImage } from "../Utils/CanvasUtils.js";
|
|
2
2
|
import { cloneStyle, getFullScreenStyle, safeMatchMedia, safeMutationObserver } from "../Utils/Utils.js";
|
|
3
|
-
import {
|
|
3
|
+
import { defaultTransformValue, generatedAttribute, minimumSize, zIndexFactorOffset } from "./Utils/Constants.js";
|
|
4
4
|
import { getStyleFromHsl, getStyleFromRgb, rangeColorToHsl, rangeColorToRgb } from "../Utils/ColorUtils.js";
|
|
5
|
+
const fColorIndex = 0, sColorIndex = 1;
|
|
5
6
|
function setTransformValue(factor, newFactor, key) {
|
|
6
7
|
const newValue = newFactor[key];
|
|
7
8
|
if (newValue !== undefined) {
|
|
@@ -38,115 +39,35 @@ function setStyle(canvas, style, important = false) {
|
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
export class Canvas {
|
|
42
|
+
container;
|
|
43
|
+
element;
|
|
44
|
+
size;
|
|
45
|
+
_canvasClearPlugins;
|
|
46
|
+
_canvasPaintPlugins;
|
|
47
|
+
_canvasSettings;
|
|
48
|
+
_clearDrawPlugins;
|
|
49
|
+
_colorPlugins;
|
|
50
|
+
_context;
|
|
51
|
+
_drawParticlePlugins;
|
|
52
|
+
_drawParticlesCleanupPlugins;
|
|
53
|
+
_drawParticlesSetupPlugins;
|
|
54
|
+
_drawPlugins;
|
|
55
|
+
_drawSettingsCleanupPlugins;
|
|
56
|
+
_drawSettingsSetupPlugins;
|
|
57
|
+
_engine;
|
|
58
|
+
_generated;
|
|
59
|
+
_mutationObserver;
|
|
60
|
+
_originalStyle;
|
|
61
|
+
_pointerEvents;
|
|
62
|
+
_postDrawUpdaters;
|
|
63
|
+
_preDrawUpdaters;
|
|
64
|
+
_resizePlugins;
|
|
65
|
+
_reusableColorStyles = {};
|
|
66
|
+
_reusablePluginColors = [undefined, undefined];
|
|
67
|
+
_reusableTransform = {};
|
|
68
|
+
_standardSize;
|
|
41
69
|
constructor(container, engine) {
|
|
42
70
|
this.container = container;
|
|
43
|
-
this._applyPostDrawUpdaters = particle => {
|
|
44
|
-
for (const updater of this._postDrawUpdaters) {
|
|
45
|
-
updater.afterDraw?.(particle);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
this._applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
|
|
49
|
-
for (const updater of this._preDrawUpdaters) {
|
|
50
|
-
if (updater.getColorStyles) {
|
|
51
|
-
const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
|
|
52
|
-
if (fill) {
|
|
53
|
-
colorStyles.fill = fill;
|
|
54
|
-
}
|
|
55
|
-
if (stroke) {
|
|
56
|
-
colorStyles.stroke = stroke;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
if (updater.getTransformValues) {
|
|
60
|
-
const updaterTransform = updater.getTransformValues(particle);
|
|
61
|
-
for (const key in updaterTransform) {
|
|
62
|
-
setTransformValue(transform, updaterTransform, key);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
updater.beforeDraw?.(particle);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
this._applyResizePlugins = () => {
|
|
69
|
-
for (const plugin of this._resizePlugins) {
|
|
70
|
-
plugin.resize?.();
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
this._getPluginParticleColors = particle => {
|
|
74
|
-
let fColor, sColor;
|
|
75
|
-
for (const plugin of this._colorPlugins) {
|
|
76
|
-
if (!fColor && plugin.particleFillColor) {
|
|
77
|
-
fColor = rangeColorToHsl(this._engine, plugin.particleFillColor(particle));
|
|
78
|
-
}
|
|
79
|
-
if (!sColor && plugin.particleStrokeColor) {
|
|
80
|
-
sColor = rangeColorToHsl(this._engine, plugin.particleStrokeColor(particle));
|
|
81
|
-
}
|
|
82
|
-
if (fColor && sColor) {
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return [fColor, sColor];
|
|
87
|
-
};
|
|
88
|
-
this._initStyle = () => {
|
|
89
|
-
const element = this.element, options = this.container.actualOptions;
|
|
90
|
-
if (!element) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
if (this._fullScreen) {
|
|
94
|
-
this._setFullScreenStyle();
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
this._resetOriginalStyle();
|
|
98
|
-
}
|
|
99
|
-
for (const key in options.style) {
|
|
100
|
-
if (!key || !Object.prototype.hasOwnProperty.call(options.style, key)) {
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
const value = options.style[key];
|
|
104
|
-
if (!value) {
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
element.style.setProperty(key, value, "important");
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
this._repairStyle = () => {
|
|
111
|
-
const element = this.element;
|
|
112
|
-
if (!element) {
|
|
113
|
-
return;
|
|
114
|
-
}
|
|
115
|
-
this._safeMutationObserver(observer => {
|
|
116
|
-
observer.disconnect();
|
|
117
|
-
});
|
|
118
|
-
this._initStyle();
|
|
119
|
-
this.initBackground();
|
|
120
|
-
const pointerEvents = this._pointerEvents;
|
|
121
|
-
element.style.pointerEvents = pointerEvents;
|
|
122
|
-
element.setAttribute("pointer-events", pointerEvents);
|
|
123
|
-
this._safeMutationObserver(observer => {
|
|
124
|
-
if (!(element instanceof Node)) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
observer.observe(element, { attributes: true });
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
this._resetOriginalStyle = () => {
|
|
131
|
-
const element = this.element, originalStyle = this._originalStyle;
|
|
132
|
-
if (!element || !originalStyle) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
setStyle(element, originalStyle, true);
|
|
136
|
-
};
|
|
137
|
-
this._safeMutationObserver = callback => {
|
|
138
|
-
if (!this._mutationObserver) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
callback(this._mutationObserver);
|
|
142
|
-
};
|
|
143
|
-
this._setFullScreenStyle = () => {
|
|
144
|
-
const element = this.element;
|
|
145
|
-
if (!element) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
setStyle(element, getFullScreenStyle(this.container.actualOptions.fullScreen.zIndex), true);
|
|
149
|
-
};
|
|
150
71
|
this._engine = engine;
|
|
151
72
|
this._standardSize = {
|
|
152
73
|
height: 0,
|
|
@@ -163,8 +84,20 @@ export class Canvas {
|
|
|
163
84
|
this._postDrawUpdaters = [];
|
|
164
85
|
this._resizePlugins = [];
|
|
165
86
|
this._colorPlugins = [];
|
|
87
|
+
this._canvasClearPlugins = [];
|
|
88
|
+
this._canvasPaintPlugins = [];
|
|
89
|
+
this._clearDrawPlugins = [];
|
|
90
|
+
this._drawParticlePlugins = [];
|
|
91
|
+
this._drawParticlesCleanupPlugins = [];
|
|
92
|
+
this._drawParticlesSetupPlugins = [];
|
|
93
|
+
this._drawPlugins = [];
|
|
94
|
+
this._drawSettingsSetupPlugins = [];
|
|
95
|
+
this._drawSettingsCleanupPlugins = [];
|
|
166
96
|
this._pointerEvents = "none";
|
|
167
97
|
}
|
|
98
|
+
get settings() {
|
|
99
|
+
return this._canvasSettings;
|
|
100
|
+
}
|
|
168
101
|
get _fullScreen() {
|
|
169
102
|
return this.container.actualOptions.fullScreen.enable;
|
|
170
103
|
}
|
|
@@ -178,9 +111,10 @@ export class Canvas {
|
|
|
178
111
|
}
|
|
179
112
|
clear() {
|
|
180
113
|
let pluginHandled = false;
|
|
181
|
-
for (const plugin of this.
|
|
182
|
-
|
|
183
|
-
|
|
114
|
+
for (const plugin of this._canvasClearPlugins) {
|
|
115
|
+
pluginHandled = plugin.canvasClear?.() ?? false;
|
|
116
|
+
if (pluginHandled) {
|
|
117
|
+
break;
|
|
184
118
|
}
|
|
185
119
|
}
|
|
186
120
|
if (pluginHandled) {
|
|
@@ -188,11 +122,6 @@ export class Canvas {
|
|
|
188
122
|
}
|
|
189
123
|
this.canvasClear();
|
|
190
124
|
}
|
|
191
|
-
clearDrawPlugin(plugin, delta) {
|
|
192
|
-
this.draw(ctx => {
|
|
193
|
-
clearDrawPlugin(ctx, plugin, delta);
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
125
|
destroy() {
|
|
197
126
|
this.stop();
|
|
198
127
|
if (this._generated) {
|
|
@@ -207,6 +136,15 @@ export class Canvas {
|
|
|
207
136
|
this._postDrawUpdaters = [];
|
|
208
137
|
this._resizePlugins = [];
|
|
209
138
|
this._colorPlugins = [];
|
|
139
|
+
this._canvasClearPlugins = [];
|
|
140
|
+
this._canvasPaintPlugins = [];
|
|
141
|
+
this._clearDrawPlugins = [];
|
|
142
|
+
this._drawParticlePlugins = [];
|
|
143
|
+
this._drawParticlesCleanupPlugins = [];
|
|
144
|
+
this._drawParticlesSetupPlugins = [];
|
|
145
|
+
this._drawPlugins = [];
|
|
146
|
+
this._drawSettingsSetupPlugins = [];
|
|
147
|
+
this._drawSettingsCleanupPlugins = [];
|
|
210
148
|
}
|
|
211
149
|
draw(cb) {
|
|
212
150
|
const ctx = this._context;
|
|
@@ -230,22 +168,15 @@ export class Canvas {
|
|
|
230
168
|
if (!fColor && !sColor) {
|
|
231
169
|
return;
|
|
232
170
|
}
|
|
233
|
-
const container = this.container, zIndexOptions = particle.options.zIndex, zIndexFactor = zIndexFactorOffset - particle.zIndexFactor,
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
return getStyleFromHsl(fColor, container.hdr, zOpacity);
|
|
238
|
-
}, colorStyles = {
|
|
239
|
-
fill: getFillStyle(),
|
|
240
|
-
}, getStrokestyle = () => {
|
|
241
|
-
if (!sColor) {
|
|
242
|
-
return colorStyles.fill;
|
|
243
|
-
}
|
|
244
|
-
return getStyleFromHsl(sColor, container.hdr, zStrokeOpacity);
|
|
245
|
-
};
|
|
246
|
-
colorStyles.stroke = getStrokestyle();
|
|
171
|
+
const container = this.container, zIndexOptions = particle.options.zIndex, zIndexFactor = zIndexFactorOffset - particle.zIndexFactor, { opacity, strokeOpacity } = particle.getOpacity(), transform = this._reusableTransform, colorStyles = this._reusableColorStyles, fill = fColor ? getStyleFromHsl(fColor, container.hdr, opacity) : undefined, stroke = sColor ? getStyleFromHsl(sColor, container.hdr, strokeOpacity) : fill;
|
|
172
|
+
transform.a = transform.b = transform.c = transform.d = undefined;
|
|
173
|
+
colorStyles.fill = fill;
|
|
174
|
+
colorStyles.stroke = stroke;
|
|
247
175
|
this.draw((context) => {
|
|
248
|
-
|
|
176
|
+
for (const plugin of this._drawParticlesSetupPlugins) {
|
|
177
|
+
plugin.drawParticleSetup?.(context, particle, delta);
|
|
178
|
+
}
|
|
179
|
+
this._applyPreDrawUpdaters(context, particle, radius, opacity, colorStyles, transform);
|
|
249
180
|
drawParticle({
|
|
250
181
|
container,
|
|
251
182
|
context,
|
|
@@ -253,34 +184,40 @@ export class Canvas {
|
|
|
253
184
|
delta,
|
|
254
185
|
colorStyles,
|
|
255
186
|
radius: radius * zIndexFactor ** zIndexOptions.sizeRate,
|
|
256
|
-
opacity:
|
|
187
|
+
opacity: opacity,
|
|
257
188
|
transform,
|
|
258
189
|
});
|
|
190
|
+
this._applyPostDrawUpdaters(particle);
|
|
191
|
+
for (const plugin of this._drawParticlesCleanupPlugins) {
|
|
192
|
+
plugin.drawParticleCleanup?.(context, particle, delta);
|
|
193
|
+
}
|
|
259
194
|
});
|
|
260
|
-
this._applyPostDrawUpdaters(particle);
|
|
261
195
|
}
|
|
262
|
-
|
|
196
|
+
drawParticlePlugins(particle, delta) {
|
|
263
197
|
this.draw(ctx => {
|
|
264
|
-
|
|
198
|
+
for (const plugin of this._drawParticlePlugins) {
|
|
199
|
+
drawParticlePlugin(ctx, plugin, particle, delta);
|
|
200
|
+
}
|
|
265
201
|
});
|
|
266
202
|
}
|
|
267
203
|
drawParticles(delta) {
|
|
268
|
-
const { particles
|
|
204
|
+
const { particles } = this.container;
|
|
269
205
|
this.clear();
|
|
270
206
|
particles.update(delta);
|
|
271
|
-
for (const plugin of plugins.values()) {
|
|
272
|
-
this.drawPlugin(plugin, delta);
|
|
273
|
-
}
|
|
274
|
-
this.draw(() => {
|
|
275
|
-
particles.drawParticles(delta);
|
|
276
|
-
});
|
|
277
|
-
for (const plugin of plugins.values()) {
|
|
278
|
-
this.clearDrawPlugin(plugin, delta);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
drawPlugin(plugin, delta) {
|
|
282
207
|
this.draw(ctx => {
|
|
283
|
-
|
|
208
|
+
for (const plugin of this._drawSettingsSetupPlugins) {
|
|
209
|
+
plugin.drawSettingsSetup?.(ctx, delta);
|
|
210
|
+
}
|
|
211
|
+
for (const plugin of this._drawPlugins) {
|
|
212
|
+
plugin.draw?.(ctx, delta);
|
|
213
|
+
}
|
|
214
|
+
particles.drawParticles(delta);
|
|
215
|
+
for (const plugin of this._clearDrawPlugins) {
|
|
216
|
+
plugin.clearDraw?.(ctx, delta);
|
|
217
|
+
}
|
|
218
|
+
for (const plugin of this._drawSettingsCleanupPlugins) {
|
|
219
|
+
plugin.drawSettingsCleanup?.(ctx, delta);
|
|
220
|
+
}
|
|
284
221
|
});
|
|
285
222
|
}
|
|
286
223
|
init() {
|
|
@@ -326,13 +263,50 @@ export class Canvas {
|
|
|
326
263
|
}
|
|
327
264
|
initPlugins() {
|
|
328
265
|
this._resizePlugins = [];
|
|
329
|
-
|
|
266
|
+
this._colorPlugins = [];
|
|
267
|
+
this._canvasClearPlugins = [];
|
|
268
|
+
this._canvasPaintPlugins = [];
|
|
269
|
+
this._clearDrawPlugins = [];
|
|
270
|
+
this._drawParticlePlugins = [];
|
|
271
|
+
this._drawParticlesSetupPlugins = [];
|
|
272
|
+
this._drawParticlesCleanupPlugins = [];
|
|
273
|
+
this._drawPlugins = [];
|
|
274
|
+
this._drawSettingsSetupPlugins = [];
|
|
275
|
+
this._drawSettingsCleanupPlugins = [];
|
|
276
|
+
for (const plugin of this.container.plugins) {
|
|
330
277
|
if (plugin.resize) {
|
|
331
278
|
this._resizePlugins.push(plugin);
|
|
332
279
|
}
|
|
333
280
|
if (plugin.particleFillColor ?? plugin.particleStrokeColor) {
|
|
334
281
|
this._colorPlugins.push(plugin);
|
|
335
282
|
}
|
|
283
|
+
if (plugin.canvasClear) {
|
|
284
|
+
this._canvasClearPlugins.push(plugin);
|
|
285
|
+
}
|
|
286
|
+
if (plugin.canvasPaint) {
|
|
287
|
+
this._canvasPaintPlugins.push(plugin);
|
|
288
|
+
}
|
|
289
|
+
if (plugin.drawParticle) {
|
|
290
|
+
this._drawParticlePlugins.push(plugin);
|
|
291
|
+
}
|
|
292
|
+
if (plugin.drawParticleSetup) {
|
|
293
|
+
this._drawParticlesSetupPlugins.push(plugin);
|
|
294
|
+
}
|
|
295
|
+
if (plugin.drawParticleCleanup) {
|
|
296
|
+
this._drawParticlesCleanupPlugins.push(plugin);
|
|
297
|
+
}
|
|
298
|
+
if (plugin.draw) {
|
|
299
|
+
this._drawPlugins.push(plugin);
|
|
300
|
+
}
|
|
301
|
+
if (plugin.drawSettingsSetup) {
|
|
302
|
+
this._drawSettingsSetupPlugins.push(plugin);
|
|
303
|
+
}
|
|
304
|
+
if (plugin.drawSettingsCleanup) {
|
|
305
|
+
this._drawSettingsCleanupPlugins.push(plugin);
|
|
306
|
+
}
|
|
307
|
+
if (plugin.clearDraw) {
|
|
308
|
+
this._clearDrawPlugins.push(plugin);
|
|
309
|
+
}
|
|
336
310
|
}
|
|
337
311
|
}
|
|
338
312
|
initUpdaters() {
|
|
@@ -364,12 +338,13 @@ export class Canvas {
|
|
|
364
338
|
canvas.height = retinaSize.height = standardSize.height * pxRatio;
|
|
365
339
|
canvas.width = retinaSize.width = standardSize.width * pxRatio;
|
|
366
340
|
const canSupportHdrQuery = safeMatchMedia("(color-gamut: p3)");
|
|
367
|
-
this.
|
|
341
|
+
this._canvasSettings = {
|
|
368
342
|
alpha: true,
|
|
369
343
|
colorSpace: canSupportHdrQuery?.matches && container.hdr ? "display-p3" : "srgb",
|
|
370
344
|
desynchronized: true,
|
|
371
345
|
willReadFrequently: false,
|
|
372
|
-
}
|
|
346
|
+
};
|
|
347
|
+
this._context = this.element.getContext("2d", this._canvasSettings);
|
|
373
348
|
this._safeMutationObserver(obs => {
|
|
374
349
|
obs.disconnect();
|
|
375
350
|
});
|
|
@@ -384,11 +359,11 @@ export class Canvas {
|
|
|
384
359
|
}
|
|
385
360
|
paint() {
|
|
386
361
|
let handled = false;
|
|
387
|
-
for (const plugin of this.
|
|
362
|
+
for (const plugin of this._canvasPaintPlugins) {
|
|
363
|
+
handled = plugin.canvasPaint?.() ?? false;
|
|
388
364
|
if (handled) {
|
|
389
365
|
break;
|
|
390
366
|
}
|
|
391
|
-
handled = plugin.canvasPaint?.() ?? false;
|
|
392
367
|
}
|
|
393
368
|
if (handled) {
|
|
394
369
|
return;
|
|
@@ -464,4 +439,113 @@ export class Canvas {
|
|
|
464
439
|
await container.refresh();
|
|
465
440
|
}
|
|
466
441
|
}
|
|
442
|
+
_applyPostDrawUpdaters = particle => {
|
|
443
|
+
for (const updater of this._postDrawUpdaters) {
|
|
444
|
+
updater.afterDraw?.(particle);
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
_applyPreDrawUpdaters = (ctx, particle, radius, zOpacity, colorStyles, transform) => {
|
|
448
|
+
for (const updater of this._preDrawUpdaters) {
|
|
449
|
+
if (updater.getColorStyles) {
|
|
450
|
+
const { fill, stroke } = updater.getColorStyles(particle, ctx, radius, zOpacity);
|
|
451
|
+
if (fill) {
|
|
452
|
+
colorStyles.fill = fill;
|
|
453
|
+
}
|
|
454
|
+
if (stroke) {
|
|
455
|
+
colorStyles.stroke = stroke;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
if (updater.getTransformValues) {
|
|
459
|
+
const updaterTransform = updater.getTransformValues(particle);
|
|
460
|
+
for (const key in updaterTransform) {
|
|
461
|
+
setTransformValue(transform, updaterTransform, key);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
updater.beforeDraw?.(particle);
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
_applyResizePlugins = () => {
|
|
468
|
+
for (const plugin of this._resizePlugins) {
|
|
469
|
+
plugin.resize?.();
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
_getPluginParticleColors = particle => {
|
|
473
|
+
let fColor, sColor;
|
|
474
|
+
for (const plugin of this._colorPlugins) {
|
|
475
|
+
if (!fColor && plugin.particleFillColor) {
|
|
476
|
+
fColor = rangeColorToHsl(this._engine, plugin.particleFillColor(particle));
|
|
477
|
+
}
|
|
478
|
+
if (!sColor && plugin.particleStrokeColor) {
|
|
479
|
+
sColor = rangeColorToHsl(this._engine, plugin.particleStrokeColor(particle));
|
|
480
|
+
}
|
|
481
|
+
if (fColor && sColor) {
|
|
482
|
+
break;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
this._reusablePluginColors[fColorIndex] = fColor;
|
|
486
|
+
this._reusablePluginColors[sColorIndex] = sColor;
|
|
487
|
+
return this._reusablePluginColors;
|
|
488
|
+
};
|
|
489
|
+
_initStyle = () => {
|
|
490
|
+
const element = this.element, options = this.container.actualOptions;
|
|
491
|
+
if (!element) {
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
if (this._fullScreen) {
|
|
495
|
+
this._setFullScreenStyle();
|
|
496
|
+
}
|
|
497
|
+
else {
|
|
498
|
+
this._resetOriginalStyle();
|
|
499
|
+
}
|
|
500
|
+
for (const key in options.style) {
|
|
501
|
+
if (!key || !Object.hasOwn(options.style, key)) {
|
|
502
|
+
continue;
|
|
503
|
+
}
|
|
504
|
+
const value = options.style[key];
|
|
505
|
+
if (!value) {
|
|
506
|
+
continue;
|
|
507
|
+
}
|
|
508
|
+
element.style.setProperty(key, value, "important");
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
_repairStyle = () => {
|
|
512
|
+
const element = this.element;
|
|
513
|
+
if (!element) {
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
this._safeMutationObserver(observer => {
|
|
517
|
+
observer.disconnect();
|
|
518
|
+
});
|
|
519
|
+
this._initStyle();
|
|
520
|
+
this.initBackground();
|
|
521
|
+
const pointerEvents = this._pointerEvents;
|
|
522
|
+
element.style.pointerEvents = pointerEvents;
|
|
523
|
+
element.setAttribute("pointer-events", pointerEvents);
|
|
524
|
+
this._safeMutationObserver(observer => {
|
|
525
|
+
if (!(element instanceof Node)) {
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
observer.observe(element, { attributes: true });
|
|
529
|
+
});
|
|
530
|
+
};
|
|
531
|
+
_resetOriginalStyle = () => {
|
|
532
|
+
const element = this.element, originalStyle = this._originalStyle;
|
|
533
|
+
if (!element || !originalStyle) {
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
setStyle(element, originalStyle, true);
|
|
537
|
+
};
|
|
538
|
+
_safeMutationObserver = callback => {
|
|
539
|
+
if (!this._mutationObserver) {
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
callback(this._mutationObserver);
|
|
543
|
+
};
|
|
544
|
+
_setFullScreenStyle = () => {
|
|
545
|
+
const element = this.element;
|
|
546
|
+
if (!element) {
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
setStyle(element, getFullScreenStyle(this.container.actualOptions.fullScreen.zIndex), true);
|
|
550
|
+
};
|
|
467
551
|
}
|