Advertisement
Guest User

Untitled

a guest
Dec 1st, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. target = $('body')
  2.  
  3. # get random RGB values so we can change background and link colors
  4. r = Math.floor Math.random() * 241
  5. g = Math.floor Math.random() * 241
  6. b = Math.floor Math.random() * 241
  7.  
  8. # variables to hold the lighter shade RGB values
  9. # rp1; gp1; bp1; rp2; gp2; bp2; rp3; gp3; bp3
  10.  
  11. # we'll use these values to calculate lighter shades
  12. p1 = .1
  13. p2 = .15
  14. p3 = .2
  15.  
  16. # get random intervals used to calculate the changing RGB values
  17. ri = Math.floor(Math.random()*4)
  18. gi = Math.floor(Math.random()*4)
  19. bi = Math.floor(Math.random()*4)
  20.  
  21. # // This changes the body background coor
  22. changeBGColor = ->
  23. if r > 239 || r < 1
  24. ri = ri * -1
  25. if g > 239 || g < 1
  26. gi = gi * -1
  27. if b > 239 || b < 1
  28. bi = bi * -1
  29. r += ri
  30. g += gi
  31. b += bi
  32.  
  33. target.css("background-color", "rgb(#{r}, #{g}, #{b})")
  34.  
  35. # // now lets figure lighter shades and chaneg the background style property
  36. # // of our banner, centercontent, and rightcontent divs. If you'd rather they
  37. # // stayed white, just get rid of the next block of code.
  38. getLighterRGBShades()
  39.  
  40.  
  41.  
  42. getLighterRGBShades = ->
  43. rp1 = parseInt (r * p1) + (255 - (255 * p1))
  44. gp1 = parseInt (g * p1) + (255 - (255 * p1))
  45. bp1 = parseInt (b * p1) + (255 - (255 * p1))
  46. rp2 = parseInt (r * p2) + (255 - (255 * p2))
  47. gp2 = parseInt (g * p2) + (255 - (255 * p2))
  48. bp2 = parseInt (b * p2) + (255 - (255 * p2))
  49. rp3 = parseInt (r * p3) + (255 - (255 * p3))
  50. gp3 = parseInt (g * p3) + (255 - (255 * p3))
  51. bp3 = parseInt (b * p3) + (255 - (255 * p3))
  52.  
  53. getLighterRGBShades()
  54. setTimeout(changeBGColor(),400)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement