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

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

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:



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

def initialize(*args); end

Instance Attribute Details

#alphaInteger

Returns the color’s alpha channel.

Returns:

  • (Integer)

    the color’s alpha channel.



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

def alpha
  @alpha
end

#blueInteger

Returns the color’s blue channel.

Returns:

  • (Integer)

    the color’s blue channel.



137
138
139
# File 'rdoc/gosu.rb', line 137

def blue
  @blue
end

#greenInteger

Returns the color’s green channel.

Returns:

  • (Integer)

    the color’s green channel.



133
134
135
# File 'rdoc/gosu.rb', line 133

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



141
142
143
# File 'rdoc/gosu.rb', line 141

def hue
  @hue
end

#redInteger

Returns the color’s red channel.

Returns:

  • (Integer)

    the color’s red channel.



129
130
131
# File 'rdoc/gosu.rb', line 129

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



145
146
147
# File 'rdoc/gosu.rb', line 145

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



149
150
151
# File 'rdoc/gosu.rb', line 149

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:



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

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:



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

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:



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

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:



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

def self.rgba(*args); end

Instance Method Details

#argbInteger Also known as: to_i

Returns a 32-bit representation of the color in 0xAARRGGBB format.

Returns:

  • (Integer)

    a 32-bit representation of the color in 0xAARRGGBB format.



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

def argb; end

#dupColor

Returns a copy of the color.

Returns:

  • (Color)

    a copy of the color.



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

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 format in memory and its integer value may vary depending on your system’s byte order.

Returns:

  • (Integer)

    a 32-bit OpenGL color.



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

def gl; end