Class: Dedalus::Color
- Inherits:
-
Object
- Object
- Dedalus::Color
- Defined in:
- lib/dedalus/palette.rb
Instance Attribute Summary collapse
-
#alpha ⇒ Object
Returns the value of attribute alpha.
-
#blue ⇒ Object
Returns the value of attribute blue.
-
#green ⇒ Object
Returns the value of attribute green.
-
#red ⇒ Object
Returns the value of attribute red.
Instance Method Summary collapse
-
#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.
-
#initialize(red, green, blue, alpha = 160) ⇒ Color
constructor
A new instance of Color.
- #lighten(ratio = 1.10) ⇒ Object
- #to_gosu ⇒ Object
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
#alpha ⇒ Object
Returns the value of attribute alpha.
3 4 5 |
# File 'lib/dedalus/palette.rb', line 3 def alpha @alpha end |
#blue ⇒ Object
Returns the value of attribute blue.
3 4 5 |
# File 'lib/dedalus/palette.rb', line 3 def blue @blue end |
#green ⇒ Object
Returns the value of attribute green.
3 4 5 |
# File 'lib/dedalus/palette.rb', line 3 def green @green end |
#red ⇒ Object
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_gosu ⇒ Object
28 29 30 |
# File 'lib/dedalus/palette.rb', line 28 def to_gosu Gosu::Color.rgba(red, green, blue, alpha) end |