Advertisement
KarachanStyler

Gradientowy

Aug 15th, 2019
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. var elems = document.body.getElementsByTagName("*");
  2.  
  3. function getRandomInt(min, max) {
  4. min = Math.ceil(min);
  5. max = Math.floor(max);
  6. return Math.floor(Math.random() * (max - min)) + min;
  7. }
  8.  
  9. function getRandomRGB() {
  10.  
  11. return "rgb("+ getRandomInt(0, 255) +", "+ getRandomInt(0, 255) +", " + getRandomInt(0, 255) +")"
  12.  
  13. }
  14.  
  15. var directions = ["to left", "to bottom", "to right", "to top"]
  16.  
  17.  
  18. for(var i = 0; i < elems.length; i++) {
  19.  
  20.  
  21. numbero = getRandomInt(0,directions.length + 5)
  22.  
  23. if(numbero <= directions.length-1) {
  24. direction = directions[numbero];
  25. } else {
  26. direction = getRandomInt(0, 360) + "deg"
  27. }
  28.  
  29. gradient = "linear-gradient("+ direction + ", " + getRandomRGB() + ", " + getRandomRGB() + " , " + getRandomRGB() + ")";
  30.  
  31. elems[i].style.backgroundImage = gradient;
  32.  
  33. }
  34.  
  35.  
  36. $(function () { $(".board").attr('style', 'background-image: ' + gradient + ' !important;');});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement