JSFiddle - React, Tailwind, and code Playground

by Humphry Huang

CSS

body{ position:relative; height:100% ; background:#000; overflow:hidden; }
        div{ width : 4px; height : 4px; border-radius : 100%; position : absolute; }
html{ height: 100%; }

JavaScript

var NUM = 80,
            THRESHOLDNUM = 60;

        // returns any random digits you need
        // gets a reasonable random() calling frequency
        var rands = (function(i) {
            var obj = {
                getRandomDigit: function() {
                    if (!(this.rands && this.rands.length > 0)) {
                        this.rands = Math.random().toString().substr(2).split("");
                    }
                    return this.rands.shift();
                },
                getRandomDigits: function(requireNumbers) {
                    var str = "",
                        n = requireNumbers;
                    while (n > 0) {
                        str += this.getRandomDigit();
                        n--;
                    }
                    return str;
                }
            };
            return function(needs) {
                return obj.getRandomDigits(needs);
            };
        })(THRESHOLDNUM);

        // creates enough divs
        var htmls = [];
        for (i = 0; i < NUM; i++) {
            var a = document.createElement("div");
            a.style.top = rands(2) + "%";
            a.style.left = rands(2) + "%";
            a.style.backgroundColor = "rgb(" + rands(2) + "%," + rands(2) + "%," + rands(2) + "%)";
            htmls.push(a.outerHTML);
        }
        document.body.innerHTML = htmls.join("");
        var allnodes = document.body.childNodes;

        var repaint = function(elem) {
            elem.style.boxShadow = "0 0 " + rands(2) + "px #FFFFFF" ;
        } ;
        
        // HTMLDivElement.prototype.startAnimationOnMyOwn = function() {
        //     var that = this ;
        //     setInterval(function(){
        //         repaint(that) ;
        //     } , 16) ;
        // } ;

        HTMLDivElement.prototype.startAnimationOnMyOwn = function() {
            var that = this ;
            (function run() {
                repaint(that) ;
                requestAnimationFrame(run);
   ...