class Gosu::Color
- Gosu::Color
- Reference
- Object
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.
Defined in:
gosu/color.crConstant Summary
-
AQUA =
Gosu::Color.argb(4278255615_i64)
-
BLACK =
Gosu::Color.argb(4278190080_i64)
-
BLUE =
Gosu::Color.argb(4278190335_i64)
-
CYAN =
Gosu::Color.argb(4278255615_i64)
-
FUCHSIA =
Gosu::Color.argb(4294902015_i64)
-
GRAY =
Gosu::Color.argb(4286611584_i64)
-
GREEN =
Gosu::Color.argb(4278255360_i64)
-
NONE =
Gosu::Color.argb(0)
-
RED =
Gosu::Color.argb(4294901760_i64)
-
WHITE =
Gosu::Color.argb(4294967295_i64)
-
YELLOW =
Gosu::Color.argb(4294967040_i64)
Constructors
-
.new(alpha : UInt8 | Int32, red : UInt8 | Int32, green : UInt8 | Int32, blue : UInt8 | Int32)
Creates color from four unsigned 8-bit integers.
-
.new(color : UInt32)
Creates color from 0xAARRGGBB integer literal.
Class Method Summary
- .argb(alpha : UInt8 | Int32, red : UInt8 | Int32, green : UInt8 | Int32, blue : UInt8 | Int32) : Gosu::Color
-
.argb(color : UInt32) : Gosu::Color
Creates color from 0xAARRGGBB integer literal.
-
.from_ahsv(alpha : UInt8 | Int32, hue : Float64, saturation : Float64, value : Float64) : Gosu::Color
Converts an HSV triplet to a color with the alpha channel set to a given value.
-
.from_hsv(hue : Float64, saturation : Float64, value : Float64) : Gosu::Color
Converts an HSV triplet to an opaque color.
- .rgb(red : UInt8 | Int32, green : UInt8 | Int32, blue : UInt8 | Int32) : Gosu::Color
- .rgba(red : UInt8 | Int32, green : UInt8 | Int32, blue : UInt8 | Int32, alpha : UInt8 | Int32) : Gosu::Color
-
.safe_to_u8(value : Int32 | UInt8) : UInt8
Converts Int32 to UInt8 safely, by clamping value to range [0; 255] then converting to UInt8.
Instance Method Summary
- #==(other : Gosu::Color) : Bool
-
#alpha : UInt8
Returns the color's alpha channel.
-
#alpha=(value : UInt8 | Int32) : UInt32
Set the color's alpha channel.
-
#blue : UInt8
Returns the color's blue channel.
-
#blue=(value : UInt8 | Int32) : UInt32
Sets the color's green channel.
- #eql?(other) : Bool
-
#gl : UInt32
Returns a 32-bit representation of the color suitable for use with OpenGL calls.
-
#green : UInt8
Returns the color's green channel.
-
#green=(value : UInt8 | Int32) : UInt32
Sets the color's green channel.
-
#hash
Generates an
UInt64
hash value for this object. -
#hue : Float64
Returns the color's hue.
-
#hue=(value : Float64 | Int32) : UInt32
Sets the color's hue.
-
#red : UInt8
Returns the color's red channel.
-
#red=(value : UInt8 | Int32) : UInt32
Sets the color's red channel.
-
#saturation : Float64
Returns the color's saturation.
-
#saturation=(value : Float64 | Int32) : UInt32
Sets the color's saturation.
-
#value : Float64
Returns the color's value (lightness).
-
#value=(value : Float64 | Int32) : UInt32
Sets the color's value.
Constructor Detail
Creates color from four unsigned 8-bit integers.
Class Method Detail
Converts an HSV triplet to a color with the alpha channel set to a given value.
Converts an HSV triplet to an opaque color.
Converts Int32 to UInt8 safely, by clamping value to range [0; 255] then converting to UInt8.
Instance Method Detail
Returns a 32-bit representation of the color suitable for use with OpenGL calls. This color is stored in a fixed order in memory and its integer value may vary depending on your system's byte order.
Generates an UInt64
hash value for this object.
This method must have the property that a == b
implies a.hash == b.hash
.
The hash value is used along with #==
by the Hash
class to determine if two objects
reference the same hash key.
Subclasses must not override this method. Instead, they must define hash(hasher)
,
though usually the macro def_hash
can be used to generate this method.