Class: Color
- Inherits:
-
Object
- Object
- Color
- Defined in:
- lib/color.rb
Overview
The RGBA color class. Each component is handled with a floating point value.
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
-
#initialize(red, green, blue, alpha = 255) ⇒ Color
constructor
Creates a Color object.
-
#set(red, green, blue, alpha = 255) ⇒ Object
Sets all components at once.
Constructor Details
#initialize(red, green, blue, alpha = 255) ⇒ Color
Creates a Color object. If alpha is omitted, it is assumed at 255.
26 27 28 |
# File 'lib/color.rb', line 26 def initialize(red, green, blue, alpha=255) set red, green, blue, alpha end |
Instance Attribute Details
#alpha ⇒ Object
Returns the value of attribute alpha.
3 4 5 |
# File 'lib/color.rb', line 3 def alpha @alpha end |
#blue ⇒ Object
Returns the value of attribute blue.
3 4 5 |
# File 'lib/color.rb', line 3 def blue @blue end |
#green ⇒ Object
Returns the value of attribute green.
3 4 5 |
# File 'lib/color.rb', line 3 def green @green end |
#red ⇒ Object
Returns the value of attribute red.
3 4 5 |
# File 'lib/color.rb', line 3 def red @red end |
Instance Method Details
#set(red, green, blue, alpha = 255) ⇒ Object
Sets all components at once.
31 32 33 34 35 36 |
# File 'lib/color.rb', line 31 def set(red, green, blue, alpha=255) self.red = red self.green = green self.blue = blue self.alpha = alpha end |