Class: GTK::Console::Color

Inherits:
Object show all
Defined in:
dragon/console_color.rb

Instance Method Summary collapse

Constructor Details

#initialize(color) ⇒ Color

Returns a new instance of Color.


11
12
13
14
# File 'dragon/console_color.rb', line 11

def initialize(color)
  @color = color
  @color << 255 if @color.size == 3
end

Instance Method Details

#mult_alpha(alpha_modifier) ⇒ Object


16
17
18
# File 'dragon/console_color.rb', line 16

def mult_alpha(alpha_modifier)
  Color.new [@color[0], @color[1], @color[2], (@color[3].to_f * alpha_modifier).to_i]
end

#to_aObject

Support splat operator


21
22
23
# File 'dragon/console_color.rb', line 21

def to_a
  @color
end

#to_hObject


25
26
27
# File 'dragon/console_color.rb', line 25

def to_h
  { r: @color[0], g: @color[1], b: @color[2], a: @color[3] }
end