Created
February 14, 2016 19:55
-
-
Save adamrunner/d63984708550aaedb6f8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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