Class: Ruby2D::Color::Set

Inherits:
Object
  • Object
show all
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.



8
9
10
# File 'lib/ruby2d/color.rb', line 8

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

Instance Method Details

#[](i) ⇒ Object



12
13
14
# File 'lib/ruby2d/color.rb', line 12

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

#lengthObject



16
17
18
# File 'lib/ruby2d/color.rb', line 16

def length
  @colors.length
end

#opacityObject



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

def opacity; @colors[0].opacity end

#opacity=(opacity) ⇒ Object



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

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