Gosu
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Gosu::Color Class Reference

Represents an RGBA color value with 8 bits for each channel. More...

Public Types

typedef std::uint8_t Channel
 

Public Member Functions

 Color ()
 The default constructor does not initialize the color to any value. More...
 
 Color (unsigned argb)
 Conversion constructor for literals of the form 0xaarrggbb. More...
 
 Color (Channel red, Channel green, Channel blue)
 
 Color (Channel alpha, Channel red, Channel green, Channel blue)
 
Channel red () const
 
Channel green () const
 
Channel blue () const
 
Channel alpha () const
 
void set_red (Channel value)
 
void set_green (Channel value)
 
void set_blue (Channel value)
 
void set_alpha (Channel value)
 
double hue () const
 Returns the hue of the color, in the usual range of 0..360. More...
 
void set_hue (double h)
 Changes the current color so hue() will return h. More...
 
double saturation () const
 Returns the saturation of the color, in the range of 0..1. More...
 
void set_saturation (double s)
 Changes the current color so saturation() will return s. More...
 
double value () const
 Returns the value (brightness) of the color, in the range of 0..1. More...
 
void set_value (double v)
 Changes the current color so value() will return v. More...
 
std::uint32_t argb () const
 Returns the color in 0xaarrggbb representation. More...
 
std::uint32_t bgr () const
 Returns the color in 0x00bbggrr representation. Useful for Win32 programming. More...
 
std::uint32_t abgr () const
 Returns the color in 0xaabbggrr representation. More...
 
std::uint32_t gl () const
 Returns the internal representation of the color (RGBA in memory). More...
 

Static Public Member Functions

static Color from_hsv (double h, double s, double v)
 Constructs a color from the given hue/saturation/value triple. More...
 
static Color from_ahsv (Channel alpha, double h, double s, double v)
 Constructs a color from the given hue/saturation/value triple. More...
 

Static Public Attributes

static const unsigned GL_FORMAT = 0x1908
 
static const Color NONE
 
static const Color BLACK
 
static const Color GRAY
 
static const Color WHITE
 
static const Color AQUA
 
static const Color RED
 
static const Color GREEN
 
static const Color BLUE
 
static const Color YELLOW
 
static const Color FUCHSIA
 
static const Color CYAN
 

Detailed Description

Represents an RGBA color value with 8 bits for each channel.

Can be implicitly constructed from literals of the form 0xaarrggbb. Has fast value semantics. The four-byte layout in memory is RGBA. On Big-Endian machines the unsigned int will look like 0xrrggbbaa, on Little-Endian machines it is 0xaabbggrr.

Definition at line 16 of file Color.hpp.

Member Typedef Documentation

◆ Channel

typedef std::uint8_t Gosu::Color::Channel

Definition at line 26 of file Color.hpp.

Constructor & Destructor Documentation

◆ Color() [1/4]

Gosu::Color::Color ( )

The default constructor does not initialize the color to any value.

Definition at line 30 of file Color.hpp.

◆ Color() [2/4]

Gosu::Color::Color ( unsigned  argb)

Conversion constructor for literals of the form 0xaarrggbb.

Definition at line 35 of file Color.hpp.

◆ Color() [3/4]

Gosu::Color::Color ( Channel  red,
Channel  green,
Channel  blue 
)

Definition at line 40 of file Color.hpp.

◆ Color() [4/4]

Gosu::Color::Color ( Channel  alpha,
Channel  red,
Channel  green,
Channel  blue 
)

Definition at line 45 of file Color.hpp.

References alpha(), from_ahsv(), and from_hsv().

Member Function Documentation

◆ abgr()

std::uint32_t Gosu::Color::abgr ( ) const

Returns the color in 0xaabbggrr representation.

Definition at line 128 of file Color.hpp.

References alpha(), blue(), green(), and red().

◆ alpha()

Channel Gosu::Color::alpha ( ) const

Definition at line 74 of file Color.hpp.

Referenced by abgr(), argb(), and Color().

◆ argb()

std::uint32_t Gosu::Color::argb ( ) const

Returns the color in 0xaarrggbb representation.

Definition at line 122 of file Color.hpp.

References alpha(), blue(), green(), and red().

◆ bgr()

std::uint32_t Gosu::Color::bgr ( ) const

Returns the color in 0x00bbggrr representation. Useful for Win32 programming.

