JM9 XRCU Board 0.1.3a
Libraries API Reference
Loading...
Searching...
No Matches
dsgc::Color Class Reference

The common interface for colors used by DSGC. More...

#include <Color.h>

Public Member Functions

 Color ()
 Default constructor which creates a black color with no transparency.
 
 Color (uint8_t red, uint8_t green, uint8_t blue)
 Copy constructor which copies the values from another Color object.
 
 Color (uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha)
 Creates a color with 8-bit RGB values with specified transparency.
 
 Color (uint16_t rgb565)
 Creates a color from the RGB-565 representation.
 
uint8_t getRed () const
 Gets the red component of the color in RGB color model.
 
uint8_t getGreen () const
 Gets the green component of the color in RGB color model.
 
uint8_t getBlue () const
 Gets the blue component of the color in RGB color model.
 
uint8_t getAlpha () const
 Gets the alpha of the color.
 
bool operator== (const Color &rhs) const
 Compares 2 Colors.
 
void setRed (uint8_t red)
 Sets the red component of the color in RGB color model.
 
void setGreen (uint8_t green)
 Sets the green component of the color in RGB color model.
 
void setBlue (uint8_t blue)
 Sets the blue component of the color in RGB color model.
 
void setAlpha (uint8_t alpha)
 Sets the alpha of the color.
 
Coloroperator= (const Color &rhs)
 Copies the values of another Color object to this Color object.
 
 operator uint16_t () const
 Gets the RGB-565 representation of this color.
 
uint16_t getRgb565 () const
 Gets the RGB-565 representation of this color.
 
uint32_t getRgb888 () const
 Gets the RGB-888 representation of this color.
 
uint32_t getArgb8888 () const
 Gets the ARGB-8888 representation of this color.
 
Color getInverse () const
 Gets the inverse of this color.
 
uint8_t getMaxRgbComponent () const
 Gets the value of the largest component among the RGB components.
 
uint8_t getMinRgbComponent () const
 Gets the value of the smallest component among the RGB components.
 
int16_t getHue () const
 Gets the hue in HSI, HSV and HSL models.
 
uint8_t getIntensity () const
 Gets the intensity in HSI model.
 
uint8_t getValue () const
 Gets the value in HSV model.
 
uint8_t getLightness () const
 Gets the lightness in HSL model.
 

Static Public Attributes

static const Color BLACK
 The color black.
 
static const Color RED
 The color red.
 
static const Color GREEN
 The color green.
 
static const Color BLUE
 The color blue.
 
static const Color YELLOW
 The color yellow.
 
static const Color CYAN
 The color cyan.
 
static const Color MAGENTA
 The color magenta.
 
static const Color ORANGE
 The color orange.
 
static const Color BROWN
 The color brown.
 
static const Color PURPLE
 The color purple.
 
static const Color NAVY
 The color navy.
 
static const Color DARK_GREY
 The color dark grey (1/3 brightness).
 
static const Color GREY
 The color grey (1/2 brightness).
 
static const Color LIGHT_GREY
 The color light grey (2/3 brightness).
 
static const Color WHITE
 The color white.
 

Detailed Description

The common interface for colors used by DSGC.

Speaking in experience, the color interface is never standardized across Arduino libraries.

Warning
You should, at your best efforts, reduce the use of this class to DSGC rendering purposes only.
Author
YH Choi @ JM9

Constructor & Destructor Documentation

◆ Color() [1/3]

dsgc::Color::Color ( uint8_t red,
uint8_t green,
uint8_t blue )

Copy constructor which copies the values from another Color object.

Creates an object that represents the same color as another Color object does.

Parameters
refColorThe other Color object whose color to be copied from.

Creates a color with 8-bit RGB values with no transparency.

Parameters
redThe red component of the color [0 : 255].
greenThe green component of the color [0 : 255].
blueThe blue component of the color [0 : 255].

◆ Color() [2/3]

dsgc::Color::Color ( uint8_t red,
uint8_t green,
uint8_t blue,
uint8_t alpha )

Creates a color with 8-bit RGB values with specified transparency.

Parameters
redThe red component of the color [0 : 255].
greenThe green component of the color [0 : 255].
blueThe blue component of the color [0 : 255].
alphaThe alpha (i.e. inverse transparency) of the color [0 : 255].

◆ Color() [3/3]

dsgc::Color::Color ( uint16_t rgb565)

Creates a color from the RGB-565 representation.

Parameters
rgb565The RGB-565 value which represents the color.

Member Function Documentation

◆ getAlpha()

uint8_t dsgc::Color::getAlpha ( ) const

Gets the alpha of the color.

