TurtleBrains  0.2.1
High quality, portable, C++ API for native application and game development.
TurtleBrains::Graphics::Color Class Reference

#include <tb_color.h>

Public Member Functions

 Color (void)
 
 Color (const tbCore::uint32 &colorARGB)
 
 Color (const float clampedAlpha, const float clampedRed, const float clampedGreen, const float clampedBlue)
 
void SetColor (const tbCore::uint32 &colorARGB)
 
void SetColor (const float clampedAlpha, const float clampedRed, const float clampedGreen, const float clampedBlue)
 
void SetColor (const float clampedTween, const Color &startColor, const Color &finalColor)
 
tbCore::uint32 GetColorARGB (void) const
 
tbCore::uint32 GetColorABGR (void) const
 
tbCore::uint8 GetAlphaByte (void) const
 
tbCore::uint8 GetRedByte (void) const
 
tbCore::uint8 GetGreenByte (void) const
 
tbCore::uint8 GetBlueByte (void) const
 
float GetAlpha (void) const
 
float GetRed (void) const
 
float GetGreen (void) const
 
float GetBlue (void) const
 

Static Public Attributes

static const Color kWhite
 
static const Color kBlack
 
static const Color kRed
 
static const Color kGreen
 
static const Color kBlue
 

Detailed Description

Stores a 24 bit color with 8 bit alpha and provides an interface to set the color through a variety of inputs either floating point channels or unsigned byte channels.

Constructor & Destructor Documentation

TurtleBrains::Graphics::Color::Color ( void  )

Constructs a default Color object with all channels fully on including alpha, resulting in white.

TurtleBrains::Graphics::Color::Color ( const tbCore::uint32 colorARGB)
explicit

Constructs a Color object from the 32bit color value with each channel as a byte in the order Alpha, Red, Green, Blue.

TurtleBrains::Graphics::Color::Color ( const float  clampedAlpha,
const float  clampedRed,
const float  clampedGreen,
const float  clampedBlue 
)

Construcs a Color object based on floats for each of the channels. Each channel should be clamped in the range of 0.0f to 1.0f, although that will happen automatically when setting a color in this function.

Parameters
clampedAlphaThe amount of alpha to use for the color from transparent 0.0f to opaque 1.0f.
clampedRedThe amount of red to use for the color from none 0.0f to full 1.0f.
clampedGreenThe amount of green to use for the color from none 0.0f to full 1.0f.
clampedBlueThe amount of blue to use for the color from none 0.0f to full 1.0f.
Note
This does not normalize the color if any of the channels were out of bounds, it simply clamps them.

Member Function Documentation

float TurtleBrains::Graphics::Color::GetAlpha ( void  ) const

Returns the clamped value of the alpha channel from transparent at 0.0f to 1.0f fully opaque.

tbCore::uint8 TurtleBrains::Graphics::Color::GetAlphaByte ( void  ) const

Returns the byte value of the alpha channel from transparent at 0 to 255 fully opaque.

float TurtleBrains::Graphics::Color::GetBlue ( void  ) const

Returns the clamped value of the blue channel from 0.0f to 1.0f representing full blue.

tbCore::uint8 TurtleBrains::Graphics::Color::GetBlueByte ( void  ) const

Returns the byte value of the blue channel from 0 to 255 for full blue.

tbCore::uint32 TurtleBrains::Graphics::Color::GetColorABGR ( void  ) const

Computes and returns the 32bit color with each channel as a byte in the order Alpha, Blue, Green, Red.

tbCore::uint32 TurtleBrains::Graphics::Color::GetColorARGB ( void  ) const

Returns the 32bit color value with each channel as a byte in the order Alpha, Red, Green, Blue.

float TurtleBrains::Graphics::Color::GetGreen ( void  ) const

Returns the clamped value of the green channel from 0.0f to 1.0f representing full green.

tbCore::uint8 TurtleBrains::Graphics::Color::GetGreenByte ( void  ) const

Returns the byte value of the green channel from 0 to 255 for full green.

float TurtleBrains::Graphics::Color::GetRed ( void  ) const

Returns the clamped value of the red channel from 0.0f to 1.0f representing full red.

tbCore::uint8 TurtleBrains::Graphics::Color::GetRedByte ( void  ) const

Returns the byte value of the red channel from 0 to 255 for full red.

void TurtleBrains::Graphics::Color::SetColor ( const tbCore::uint32 colorARGB)

Sets the color value based on the 32bit value with each channel as a byte in the order Alpha, Red, Green, Blue.

void TurtleBrains::Graphics::Color::SetColor ( const float  clampedAlpha,
const float  clampedRed,
const float  clampedGreen,
const float  clampedBlue 
)

Set the color value based on floats for each of the channels. Each channel should be clamped in the range of 0.0f to 1.0f, although that will happen automatically when setting a color in this function.

Parameters
clampedAlphaThe amount of alpha to use for the color from transparent 0.0f to opaque 1.0f.
clampedRedThe amount of red to use for the color from none 0.0f to full 1.0f.
clampedGreenThe amount of green to use for the color from none 0.0f to full 1.0f.
clampedBlueThe amount of blue to use for the color from none 0.0f to full 1.0f.
Note
This does not normalize the color if any of the channels were out of bounds, it simply clamps them.
void TurtleBrains::Graphics::Color::SetColor ( const float  clampedTween,
const Color startColor,
const Color finalColor 
)

Sets a color to be a color in between a startColor and finalColor by linearly interpolating between the two values.

Parameters
clampedTweenThe amount of interpolation to be applied from 0.0f to be startColor and 1.0f to be the finalColor. Any value in between will use linear interpolatation, so 0.5f is the color halfway between the startColor and finalColor.
startColorA color the start from for the in-between linear interpolation.
finalColorA color at the end of the in-between linear interpolation.

Member Data Documentation

const Color TurtleBrains::Graphics::Color::kBlack
static

Fully opaque color representing black, ARGB: 0xFF000000.

const Color TurtleBrains::Graphics::Color::kBlue
static

Fully opaque color representing primary blue, ARGB: 0xFF0000FF.

const Color TurtleBrains::Graphics::Color::kGreen
static

Fully opaque color representing primary green, ARGB: 0xFF00FF00..

const Color TurtleBrains::Graphics::Color::kRed
static

Fully opaque color representing primary red, ARGB: 0xFFFF0000.

const Color TurtleBrains::Graphics::Color::kWhite
static

Fully opaque color representing white, ARGB: 0xFFFFFFFF.