Class: Ruby2D::Color::Set

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ruby2d/color.rb

Overview

Color::Set represents an array of colors.

Instance Method Summary collapse

Constructor Details

#initialize(colors) ⇒ Set

Returns a new instance of Set.



14
15
16
# File 'lib/ruby2d/color.rb', line 14

def initialize(colors)
  @colors = colors.map { |c| Color.new(c) }
end

Instance Method Details

#[](index) ⇒ Object



18
19
20
# File 'lib/ruby2d/color.rb', line 18

def [](index)
  @colors[index]
end

#each(&block) ⇒ Object



28
29
30
# File 'lib/ruby2d/color.rb', line 28

def each(&block)
  @colors.each(&block)
end

#firstObject



32
33
34
# File 'lib/ruby2d/color.rb', line 32

def first
  @colors.first
end

#lastObject



36
37
38
# File 'lib/ruby2d/color.rb', line 36

def last
  @colors.last
end

#lengthObject Also known as: count



22
23
24
# File 'lib/ruby2d/color.rb', line 22

def length
  @colors.length
end

#opacityObject



40
41
42
# File 'lib/ruby2d/color.rb', line 40

def opacity
  @colors.first.opacity
end

#opacity=(opacity) ⇒ Object



44
45
46
47
48
# File 'lib/ruby2d/color.rb', line 44

def opacity=(opacity)
  @colors.each do |color|
    color.opacity = opacity
  end
end