Advertisement
kawaiibuu

Default Gradient

Dec 9th, 2014
635
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. Copy and paste this AFTER <style> or <style type="text/css">
  2. #gradient_bg { z-index: -1000; width: 100%; top: 0px; left: 0px; right: 0px; bottom: 0px; height: 100%; background-size: cover; position:fixed; padding: 0px; margin: 0px; }
  3.  
  4. Copy and paste this AFTER <body>:
  5. <div id="gradient_bg"></div>
  6.  
  7. Scroll to the bottom of the page and copy and paste this BEFORE </body>:
  8. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
  9. <script>
  10. var colors = new Array(
  11. [241, 225, 210],
  12. [190, 220, 218],
  13. [137, 149, 206],
  14. [175, 221, 190],
  15. [210, 175, 221],
  16. [249, 244, 182]);
  17. var step = 0;
  18. var colorIndices = [0,1,2,3];
  19. var gradientSpeed = 0.002;
  20. function updateGradient()
  21. {
  22. var c0_0 = colors[colorIndices[0]];
  23. var c0_1 = colors[colorIndices[1]];
  24. var c1_0 = colors[colorIndices[2]];
  25. var c1_1 = colors[colorIndices[3]];
  26. var istep = 1 - step;
  27. var r1 = Math.round(istep * c0_0[0] + step * c0_1[0]);
  28. var g1 = Math.round(istep * c0_0[1] + step * c0_1[1]);
  29. var b1 = Math.round(istep * c0_0[2] + step * c0_1[2]);
  30. var color1 = "#"+((r1 << 16) | (g1 << 8) | b1).toString(16);
  31. var r2 = Math.round(istep * c1_0[0] + step * c1_1[0]);
  32. var g2 = Math.round(istep * c1_0[1] + step * c1_1[1]);
  33. var b2 = Math.round(istep * c1_0[2] + step * c1_1[2]);
  34. var color2 = "#"+((r2 << 16) | (g2 << 8) | b2).toString(16);
  35. $('#gradient_bg').css({
  36.  
  37. background: "-webkit-gradient(linear, left top, right top, from("+color1+"), to("+color2+"))"}).css({
  38. background: "-moz-linear-gradient(left, "+color1+" 0%, "+color2+" 100%)"});
  39. step += gradientSpeed;
  40. if ( step >= 1 )
  41. {
  42. step %= 1;
  43. colorIndices[0] = colorIndices[1];
  44. colorIndices[2] = colorIndices[3];
  45. colorIndices[1] = ( colorIndices[1] + Math.floor( 1 + Math.random() * (colors.length - 1))) % colors.length;
  46. colorIndices[3] = ( colorIndices[3] + Math.floor( 1 + Math.random() * (colors.length - 1))) % colors.length;
  47. }
  48. }
  49. setInterval(updateGradient,10);
  50. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement