Class: CheekyPi::Animation::Throb

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

Constant Summary

Constants inherited from Base

Base::TICKRATE

Instance Method Summary collapse

Methods inherited from Cycle

#cycle_percent

Methods inherited from Base

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

Constructor Details

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

Returns a new instance of Throb.



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

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

  @to = options[:to]
  @from = options[:from]
  @wave = options[:type] || :triangle
end

Instance Method Details

#animateObject



16
17
18
19
# File 'lib/cheeky-pi/animation/throb.rb', line 16

def animate
  blend_percent = send(@wave, cycle_percent)
  @light.set(@from.blend(@to, blend_percent))
end