class

Gosu::Color

Inherits Reference / Object

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.

Constants

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.

Source
new(color : UInt32)

Creates color from 0xAARRGGBB integer literal.

Source

Class methods

argb(alpha : UInt8 | Int32, red : UInt8 | Int32, green : UInt8 | Int32, blue : UInt8 | Int32) : Gosu::Color
Source
argb(color : UInt32) : Gosu::Color

Creates color from 0xAARRGGBB integer literal.

Source
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.

Source
from_hsv(hue : Float64, saturation : Float64, value : Float64) : Gosu::Color

Converts an HSV triplet to an opaque color.

Source
rgb(red : UInt8 | Int32, green : UInt8 | Int32, blue : UInt8 | Int32) : Gosu::Color
Source
rgba(red : UInt8 | Int32, green : UInt8 | Int32, blue : UInt8 | Int32, alpha : UInt8 | Int32) : Gosu::Color
Source
safe_to_u8(value : Int32 | UInt8) : UInt8

Converts Int32 to UInt8 safely, by clamping value to range [0; 255] then converting to UInt8.

Source

Instance methods

==(other : Gosu::Color) : Bool
Source
alpha

Returns the color's alpha channel.

Source
alpha=(value : UInt8 | Int32) : UInt32

Set the color's alpha channel.

Source
blue

Returns the color's blue channel.

Source
blue=(value : UInt8 | Int32) : UInt32

Sets the color's green channel.

Source
eql?(other) : Bool
Source
gl

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.

Source
green

Returns the color's green channel.

Source
green=(value : UInt8 | Int32) : UInt32

Sets the color's green channel.

Source
hash

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.

Source
hue

Returns the color's hue.

Source
hue=(value : Float64 | Int32) : UInt32

Sets the color's hue.

Source
red

Returns the color's red channel.

Source
red=(value : UInt8 | Int32) : UInt32

Sets the color's red channel.

Source
saturation

Returns the color's saturation.

Source
saturation=(value : Float64 | Int32) : UInt32

Sets the color's saturation.

Source
value

Returns the color's value (lightness).

Source
value=(value : Float64 | Int32) : UInt32

Sets the color's value.

Source