Class: Ledstrip::Effects::Rainbow
- Defined in:
- lib/ledstrip/effects/rainbow.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#initialize, #run, #start, #stop, #tick
Constructor Details
This class inherits a constructor from Ledstrip::Effects::Base
Instance Method Details
#sleep_time ⇒ Object
23 24 25 |
# File 'lib/ledstrip/effects/rainbow.rb', line 23 def sleep_time 0.1 end |
#step(leds) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ledstrip/effects/rainbow.rb', line 5 def step(leds) i = @frame frequency = 0.3 leds.collect do |led| red = Math.sin(frequency*i + 0) * 127 + 128 green = Math.sin(frequency*i + 2) * 127 + 128 blue = Math.sin(frequency*i + 4) * 127 + 128 led.red = red led.green = green led.blue = blue i += 1 led end.reverse end |