Definition at line 125 of file Color.hpp.

References blue(), green(), and red().

◆ blue()

Channel Gosu::Color::blue ( ) const

Definition at line 69 of file Color.hpp.

Referenced by abgr(), argb(), and bgr().

◆ from_ahsv()

static Color Gosu::Color::from_ahsv ( Channel  alpha,
double  h,
double  s,
double  v 
)
static

Constructs a color from the given hue/saturation/value triple.

Ranges of these values are given as 0..360, 0..1, and 0..1, respectively.

Referenced by Color().

◆ from_hsv()

static Color Gosu::Color::from_hsv ( double  h,
double  s,
double  v 
)
static

Constructs a color from the given hue/saturation/value triple.

Ranges of these values are given as 0..360, 0..1, and 0..1, respectively.

Referenced by Color().

◆ gl()

std::uint32_t Gosu::Color::gl ( ) const

Returns the internal representation of the color (RGBA in memory).

Definition at line 131 of file Color.hpp.

Referenced by Gosu::operator!=(), Gosu::operator<(), and Gosu::operator==().

◆ green()

Channel Gosu::Color::green ( ) const

Definition at line 64 of file Color.hpp.

Referenced by abgr(), argb(), and bgr().

◆ hue()

double Gosu::Color::hue ( ) const

Returns the hue of the color, in the usual range of 0..360.

Referenced by set_alpha().

◆ red()

Channel Gosu::Color::red ( ) const

Definition at line 59 of file Color.hpp.

Referenced by abgr(), argb(), and bgr().

◆ saturation()

double Gosu::Color::saturation ( ) const

Returns the saturation of the color, in the range of 0..1.

Referenced by set_alpha().

◆ set_alpha()

void Gosu::Color::set_alpha ( Channel  value)

Definition at line 97 of file Color.hpp.

References hue(), saturation(), set_hue(), set_saturation(), set_value(), and value().

◆ set_blue()

void Gosu::Color::set_blue ( Channel  value)

Definition at line 91 of file Color.hpp.

◆ set_green()

void Gosu::Color::set_green ( Channel  value)

Definition at line 85 of file Color.hpp.

◆ set_hue()

void Gosu::Color::set_hue ( double  h)

Changes the current color so hue() will return h.

Referenced by set_alpha().

◆ set_red()

void Gosu::Color::set_red ( Channel  value)

Definition at line 79 of file Color.hpp.

◆ set_saturation()

void Gosu::Color::set_saturation ( double  s)

Changes the current color so saturation() will return s.

Referenced by set_alpha().

◆ set_value()

void Gosu::Color::set_value ( double  v)

Changes the current color so value() will return v.

Referenced by set_alpha().

◆ value()

double Gosu::Color::value ( ) const

Returns the value (brightness) of the color, in the range of 0..1.

Referenced by set_alpha().

Member Data Documentation

◆ AQUA

const Color Gosu::Color::AQUA
static

Definition at line 138 of file Color.hpp.

◆ BLACK

const Color Gosu::Color::BLACK
static

Definition at line 134 of file Color.hpp.

◆ BLUE

const Color Gosu::Color::BLUE
static

Definition at line 141 of file Color.hpp.

◆ CYAN

const Color Gosu::Color::CYAN
static

Definition at line 144 of file Color.hpp.

◆ FUCHSIA

const Color Gosu::Color::FUCHSIA
static

Definition at line 143 of file Color.hpp.

◆ GL_FORMAT

const unsigned Gosu::Color::GL_FORMAT = 0x1908
static

Definition at line 27 of file Color.hpp.

◆ GRAY

const Color Gosu::Color::GRAY
static

Definition at line 135 of file Color.hpp.

◆ GREEN

const Color Gosu::Color::GREEN
static

Definition at line 140 of file Color.hpp.

◆ NONE

const Color Gosu::Color::NONE
static

Definition at line 133 of file Color.hpp.

Referenced by Gosu::Bitmap::height().

◆ RED

const Color Gosu::Color::RED
static

Definition at line 139 of file Color.hpp.

◆ WHITE

const Color Gosu::Color::WHITE
static

Definition at line 136 of file Color.hpp.

◆ YELLOW

const Color Gosu::Color::YELLOW
static

Definition at line 142 of file Color.hpp.


The documentation for this class was generated from the following file: