Created
May 6, 2014 18:34
-
-
Save RuanAragao/4ac934b73445eaf0eedf to your computer and use it in GitHub Desktop.
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
document.write('<style>.block{width:30px;height:30px;position:relative; float:left;display:block;}</style>'); | |
function blockRainbow(gridId, sizeBlock, opacity) { | |
var drawb = document.getElementById(gridId); | |
var d; | |
function createGrid(sizeBlock){ | |
for(d=1;d <= 16;d++){ | |
var innerDrawb = drawb.innerHTML; | |
drawb.innerHTML += '<span id="block-'+d+'" class="block"></span>'; | |
var rand_1 = Math.floor((Math.random() * 255) + 0); | |
var rand_2 = Math.floor((Math.random() * 255) + 0); | |
var rand_3 = Math.floor((Math.random() * 255) + 0); | |
var blockNow = document.getElementById('block-'+d); | |
blockNow.style.backgroundColor = 'rgba('+rand_1+','+rand_2+','+rand_3+','+opacity+')'; | |
blockNow.style.width = sizeBlock+'px'; | |
blockNow.style.height = sizeBlock+'px'; | |
} | |
} | |
createGrid(sizeBlock); | |
} | |
blockRainbow('draw-box', 50, 0.5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment