Skip to content

Instantly share code, notes, and snippets.

@adamrunner
Created February 14, 2016 19:55
Show Gist options
  • Save adamrunner/d63984708550aaedb6f8 to your computer and use it in GitHub Desktop.
Save adamrunner/d63984708550aaedb6f8 to your computer and use it in GitHub Desktop.
#NOTE: gem install blinkstick first
require "blinkstick"
def cycle_colors(blinkstick)
percentages = [0,0,0]
cycle = 1
while true do
sleep(0.01)
if percentages.first <= 100 && cycle.odd?
percentages = percentages.map {|a| a+1}
puts percentages.inspect
elsif percentages.first >= 0 && cycle.even?
percentages = percentages.map {|a| a-1}
puts percentages.inspect
end
if percentages.first == 100 || percentages.first == 0
cycle = cycle + 1
end
blinkstick.color = Color::RGB.from_percentage(*percentages)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment