Class: CheekyDreams::Effects::Fade
- Defined in:
- lib/cheeky-dreams.rb
Constant Summary
Constants included from CheekyDreams
Instance Method Summary collapse
-
#initialize(from, to, steps, freq) ⇒ Fade
constructor
A new instance of Fade.
- #next(current_colour = nil) ⇒ Object
Methods included from CheekyDreams
#ansi_driver, #audit_to, #crazy, #cycle, #dev_null, #fade, #fade_to, #find_dream_cheeky_usb_device, #forward, #func, #light_show, #max, #off, #position_between, #rgb, #rgb_between, #sleep_until, #solid, #stdio_audit, #stdout_driver, #suppress_duplicates, #throb, #throbbing
Constructor Details
#initialize(from, to, steps, freq) ⇒ Fade
Returns a new instance of Fade.
345 346 347 348 349 350 351 |
# File 'lib/cheeky-dreams.rb', line 345 def initialize from, to, steps, freq @freq, @rgb_from, @rgb_to = freq, rgb(from), rgb(to) @fade = [@rgb_from] (1..(steps-1)).each { |i| @fade << rgb_between(@rgb_from, @rgb_to, i / steps.to_f) } @fade << @rgb_to @index = 0 end |
Instance Method Details
#next(current_colour = nil) ⇒ Object
353 354 355 356 357 358 |
# File 'lib/cheeky-dreams.rb', line 353 def next current_colour = nil return [@rgb_to, 0] if @index >= @fade.length next_colour = @fade[@index] @index += 1 [next_colour, next_colour == @rgb_to ? 0 : @freq] end |