Class: WSLight::Set::ColorSet
- Inherits:
-
Object
- Object
- WSLight::Set::ColorSet
- Defined in:
- lib/ws_light/set/color_set.rb
Overview
Base set with one color
Direct Known Subclasses
GradientSet, RainbowSet, RandomSet, SemolinaSet, StarSet, StrawberrySet, WatermelonSet
Constant Summary collapse
- DEFAULT_LENGTH =
160
- DEFAULT_TYPE =
:double
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#full_length ⇒ Object
Returns the value of attribute full_length.
-
#length ⇒ Object
Returns the value of attribute length.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #frame ⇒ Object
- #frame_data ⇒ Object
- #init ⇒ Object
-
#initialize(length = DEFAULT_LENGTH, type = DEFAULT_TYPE) ⇒ ColorSet
constructor
A new instance of ColorSet.
- #next_frame ⇒ Object
- #pixel(_number, _frame = 0) ⇒ Object
Constructor Details
#initialize(length = DEFAULT_LENGTH, type = DEFAULT_TYPE) ⇒ ColorSet
Returns a new instance of ColorSet.
12 13 14 15 16 17 18 19 |
# File 'lib/ws_light/set/color_set.rb', line 12 def initialize(length = DEFAULT_LENGTH, type = DEFAULT_TYPE) @length = length @type = type @full_length = (@type == :double ? @length * 2 : @length) @color = Color.random @frame_count = 0 init end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
10 11 12 |
# File 'lib/ws_light/set/color_set.rb', line 10 def color @color end |
#full_length ⇒ Object
Returns the value of attribute full_length.
10 11 12 |
# File 'lib/ws_light/set/color_set.rb', line 10 def full_length @full_length end |
#length ⇒ Object
Returns the value of attribute length.
10 11 12 |
# File 'lib/ws_light/set/color_set.rb', line 10 def length @length end |
#type ⇒ Object
Returns the value of attribute type.
10 11 12 |
# File 'lib/ws_light/set/color_set.rb', line 10 def type @type end |
Instance Method Details
#frame ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/ws_light/set/color_set.rb', line 25 def frame length = type == :double ? @length * 2 : @length set = [] length.times do set << @color end set end |
#frame_data ⇒ Object
21 22 23 |
# File 'lib/ws_light/set/color_set.rb', line 21 def frame_data frame.collect{|color| color.to_a}.flatten end |
#init ⇒ Object
42 43 44 |
# File 'lib/ws_light/set/color_set.rb', line 42 def init # do some initializing stuff here end |
#next_frame ⇒ Object
34 35 36 |
# File 'lib/ws_light/set/color_set.rb', line 34 def next_frame # reimplement if necessary, please :) end |
#pixel(_number, _frame = 0) ⇒ Object
38 39 40 |
# File 'lib/ws_light/set/color_set.rb', line 38 def pixel(_number, _frame = 0) @color end |