Particles Container
The Container class is the runtime manager of a single tsParticles instance.
You usually get a container from:
- Engine.load | tsParticles.load
- Engine.loadJSON | tsParticles.loadJSON (
then(container => ...))
You can also access loaded instances with:
- Engine.items | tsParticles.items
- Engine.item | tsParticles.item(index)
Quick runtime example
{
"id": "tsparticles",
"options": {
"particles": {
"move": {
"enable": true
}
}
}
}
After loading this configuration, you can control the container with pause() and play().
Main properties
- Container.id: container id, usually matching the target DOM element id
- Container.options: current live options
- Container.sourceOptions: original options used during construction
- Container.particles: particles manager (add/remove and runtime operations)
If you mutate container.options at runtime, call Container.refresh | refresh() to apply changes consistently.
Main methods
- Container.play | play(): resume animation
- Container.pause | pause(): pause animation
- Container.start | start(): (re)start container with full initialization
- Container.stop | stop(): stop and cleanup runtime resources
- Container.refresh | refresh(): shortcut for
stop() + start()
- Container.destroy | destroy(): destroy instance and release resources
Export methods
- Container.exportImage | exportImage(callback, type?, quality?): export the canvas image (without configured background)
- Container.exportConfiguration | exportConfiguration(): export current config as JSON string
Themes
- Container.loadTheme | loadTheme(name): apply a theme and reload options
- If
name is undefined, the default theme is used (if configured)