JSFiddle - React, Tailwind, and code Playground
by Ajith S Punalur
HTML
<!-- particles.js container --> <div id="particles-js"></div> <!-- stats - count particles -->
<!-- <div class="count-particles"> <span class="js-count-particles">--</span> particles </div>
<!-- particles.js lib - https://github.com/VincentGarreau/particles.js -->
<script src="http://cdn.jsdelivr.net/particles.js/2.0.0/particles.min.js"></script>
<!-- stats.js lib -->
<!-- <script src="http://threejs.org/examples/js/libs/stats.min.js"></script> -->
CSS
/* ---- particles.js container ---- */
#particles-js {
position:absolute;
width: 100%;
height: 100%;
background: linear-gradient(180deg, rgba(247,243,229,1) 0%, rgba(212,206,186,1) 100%);
margin: 0;
left: 0;
bottom: 0;
top: 0;
right: 0;
filter: blur(.5px);
}
JavaScript
particlesJS("particles-js", {"particles":{"number":{"value":420,"density":{"enable":true,"value_area":2100}},"color":{"value":"#FFFCF2"},"shape":{"type":"circle","stroke":{"width":0,"color":"#ffffff"},"polygon":{"nb_sides":21},"image":{"src":"img/github.svg","width":100,"height":100}},"opacity":{"value":0.6,"random":true,"anim":{"enable":false,"speed":1,"opacity_min":0.1,"sync":false}},"size":{"value":3,"random":true,"anim":{"enable":false,"speed":1,"size_min":0.1,"sync":false}},"line_linked":{"enable":false,"distance":150,"color":"#ffffff","opacity":0.4,"width":1},"move":{"enable":true,"speed":1,"direction":"top","random":true,"straight":false,"out_mode":"out","bounce":true,"attract":{"enable":true,"rotateX":600,"rotateY":1200}}},"interactivity":{"detect_on":"canvas","events":{"onhover":{"enable":true,"mode":"bubble"},"onclick":{"enable":true,"mode":"push"},"resize":true},"modes":{"grab":{"distance":143,"line_linked":{"opacity":.2}},"bubble":{"distance":210,"size":7,"duration":.4,"opacity":.2,"speed":21},"repulse":{"distance":63,"duration":0.4},"push":{"particles_nb":4},"remove":{"particles_nb":2}}},"retina_detect":true});var count_particles, stats, update; stats = new Stats; stats.setMode(0); stats.domElement.style.position = 'absolute'; stats.domElement.style.left = '0px'; stats.domElement.style.top = '0px'; document.body.appendChild(stats.domElement); count_particles = document.querySelector('.js-count-particles'); update = function() { stats.begin(); stats.end(); if (window.pJSDom[0].pJS.particles && window.pJSDom[0].pJS.particles.array) { count_particles.innerText = window.pJSDom[0].pJS.particles.array.length; } requestAnimationFrame(update); }; requestAnimationFrame(update);;