MONOCHROMATIC







// set the body of the page var section = document.getElementById('photography'); // set the title of the page // var title = document.getElementById('title'); // set the default direction var direction = 'top right'; // make a container for colors var arr = []; // function to set the background default values var setBg = function() { let r = Math.floor(Math.random() * 256); arr[0] = r; let g = Math.floor(Math.random() * 256); arr[1] = g; let b = Math.floor(Math.random() * 256); arr[2] = b; let bg = 'rgb(' + r + ',' + g + ',' + b + ')'; section.style.backgroundColor = bg; }; // function to adjust colors incrementally var bgDrip = function(rgb) { let newRgb = []; rgb.forEach(function(v) { if (v < 1) { newRgb.push((v+1)); } else if (v > 250) { newRgb.push((v-1)); } else { // random roll to determine increase or decrease for values let roll = (Math.floor(Math.random() * 3)); if (roll < 1) { newRgb.push((v-1)); } else if (roll > 1) { newRgb.push((v+1)); } else { newRgb.push(v); } } }); arr = newRgb; let bg = 'background: linear-gradient(to ' + direction + ', rgba(' + arr[2] + ',' + arr[1] + ',' + arr[0] + ',0.6), rgba(' + arr[0] + ',' + arr[1] + ',' + arr[2] + ',1))'; section.style = bg; // title.style.color = 'rgba(' + arr[2] + ',' + arr[0] + ',' + arr[1] + ',0.8)'; }; var cycle = function() { let drip = bgDrip(arr); drip; setTimeout(cycle, 16); } setBg(); cycle();