Class: WSLight::Animation::SlideLeftAnimation

Inherits:
BaseAnimation show all
Defined in:
lib/ws_light/animation/slide_left_animation.rb

Overview

Slides from one set to another from left to right (obviously depending on the hardware setup)

Instance Attribute Summary

Attributes inherited from BaseAnimation

#set_from, #set_to, #type

Instance Method Summary collapse

Methods inherited from BaseAnimation

#frame_data, #initialize

Constructor Details

This class inherits a constructor from WSLight::Animation::BaseAnimation

Instance Method Details

#frame(count) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/ws_light/animation/slide_left_animation.rb', line 11

def frame(count)
  set = []
  reverse_set = []

  @set_from.next_frame
  @set_to.next_frame

  (set_from.length - count).times do |i|
    set << set_from.pixel(i)
    reverse_set << set_from.pixel((set_from.length * 2) - 1 - i) if set_from.type == :double
  end

  count.times do |i|
    set << set_to.pixel(set_from.length - count + i)
    reverse_set << set_to.pixel(set_from.length + count - 1 - i) if set_from.type == :double
  end

  set += reverse_set.reverse if set_from.type == :double

  set
end

#framesObject



7
8
9
# File 'lib/ws_light/animation/slide_left_animation.rb', line 7

def frames
  @set_from.length + 1 # one for each led plus one for all zero
end

#frames_per_secondObject



33
34
35
# File 'lib/ws_light/animation/slide_left_animation.rb', line 33

def frames_per_second
  nil
end