Class: LifxToys::Colors
- Inherits:
-
Object
- Object
- LifxToys::Colors
- Defined in:
- lib/lifx_toys/colors.rb
Constant Summary collapse
- HUE_RANGE =
0..360
- BRIGHTNESS_RANGE =
20..80
- SATURATION_RANGE =
20..100
- CYCLE_TIME =
10.0
Instance Method Summary collapse
-
#initialize ⇒ Colors
constructor
A new instance of Colors.
- #random_brightness ⇒ Object
- #random_hue ⇒ Object
- #random_saturation ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize ⇒ Colors
Returns a new instance of Colors.
12 13 14 |
# File 'lib/lifx_toys/colors.rb', line 12 def initialize @lights = LifxHttp::LifxLight.get_lights.select{|x| x.connected } end |
Instance Method Details
#random_brightness ⇒ Object
33 34 35 |
# File 'lib/lifx_toys/colors.rb', line 33 def random_brightness rand(BRIGHTNESS_RANGE).to_f / 100 end |
#random_hue ⇒ Object
25 26 27 |
# File 'lib/lifx_toys/colors.rb', line 25 def random_hue rand(HUE_RANGE) end |
#random_saturation ⇒ Object
29 30 31 |
# File 'lib/lifx_toys/colors.rb', line 29 def random_saturation rand(SATURATION_RANGE).to_f / 100 end |
#run ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/lifx_toys/colors.rb', line 16 def run while (true) @lights.each do |light| light.set_color("hue:#{random_hue} saturation:#{random_saturation} brightness:#{random_brightness}", duration: CYCLE_TIME* 1.5) sleep(CYCLE_TIME/ @lights.count) end end end |