Skip to content

Instantly share code, notes, and snippets.

@lebbe
Created October 7, 2014 13:09
Show Gist options
  • Select an option

  • Save lebbe/3f0bffeeef1997ebebe8 to your computer and use it in GitHub Desktop.

Select an option

Save lebbe/3f0bffeeef1997ebebe8 to your computer and use it in GitHub Desktop.
Transform any web-page into a psychedelic experience
window.setInterval(function() {
var levelColors = [], m = Math;
function getLevelColor(level) {
if(levelColors[level] === undefined) {
levelColors[level] = (m.PI * m.random()).toString(16).slice(-2);
}
return levelColors[level];
}
(function rec(node, level) {
if(node.style)
node.style.boxShadow = window.getComputedStyle(node).width + ' 0 #' + getLevelColor(level) + ' inset';
[].forEach.call(node.childNodes, function(node) {
rec(node, level + 1)
});
})(document, 0);
}, 1000);
window.setInterval(function(){function e(c){void 0===a[c]&&(a[c]=(d.PI*d.random()).toString(16).slice(-6));return a[c]}var a=[],d=Math;(function f(b,a){b.style&&(b.style.boxShadow=window.getComputedStyle(b).width+" 0 #"+e(a)+" inset");[].forEach.call(b.childNodes,function(b){f(b,a+1)})})(document,0)},1E3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment