Class: Gosu::Color
- Inherits:
-
Object
- Object
- Gosu::Color
- Defined in:
- rdoc/gosu.rb
Overview
Represents an ARGB color value with 8 bits for each channel. Colors can be used interchangeably with integer literals of the form 0xAARRGGBB in all Gosu APIs.
Constant Summary collapse
- GL_FORMAT =
Returns an OpenGL integer constant that identifies the RGBA color format that Gosu uses.
:some_integer
- NONE =
Gosu::Color.argb(0x00_000000)
- BLACK =
Gosu::Color.argb(0xff_000000)
- GRAY =
Gosu::Color.argb(0xff_808080)
- WHITE =
Gosu::Color.argb(0xff_ffffff)
- AQUA =
Gosu::Color.argb(0xff_00ffff)
- RED =
Gosu::Color.argb(0xff_ff0000)
- GREEN =
Gosu::Color.argb(0xff_00ff00)
- BLUE =
Gosu::Color.argb(0xff_0000ff)
- YELLOW =
Gosu::Color.argb(0xff_ffff00)
- FUCHSIA =
Gosu::Color.argb(0xff_ff00ff)
- CYAN =
Gosu::Color.argb(0xff_00ffff)
Instance Attribute Summary collapse
-
#alpha ⇒ Integer
The color’s alpha channel.
-
#blue ⇒ Integer
The color’s blue channel.
-
#green ⇒ Integer
The color’s green channel.
-
#hue ⇒ Float
The color’s hue in the range [0.0; 360.0).
-
#red ⇒ Integer
The color’s red channel.
-
#saturation ⇒ Float
The color’s saturation in the range [0.0; 1.0].
-
#value ⇒ Float
The color’s value in the range [0.0; 1.0].
Creating colors. collapse
-
.argb(*args) ⇒ Color
This method is equivalent to calling ‘Color.new`, but the name makes the parameter order explicit.
-
.from_ahsv(a, h, s, v) ⇒ Color
Converts an HSV triplet to a color with the alpha channel set to a given value.
-
.from_hsv(h, s, v) ⇒ Color
Converts an HSV triplet to an opaque color.
-
.rgba(*args) ⇒ Color
A new instance of Color.
-
#initialize(*args) ⇒ Color
constructor
A new instance of Color.
Instance Method Summary collapse
-
#argb ⇒ Integer
(also: #to_i)
A 32-bit representation of the color in 0xAARRGGBB format.
-
#dup ⇒ Color
A copy of the color.
-
#gl ⇒ Integer
Returns a 32-bit representation of the color suitable for use with OpenGL calls.
Constructor Details
Instance Attribute Details
#alpha ⇒ Integer
Returns the color’s alpha channel.
127 128 129 |
# File 'rdoc/gosu.rb', line 127 def alpha @alpha end |
#blue ⇒ Integer
Returns the color’s blue channel.
139 140 141 |
# File 'rdoc/gosu.rb', line 139 def blue @blue end |
#green ⇒ Integer
Returns the color’s green channel.
135 136 137 |
# File 'rdoc/gosu.rb', line 135 def green @green end |
#hue ⇒ Float
Returns the color’s hue in the range [0.0; 360.0).
143 144 145 |
# File 'rdoc/gosu.rb', line 143 def hue @hue end |
#red ⇒ Integer
Returns the color’s red channel.
131 132 133 |
# File 'rdoc/gosu.rb', line 131 def red @red end |
#saturation ⇒ Float
Returns the color’s saturation in the range [0.0; 1.0].
147 148 149 |
# File 'rdoc/gosu.rb', line 147 def saturation @saturation end |
#value ⇒ Float
Returns the color’s value in the range [0.0; 1.0].
151 152 153 |
# File 'rdoc/gosu.rb', line 151 def value @value end |
Class Method Details
.argb(argb) ⇒ Color .argb(a, r, g, b) ⇒ Color
This method is equivalent to calling ‘Color.new`, but the name makes the parameter order explicit.
195 |
# File 'rdoc/gosu.rb', line 195 def self.argb(*args); end |
.from_ahsv(a, h, s, v) ⇒ Color
Converts an HSV triplet to a color with the alpha channel set to a given value.
214 |
# File 'rdoc/gosu.rb', line 214 def self.from_ahsv(a, h, s, v); end |
.from_hsv(h, s, v) ⇒ Color
Converts an HSV triplet to an opaque color.
205 |
# File 'rdoc/gosu.rb', line 205 def self.from_hsv(h, s, v); end |
Instance Method Details
#argb ⇒ Integer Also known as: to_i
Returns a 32-bit representation of the color in 0xAARRGGBB format.
220 |
# File 'rdoc/gosu.rb', line 220 def argb; end |
#gl ⇒ Integer
Returns a 32-bit representation of the color suitable for use with OpenGL calls. This color is stored in a fixed format in memory and its integer value may vary depending on your system’s byte order.
227 |
# File 'rdoc/gosu.rb', line 227 def gl; end |