JSFiddle - React, Tailwind, and code Playground
JavaScript
function AppController()
{
var blockCount = 20;
var blockSpacing = 3;
var blockWidth = Math.floor(((window.innerWidth - blockSpacing) / blockCount) - blockSpacing);
var blockY = Math.floor((window.innerHeight / 2) - (blockWidth / 2));
var blockViews = [];
var blockViewValues = [];
this.init = function()
{
document.body.style.backgroundColor = '#000';
// create a block dom nodes
this.createNodes();
// update block nodes, and begin animation
this.updateNodes();
// observe window resize, to re-create block nodes
window.addEventListener('resize', function(event) {
blockWidth = Math.floor(((window.innerWidth - blockSpacing) / blockCount) - blockSpacing);
blockY = Math.floor((window.innerHeight / 2) - (blockWidth / 2));
var blockIndex;
for (blockIndex = 0; blockIndex < blockCount; blockIndex++) {
document.body.removeChild(blockViews[blockIndex]);
}
this.createNodes();
}.bind(this));
}
this.createNodes = function()
{
blockViews = [];
blockViewValues = [];
var blockIndex;
for (blockIndex = 0; blockIndex < blockCount; blockIndex++) {
blockView = document.createElement('canvas');
blockView.style.position = 'absolute';
blockView.style.left = blockSpacing + ((blockWidth + blockSpacing) * blockIndex) + 'px';
blockView.style.top = blockY + 'px';
blockView.style.width = blockWidth + 'px';
blockView.style.height = blockWidth + 'px';
blockView.style.backgroundColor = "rgba(255,255,255,0.2)";
blockView.width = blockWidth;
blockView.height = blockWidth;
document.body.appendChild(blockView);
blockViews.push(blockView);
blockViewValues.push(false);
}
}
this.updateNodes = function()
{
var time = new BinaryTime();
var binaryValues = time.binaryValuesWithLength(blockCount);
var blockIndex;
for (blockIndex = 0; blockIndex <...