Class: CheekyPi::Animation::Fade

Inherits:
Base
  • Object
show all
Defined in:
lib/cheeky-pi/animation/fade.rb

Constant Summary

Constants inherited from Base

Base::TICKRATE

Instance Method Summary collapse

Methods inherited from Base

#complete, #halt, #percent, #promise, #safe_percent, #sine, #start, #tick, #triangle

Constructor Details

#initialize(duration, light, options = {}) ⇒ Fade

Returns a new instance of Fade.



7
8
9
10
11
12
# File 'lib/cheeky-pi/animation/fade.rb', line 7

def initialize(duration, light, options={})
  super

  @to = options[:to]
  @from = options[:from]
end

Instance Method Details

#animateObject



18
19
20
# File 'lib/cheeky-pi/animation/fade.rb', line 18

def animate
  @light.set(@from.blend(@to, safe_percent))
end

#handle_completeObject



14
15
16
# File 'lib/cheeky-pi/animation/fade.rb', line 14

def handle_complete
  @light.set @to
end