Engine class for creating the singleton on window. It's a singleton class for initializing Container instances, and for Plugins class responsible for every external feature

Constructors

Properties

_configs: Map<string, RecursivePartial<IOptions>>
_domArray: Container[]

Contains all the Container instances of the current engine instance

_eventDispatcher: EventDispatcher
_initialized: boolean

Checks if the engine instance is initialized

_initializers: Initializers
effectDrawers: Map<string, IEffectDrawer<Particle>>

The drawers (additional effects) array

interactors: Map<Container, IInteractor<Particle>[]>

The interaction managers array

movers: Map<Container, IParticleMover[]>
pathGenerators: Map<string, IMovePathGenerator>

The path generators array

plugins: IPlugin[]

The plugins array

presets: Map<string, RecursivePartial<IOptions>>

The presets array

shapeDrawers: Map<string, IShapeDrawer<Particle>>

The drawers (additional shapes) array

updaters: Map<Container, IParticleUpdater[]>

The updaters array

Accessors

Methods

  • addEffect adds effect to tsParticles, it will be available to all future instances created

    Parameters

    • effect: SingleOrMultiple<string>

      the effect name

    • drawer: IEffectDrawer<Particle>

      the effect drawer function or class instance that draws the effect in the canvas

    • refresh: boolean = true

      should refresh the dom after adding the effect

    Returns Promise<void>

  • Adds a listener to the specified event

    Parameters

    • type: string

      The event to listen to

    • listener: CustomEventListener

      The listener of the specified event

    Returns void

  • Adds an interaction manager to the current collection

    Parameters

    • name: string

      the interaction manager name

    • interactorInitializer: InteractorInitializer

      the interaction manager initializer

    • refresh: boolean = true

      if true the engine will refresh all the containers

    Returns Promise<void>

  • Parameters

    • name: string

      the mover name

    • moverInitializer: MoverInitializer

      the mover initializer

    • refresh: boolean = true

      if true the engine will refresh all the containers

    Returns Promise<void>

  • Adds a particle updater to the collection

    Parameters

    • name: string

      the particle updater name used as a key

    • updaterInitializer: UpdaterInitializer

      the particle updater initializer

    • refresh: boolean = true

      if true the engine will refresh all the containers

    Returns Promise<void>

  • addPathGenerator adds a named path generator to tsParticles, this can be called by options

    Parameters

    • name: string

      the path generator name

    • generator: IMovePathGenerator

      the path generator object

    • refresh: boolean = true

      should refresh the dom after adding the path generator

    Returns Promise<void>

  • addPlugin adds plugin to tsParticles, if an instance needs it, it will be loaded

    Parameters

    • plugin: IPlugin

      the plugin implementation of IPlugin

    • refresh: boolean = true

      should refresh the dom after adding the plugin

    Returns Promise<void>

  • addPreset adds preset to tsParticles, it will be available to all future instances created

    Parameters

    • preset: string

      the preset name

    • options: RecursivePartial<IOptions>

      the options to add to the preset

    • override: boolean = false

      if true, the preset will override any existing with the same name

    • refresh: boolean = true

      should refresh the dom after adding the preset

    Returns Promise<void>

  • addShape adds shape to tsParticles, it will be available to all future instances created

    Parameters

    • shape: SingleOrMultiple<string>

      the shape name

    • drawer: IShapeDrawer<Particle>

      the shape drawer function or class instance that draws the shape in the canvas

    • refresh: boolean = true

      should refresh the dom after adding the shape

    Returns Promise<void>

  • Dispatches an event that will be listened from listeners

    Parameters

    • type: string

      The event to dispatch

    • args: CustomEventArgs

      The event parameters

    Returns void

  • Retrieves a Container from all the objects loaded

    Parameters

    • index: number

      The object index

    Returns undefined | Container

    The Container object at specified index, if present or not destroyed, otherwise undefined

  • Gets all the available plugins, for the specified container

    Parameters

    • container: Container

      the container used to check which are the valid plugins

    Returns Promise<Map<string, IContainerPlugin>>

    a map containing all enabled plugins, with the id as a key

  • Returns all the container interaction managers

    Parameters

    • container: Container

      the container used to check which interaction managers are compatible

    • force: boolean = false

      if true reloads the interaction managers collection for the given container

    Returns Promise<IInteractor<Particle>[]>

    the array of interaction managers for the given container

  • Searches the path generator with the given type name

    Parameters

    • type: string

      the path generator type to search

    Returns undefined | IMovePathGenerator

    the path generator if found, or undefined

  • Searches if the specified plugin exists and returns it

    Parameters

    • plugin: string

      the plugin name

    Returns undefined | IPlugin

    the plugin if found, or undefined

  • This method returns all the supported effects with this Plugins instance

    Returns IterableIterator<string>

    all the supported effects type name

  • This method returns all the supported shapes with this Plugins instance

    Returns IterableIterator<string>

    all the supported shapes type name

  • Returns all the container particle updaters

    Parameters

    • container: Container

      the container used to check which particle updaters are enabled

    • force: boolean = false

      if true reloads the updater collection for the given container

    Returns Promise<IParticleUpdater[]>

    the array of updaters for the given container

  • Loads the provided options to create a Container object.

    Parameters

    Returns Promise<undefined | Container>

    A Promise with the Container object created

  • Load the given options for all the plugins

    Parameters

    Returns void

  • Reloads all existing tsParticles loaded instances

    Parameters

    • refresh: boolean = true

      should refresh the dom after reloading

    Returns Promise<void>

  • Removes a listener from the specified event

    Parameters

    • type: string

      The event to stop listening to

    • listener: CustomEventListener

      The listener of the specified event

    Returns void

  • Adds another click handler to all the loaded Container objects.

    Parameters

    • callback: ((e, particles?) => void)

      The function called after the click event is fired

        • (e, particles?): void
        • Parameters

          Returns void

    Returns void