SuperParticles
Performance-focused alternative to VincentGarreau’s particles.js
Introduction
SuperParticles aims at resolving the major performance issues that come with particles.js, by using WebGL when possible and also by allowing you to limit the frame rate (FPS).
If you have more ideas on what could be done to further improve the performance, feel free to open an issue.
GIF Demo

Live Demo
https://t-vk.github.io/SuperParticles/demo.html
How To Use
Jquery is optional, but recommended.
Pixi.js is required (preferrably in a version above 5.0.0-rc):
<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="https://pixijs.download/dev-graphics-batch-pool/pixi.js"></script>
<script src="https://cdn.jsdelivr.net/gh/T-vK/SuperParticles@master/SuperParticles.js"></script>
<script>
window.onload = function(){
var superParticles = new SuperParticles()
}
</script>
If you want, you can pass a div container to SuperParticles which then will be used to render the particles:
<body>
<script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="https://pixijs.download/dev-graphics-batch-pool/pixi.js"></script>
<script src="https://cdn.jsdelivr.net/gh/T-vK/SuperParticles@master/SuperParticles.js"></script>
<div id="super-particles"></div>
<script>
window.onload = function(){
var divContainer = '#super-particles'
new SuperParticles({
container: divContainer
})
}
</script>
</body>
You can limit the FPS like this:
new SuperParticles({
maxFps: 30
})
API
new SuperParticles(cfg)
Creates a new SuperParticles instance.
cfg defaults to:
{
useJquery: undefined,
maxFps: 30,
autoStartAnimation: true,
container: {
element: undefined,
backgroundCssRule: "radial-gradient(ellipse at center, rgba(10,46,56,1) 0%,rgba(34,34,34,1) 70%)"
},
pixiApp: {
antialias: true,
transparent: true,
forceFXAA: false,
powerPreference: 'high-performance',
resolution: 1.0
},
particles: {
amount: 80,
radius: 2,
velocity : 10,
color: "0xFFFFFF",
fadeInDuration: 3000,
fadeOutDuration: 600,
keepRelativePositionOnResize: true,
},
lines: {
minDistance: 0.09,
color: "0xFFFFFF",
maxOpacity: 0.4,
thickness: 1,
distanceBasedTransparency: true,
},
debug: {
showFps: false,
}
}
but you can overwrite individual properties if you like.
superParticles.stopAnimation()
Pauses the SuperParticles instance.
superParticles.startAnimation()
Resume the SuperParticles instance.
superParticles.destroy()
Destroys the SuperParticles instance. (If you want to reuse the instance afterwards, you have to call reinit first!)
superParticles.reinit()
Reinitializes the instance. (Useful after destroying it.)
superParticles.cfg
This is the config object of the instance. You can overwrite the cfg object during runtime.
E.g. superParticles.cfg = { pixiApp: { antialiasing: true } }
Don’t do superParticles.cfg.pixiApp.antialiasing = true
评论