Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var elems = document.body.getElementsByTagName("*");
- function getRandomInt(min, max) {
- min = Math.ceil(min);
- max = Math.floor(max);
- return Math.floor(Math.random() * (max - min)) + min;
- }
- function getRandomRGB() {
- return "rgb("+ getRandomInt(0, 255) +", "+ getRandomInt(0, 255) +", " + getRandomInt(0, 255) +")"
- }
- var directions = ["to left", "to bottom", "to right", "to top"]
- for(var i = 0; i < elems.length; i++) {
- numbero = getRandomInt(0,directions.length + 5)
- if(numbero <= directions.length-1) {
- direction = directions[numbero];
- } else {
- direction = getRandomInt(0, 360) + "deg"
- }
- gradient = "linear-gradient("+ direction + ", " + getRandomRGB() + ", " + getRandomRGB() + " , " + getRandomRGB() + ")";
- elems[i].style.backgroundImage = gradient;
- }
- $(function () { $(".board").attr('style', 'background-image: ' + gradient + ' !important;');});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement