Class: Gosu::Color

Inherits:
Object
  • Object
show all
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

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

Creating colors. collapse

Instance Method Summary collapse

Constructor Details

#initialize(argb) ⇒ Color #initialize(a, r, g, b) ⇒ Color

Returns a new instance of Color

Overloads:

  • #initialize(argb) ⇒ Color

    Parameters:

    • argb (Integer)

      an integer of the form 0xAARRGGBB.

  • #initialize(a, r, g, b) ⇒ Color

    Parameters:

    • a (Integer)

      the color's alpha channel in the range [0; 255].

    • r (Integer)

      the color's red channel in the range [0; 255].

    • g (Integer)

      the color's green channel in the range [0; 255].

    • b (Integer)

      the color's blue channel in the range [0; 255].

See Also:



144
# File 'rdoc/gosu.rb', line 144

def initialize(*args); end

Instance Attribute Details

#alphaInteger

Returns the color's alpha channel.

Returns:

  • (Integer)

    the color's alpha channel.



102
103
104
# File 'rdoc/gosu.rb', line 102

def alpha
  @alpha
end

#blueInteger

Returns the color's blue channel.

Returns:

  • (Integer)

    the color's blue channel.



114
115
116
# File 'rdoc/gosu.rb', line 114

def blue
  @blue
end

#greenInteger

Returns the color's green channel.

Returns:

  • (Integer)

    the color's green channel.



110
111
112
# File 'rdoc/gosu.rb', line 110

def green
  @green
end

#hueFloat

Returns the color's hue in the range [0.0; 360.0).

Returns:

  • (Float)

    the color's hue in the range [0.0; 360.0).



118
119
120
# File 'rdoc/gosu.rb', line 118

def hue
  @hue
end

#redInteger

Returns the color's red channel.

Returns:

  • (Integer)

    the color's red channel.



106
107
108
# File 'rdoc/gosu.rb', line 106

def red
  @red
end

#saturationFloat

Returns the color's saturation in the range [0.0; 1.0].

Returns:

  • (Float)

    the color's saturation in the range [0.0; 1.0].



122
123
124
# File 'rdoc/gosu.rb', line 122

def saturation
  @saturation
end

#valueFloat

Returns the color's value in the range [0.0; 1.0].

Returns:

  • (Float)

    the color's value in the range [0.0; 1.0].



126
127
128
# File 'rdoc/gosu.rb', line 126

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.

Returns:

  • (Color)

    a new instance of Color

See Also:



170
# File 'rdoc/gosu.rb', line 170

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.

Parameters:

  • a (Integer)

    the color's opacity in the range [0; 255].

  • h (Float)

    the color's hue in the range [0.0; 360.0).

  • s (Float)

    the color's saturation in the range [0.0; 1.0].

  • v (Float)

    the color's value in the range [0.0; 1.0].

Returns:

  • (Color)

    a color corresponding to the HSV triplet.

See Also:



189
# File 'rdoc/gosu.rb', line 189

def self.from_ahsv(a, h, s, v); end

.from_hsv(h, s, v) ⇒ Color

Converts an HSV triplet to an opaque color.

Parameters:

  • h (Float)

    the color's hue in the range [0.0; 360.0).

  • s (Float)

    the color's saturation in the range [0.0; 1.0].

  • v (Float)

    the color's value in the range [0.0; 1.0].

Returns:

  • (Color)

    a color corresponding to the HSV triplet.

See Also:



180
# File 'rdoc/gosu.rb', line 180

def self.from_hsv(h, s, v); end

.rgba(rgba) ⇒ Color .rgba(r, g, b, a) ⇒ Color

Returns a new instance of Color

Overloads:

  • .rgba(rgba) ⇒ Color

    Parameters:

    • argb (Integer)

      an integer of the form 0xRRGGBBAA.

  • .rgba(r, g, b, a) ⇒ Color

    Parameters:

    • a (Integer)

      the color's alpha channel in the range [0; 255].

    • r (Integer)

      the color's red channel in the range [0; 255].

    • g (Integer)

      the color's green channel in the range [0; 255].

    • b (Integer)

      the color's blue channel in the range [0; 255].

Returns:

  • (Color)

    a new instance of Color

See Also:



160
# File 'rdoc/gosu.rb', line 160

def self.rgba(*args); end

Instance Method Details

#dupColor

Returns a copy of the color.

Returns:

  • (Color)

    a copy of the color.



200
# File 'rdoc/gosu.rb', line 200

def dup; end

#glInteger

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.

Returns:

  • (Integer)

    a 32-bit OpenGL color.



196
# File 'rdoc/gosu.rb', line 196

def gl; end