Skip to content

Instantly share code, notes, and snippets.

@surjikal
Created March 11, 2013 00:59
Show Gist options
  • Save surjikal/5131254 to your computer and use it in GitHub Desktop.
Save surjikal/5131254 to your computer and use it in GitHub Desktop.
This gist demonstrates a way to cycle the color of a set of elements
cycleHue = (interval, increment, hue, callback) ->
cycle = ->
hue = (hue + increment) % 360
callback hue
setInterval cycle, interval
# To use it...
# Ex: Increment degree by 1 every 100 ms, starting at 120 degrees
$coloredElements = $('.some-elements')
cycleHue 100, 1, 120, (hue) ->
$coloredElements.css color:"hsl(#{hue}, 80%, 70%)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment