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:


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

def initialize(*args); end

Instance Attribute Details

#alphaInteger

Returns the color's alpha channel.

Returns:

  • (Integer)

    the color's alpha channel.


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

def alpha
  @alpha
end

#blueInteger

Returns the color's blue channel.

Returns:

  • (Integer)

    the color's blue channel.


139
140
141
# File 'rdoc/gosu.rb', line 139

def blue
  @blue
end

#greenInteger

Returns the color's green channel.

Returns:

  • (Integer)

    the color's green channel.


135
136
137
# File 'rdoc/gosu.rb', line 135

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


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

def hue
  @hue
end

#redInteger

Returns the color's red channel.

Returns:

  • (Integer)

    the color's red channel.


131
132
133
# File 'rdoc/gosu.rb', line 131

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


147
148
149
# File 'rdoc/gosu.rb', line 147

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


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.

Returns:

  • (Color)

    a new instance of Color

See Also:


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.

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:


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.

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:


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

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:


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

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.


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

def argb; end

#dupColor

Returns a copy of the color.

Returns:

  • (Color)

    a copy of the color.


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

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.


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

def gl; end