Sha256: 7339608fafd61c1fd92cdbc1a47f79db221716010113ac663ac837e361481034

Contents?: true

Size: 945 Bytes

Versions: 1

Compression:

Stored size: 945 Bytes

Contents

require 'ws_light/color'

module WSLight
  module Set
    # Base set with one color
    class ColorSet
      DEFAULT_LENGTH = 160
      DEFAULT_TYPE = :double

      attr_accessor :type, :length, :color, :full_length

      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

      def frame_data
        frame.collect(&:to_a).flatten
      end

      def frame
        length = type == :double ? @length * 2 : @length
        set = []
        length.times do
          set << @color
        end
        set
      end

      def next_frame
        # reimplement if necessary, please :)
      end

      def pixel(_number, _frame = 0)
        @color
      end

      def init
        # do some initializing stuff here
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ws_light-0.4.2 lib/ws_light/set/color_set.rb