Class: Color
- Inherits:
-
Object
- Object
- Color
- Defined in:
- lib/color.rb
Overview
Color components grouped into a single object. Colors consist of red, green, blue, and alpha. Each color component uses a floating-point value and is restricted to the range 0 to 255.
Instance Attribute Summary (collapse)
-
- (Float) alpha
Value of the alpha component from 0 to 255.
-
- (Float) blue
Value of the blue component from 0 to 255.
-
- (Float) green
Value of the green component from 0 to 255.
-
- (Float) red
Value of the red component from 0 to 255.
Instance Method Summary (collapse)
-
- (Color) initialize(*args)
constructor
Creates the color object and sets the initial values.
-
- (self) set(*args)
Sets all components at once.
Constructor Details
Instance Attribute Details
- (Float) alpha
Value of the alpha component from 0 to 255. 0 is completely transparent and 255 is fully opaque. Out of range values are automatically corrected.
56 57 58 |
# File 'lib/color.rb', line 56 def alpha @alpha end |
- (Float) blue
Value of the blue component from 0 to 255. Out of range values are automatically corrected.
50 51 52 |
# File 'lib/color.rb', line 50 def blue @blue end |
- (Float) green
Value of the green component from 0 to 255. Out of range values are automatically corrected.
45 46 47 |
# File 'lib/color.rb', line 45 def green @green end |
- (Float) red
Value of the red component from 0 to 255. Out of range values are automatically corrected.
40 41 42 |
# File 'lib/color.rb', line 40 def red @red end |
Instance Method Details
- (self) set(red, green, blue, alpha = 255) - (self) set(color)
Sets all components at once.
33 34 35 |
# File 'lib/color.rb', line 33 def set(*args) fail NotImplementedError end |