Class: Dedalus::Color

Inherits:
Object
  • Object
show all
Defined in:
lib/dedalus/palette.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(red, green, blue, alpha = 160) ⇒ Color

Returns a new instance of Color.



5
6
7
8
9
10
# File 'lib/dedalus/palette.rb', line 5

def initialize(red,green,blue,alpha=160)
  @red = red
  @green = green
  @blue = blue
  @alpha = alpha
end

Instance Attribute Details

#alphaObject

Returns the value of attribute alpha.



3
4
5
# File 'lib/dedalus/palette.rb', line 3

def alpha
  @alpha
end

#blueObject

Returns the value of attribute blue.



3
4
5
# File 'lib/dedalus/palette.rb', line 3

def blue
  @blue
end

#greenObject

Returns the value of attribute green.



3
4
5
# File 'lib/dedalus/palette.rb', line 3

def green
  @green
end

#redObject

Returns the value of attribute red.



3
4
5
# File 'lib/dedalus/palette.rb', line 3

def red
  @red
end

Instance Method Details

#darken(ratio = 0.90) ⇒ Object

def mix(other_color) Color.new( (red+other_color.red/2), (green+other_color.green/2), (blue+other_color.blue/2) ) end



20
21
22
# File 'lib/dedalus/palette.rb', line 20

def darken(ratio=0.90)
  Color.new(red*ratio,green*ratio,blue*ratio)
end

#lighten(ratio = 1.10) ⇒ Object



24
25
26
# File 'lib/dedalus/palette.rb', line 24

def lighten(ratio=1.10)
  Color.new(red*ratio,green*ratio,blue*ratio)
end

#to_gosuObject



28
29
30
# File 'lib/dedalus/palette.rb', line 28

def to_gosu
  Gosu::Color.rgba(red, green, blue, alpha)
end