Last active
December 22, 2015 21:59
-
-
Save seanmtracey/6536865 to your computer and use it in GitHub Desktop.
Random color generation for all DOM elements so you can see where that pesky whitespace is coming from.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m=Math.random,v=255;Array.from(document.querySelectorAll("*")).forEach(e=>{e.style.background=`rgb(${m()*v|0},${m()*v|0},${m()*v|0})`}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a=document.querySelectorAll('*'),m=Math.random,v=255,x=0;while(x<a.length){r=m()*v|0,g=m()*v|0,b=m()*v|0;a[x].style.background="rgb("+r+","+g+","+b+")";x++;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var all = document.querySelectorAll('*'); | |
for(var x = 0; x < all.length; x += 1){ | |
var thisThing = all[x]; | |
var r = Math.floor(Math.random()*255); | |
var g = Math.floor(Math.random()*255); | |
var b = Math.floor(Math.random()*255); | |
thisThing.style.backgroundColor = "rgba(" + r + ", " + g + ", " + b + ", 1)"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m=Math.random,v=255;Array.from(document.querySelectorAll("*")).forEach(e=>{e['style'].background=`rgb(${m()*v|0},${m()*v|0},${m()*v|0})`}) |
Slightly more condensed ES6 version.
m=Math.random,v=255;for(e of Array.from(document.querySelectorAll('*'))){e.style.background=`rgb(${m()*v|0},${m()*v|0},${m()*v|0})`}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
m=Math.random,v=255;Array.from(document.querySelectorAll('*')).map(e=>e.style.background=
rgb(${m()*v|0},${m()*v|0},${m()*v|0}))