SDL Utility
Color Struct Reference

A structure holding color data. More...

#include <Color.hpp>

Public Member Functions

 Color ()
 Default constructor (Black) More...
 
 Color (Uint8 r, Uint8 g, Uint8 b, Uint8 a=255)
 Construct color from four 8-Bit integer values. More...
 
 Color (Uint32 color)
 Construct color from a 32-Bit integer value. More...
 
Uint32 ToInt ()
 Returns color data as a 32-Bit integer. More...
 

Static Public Member Functions

static Color FromHSV (Uint16 h, Uint8 s, Uint8 v)
 Generate color from HSV values. More...
 

Public Attributes

Uint8 r
 Red component. More...
 
Uint8 g
 Green component. More...
 
Uint8 b
 Blue component. More...
 
Uint8 a
 Alpha component. More...
 

Static Public Attributes

static const Color Black
 Default Color Black (#000000FF) More...
 
static const Color Red
 Default Color Red (#FF0000FF) More...
 
static const Color Green
 Default Color Green (#00FF00FF) More...
 
static const Color Blue
 Default Color Blue (#0000FFFF) More...
 
static const Color Yellow
 Default Color Yellow (#FFFF00FF) More...
 
static const Color Magenta
 Default Color Magenta (#FF00FFFF) More...
 
static const Color Cyan
 Default Color Cyan (#00FFFFFF) More...
 
static const Color White
 Default Color White (#FFFFFFFF) More...
 
static const Color Transparent
 Default Color Transparent (#00000000) More...
 

Friends

Color operator+ (const Color &left, const Color &right)
 Componentwise color addition. More...
 
Color operator- (const Color &left, const Color &right)
 Componentwise color subtraction. More...
 
Color operator* (const Color &left, const Color &right)
 Componentwise color multiplication. More...
 
Color operator/ (const Color &left, const Color &right)
 Componentwise color division. More...
 
Coloroperator+= (Color &left, const Color &right)
 Componentwise color addition. More...
 
Coloroperator-= (Color &left, const Color &right)
 Componentwise color subtraction. More...
 
Coloroperator*= (Color &left, const Color &right)
 Componentwise color multiplication. More...
 
Coloroperator/= (Color &left, const Color &right)
 Componentwise color division. More...
 
bool operator== (const Color &left, const Color &right)
 Componentwise color comparison. More...
 
bool operator!= (const Color &left, const Color &right)
 Componentwise color comparison. More...
 

Detailed Description

A structure holding color data.

This struct allows for the easy passing of color data between objects or functions. It holds RGBA values and allows for arithmetical operations.

Constructor & Destructor Documentation

◆ Color() [1/3]

Color::Color ( )

Default constructor (Black)

◆ Color() [2/3]

Color::Color ( Uint8  r,
Uint8  g,
Uint8  b,
Uint8  a = 255 
)

Construct color from four 8-Bit integer values.

Parameters
[in]rRed component
[in]gGreen component
[in]bBlue component
[in]aAlpha component

◆ Color() [3/3]

Color::Color ( Uint32  color)

Construct color from a 32-Bit integer value.

Parameters
[in]colorThe color data structured as RGBA

Member Function Documentation

◆ FromHSV()

static Color Color::FromHSV ( Uint16  h,
Uint8  s,
Uint8  v 
)
static

Generate color from HSV values.

Returns
An RGBA Color object generated from HSV

◆ ToInt()

Uint32 Color::ToInt ( )

Returns color data as a 32-Bit integer.

Returns
A 32-Bit containing the RGBA values

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const Color left,
const Color right 
)
friend

Componentwise color comparison.

Parameters
[in]leftLeft operand
[in]rightRight operand
Returns
False if the respective color components are equal, True if not

◆ operator*

Color operator* ( const Color left,
const Color right 
)
friend

Componentwise color multiplication.

Parameters
[in]leftLeft operand
[in]rightRight operand
Returns
left * right

◆ operator*=

Color& operator*= ( Color left,
const Color right 
)
friend

Componentwise color multiplication.

Parameters
[in]leftLeft operand
[in]rightRight operand
Returns
left *= right

◆ operator+

Color operator+ ( const Color left,
const Color right 
)
friend

Componentwise color addition.

Parameters
[in]leftLeft operand
[in]rightRight operand
Returns
left + right

◆ operator+=

Color& operator+= ( Color left,
const Color right 
)
friend

Componentwise color addition.

Parameters
[in]leftLeft operand
[in]rightRight operand
Returns
left += right

◆ operator-

Color operator- ( const Color left,
const Color right 
)
friend

Componentwise color subtraction.

Parameters
[in]leftLeft operand
[in]rightRight operand
Returns
left - right

◆ operator-=

Color& operator-= ( Color left,
const Color right 
)
friend

Componentwise color subtraction.

Parameters
[in]leftLeft operand
[in]rightRight operand
Returns
left -= right

◆ operator/

Color operator/ ( const Color left,
const Color right 
)
friend

Componentwise color division.

Parameters
[in]leftLeft operand
[in]rightRight operand
Returns
left / right

◆ operator/=

Color& operator/= ( Color left,
const Color right 
)
friend

Componentwise color division.

Parameters
[in]leftLeft operand
[in]rightRight operand
Returns
left /= right

◆ operator==

bool operator== ( const Color left,
const Color right 
)
friend

Componentwise color comparison.

Parameters
[in]leftLeft operand
[in]rightRight operand
Returns
True if the respective color components are equal, False if not

Member Data Documentation

◆ a

Uint8 Color::a

Alpha component.

◆ b

Uint8 Color::b

Blue component.

◆ Black

const Color Color::Black
static

Default Color Black (#000000FF)

◆ Blue

const Color Color::Blue
static

Default Color Blue (#0000FFFF)

◆ Cyan

const Color Color::Cyan
static

Default Color Cyan (#00FFFFFF)

◆ g

Uint8 Color::g

Green component.

◆ Green

const Color Color::Green
static

Default Color Green (#00FF00FF)

◆ Magenta

const Color Color::Magenta
static

Default Color Magenta (#FF00FFFF)

◆ r

Uint8 Color::r

Red component.

◆ Red

const Color Color::Red
static

Default Color Red (#FF0000FF)

◆ Transparent

const Color Color::Transparent
static

Default Color Transparent (#00000000)

◆ White

const Color Color::White
static

Default Color White (#FFFFFFFF)

◆ Yellow

const Color Color::Yellow
static

Default Color Yellow (#FFFF00FF)


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