The alpha of a color is the inverse of its transparency. The smaller the alpha, the more transparent a color is.

Returns
The 8-bit alpha of the color [0 : 255].

◆ getArgb8888()

uint32_t dsgc::Color::getArgb8888 ( ) const

Gets the ARGB-8888 representation of this color.

8 bits of alpha, 8 bits of red, 8 bits of green, 8 bits of blue.

Returns
The ARGB-8888 representation of this color [AAAAAAAA RRRRRRRR GGGGGGGG BBBBBBBB].

◆ getBlue()

uint8_t dsgc::Color::getBlue ( ) const

Gets the blue component of the color in RGB color model.

Returns
The 8-bit blue component of the color in RGB color model [0 : 255].

◆ getGreen()

uint8_t dsgc::Color::getGreen ( ) const

Gets the green component of the color in RGB color model.

Returns
The 8-bit green component of the color in RGB color model [0 : 255].

◆ getHue()

int16_t dsgc::Color::getHue ( ) const

Gets the hue in HSI, HSV and HSL models.

Returns
The hue in HSI, HSV and HSL models [0 : 360].

◆ getIntensity()

uint8_t dsgc::Color::getIntensity ( ) const

Gets the intensity in HSI model.

Returns
The intensity in HSI model [0 : 255].

◆ getInverse()

dsgc::Color dsgc::Color::getInverse ( ) const

Gets the inverse of this color.

Returns
The inverse of this color (255 - red, 255 - green, 255 - blue).

◆ getLightness()

uint8_t dsgc::Color::getLightness ( ) const

Gets the lightness in HSL model.

Returns
The lightness in HSL model [0 : 255].

◆ getMaxRgbComponent()

uint8_t dsgc::Color::getMaxRgbComponent ( ) const

Gets the value of the largest component among the RGB components.

Returns
The value of the largest component among the RGB components [0 : 255].

◆ getMinRgbComponent()

uint8_t dsgc::Color::getMinRgbComponent ( ) const

Gets the value of the smallest component among the RGB components.

Returns
The value of the smallest component among the RGB components [0 : 255].

◆ getRed()

uint8_t dsgc::Color::getRed ( ) const

Gets the red component of the color in RGB color model.

Returns
The 8-bit red component of the color in RGB color model [0 : 255].

◆ getRgb565()

uint16_t dsgc::Color::getRgb565 ( ) const

Gets the RGB-565 representation of this color.

5 bits of red, 6 bits of green, 5 bits of blue.

Returns
The RGB-565 representation of this color [RRRRRGGG GGGBBBBB].

◆ getRgb888()

uint32_t dsgc::Color::getRgb888 ( ) const

Gets the RGB-888 representation of this color.

8 bits of red, 8 bits of green, 8 bits of blue.

Returns
The RGB-888 representation of this color [00000000 RRRRRRRR GGGGGGGG BBBBBBBB].

◆ getValue()

uint8_t dsgc::Color::getValue ( ) const

Gets the value in HSV model.

Returns
The value in HSV model [0 : 255].

◆ operator uint16_t()

dsgc::Color::operator uint16_t ( ) const

Gets the RGB-565 representation of this color.

5 bits of red, 6 bits of green, 5 bits of blue.

Returns
The RGB-565 representation of this color [RRRRRGGG GGGBBBBB].
See also
getRgb565()

◆ operator=()

dsgc::Color & dsgc::Color::operator= ( const Color & rhs)

Copies the values of another Color object to this Color object.

Parameters
rhsThe other Color object whose color to be copied from.
Returns
This Color object.

◆ operator==()

bool dsgc::Color::operator== ( const Color & rhs) const

Compares 2 Colors.

Returns
true if 2 colors are completely the same, false otherwise.

◆ setAlpha()

void dsgc::Color::setAlpha ( uint8_t alpha)

Sets the alpha of the color.

The alpha of a color is the inverse of its transparency. The smaller the alpha, the more transparent a color is.

Parameters
alphaThe 8-bit alpha of the color [0 : 255].

◆ setBlue()

void dsgc::Color::setBlue ( uint8_t blue)

Sets the blue component of the color in RGB color model.

Parameters
blueThe 8-bit blue component of the color in RGB color model [0 : 255].

◆ setGreen()

void dsgc::Color::setGreen ( uint8_t green)

Sets the green component of the color in RGB color model.

Parameters
greenThe 8-bit green component of the color in RGB color model [0 : 255].

◆ setRed()

void dsgc::Color::setRed ( uint8_t red)

Sets the red component of the color in RGB color model.

Parameters
redThe 8-bit red component of the color in RGB color model [0 : 255].

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