Blamite Game Engine - blam!  00272.10.26.20.0001.blamite
The core library for the Blamite Game Engine.
BlamColor Class Reference

Structure representing a color. More...

#include <globals.h>

Public Member Functions

 BlamColor ()
 
 BlamColor (short _r, short _g, short _b)
 
 BlamColor (short _r, short _g, short _b, short _a)
 
std::string ToString ()
 Converts the color value to a string. More...
 
float GetRedAsFloat ()
 Gets the color's red value as a float, between 0 and 1. More...
 
float GetGreenAsFloat ()
 Gets the color's red value as a float, between 0 and 1. More...
 
float GetBlueAsFloat ()
 Gets the color's red value as a float, between 0 and 1. More...
 
float GetAlphaAsFloat ()
 Gets the color's red value as a float, between 0 and 1. More...
 
std::string ToString (std::string format)
 Converts the color value to a string in the specified format. More...
 
std::string ToStringForCSS ()
 Converts the color to a string that can be used with CSS. More...
 
bool FromString (std::string string)
 Attempts to set color information from a string. More...
 

Public Attributes

short r = 255
 The Red value of the color. More...
 
short g = 255
 The Green value of the color. More...
 
short b = 255
 The Blue value of the color. More...
 
short a = 255
 The Alpha value of the color. More...
 

Detailed Description

Structure representing a color.

Used for a variety of purposes in the engine.

Color values range from 0 to 255. To convert to a float-based color, use #Blam::Colors::D2DColorFromBlamColor.

Constructor & Destructor Documentation

◆ BlamColor() [1/3]

BlamColor::BlamColor ( )
inline

◆ BlamColor() [2/3]

BlamColor::BlamColor ( short  _r,
short  _g,
short  _b 
)
inline

◆ BlamColor() [3/3]

BlamColor::BlamColor ( short  _r,
short  _g,
short  _b,
short  _a 
)
inline

Member Function Documentation

◆ FromString()

bool BlamColor::FromString ( std::string  string)
inline

Attempts to set color information from a string.

String should be in either r,g,b or r,g,b,a format - the same format as is returned when using BlamColor::ToString();

Parameters
string- The string to try to convert to a color.
Returns
true if the color was converted successfully, false if the conversion failed.

◆ GetAlphaAsFloat()

float BlamColor::GetAlphaAsFloat ( )
inline

Gets the color's red value as a float, between 0 and 1.

Returns
The color's red value, converted to a float.

◆ GetBlueAsFloat()

float BlamColor::GetBlueAsFloat ( )
inline

Gets the color's red value as a float, between 0 and 1.

Returns
The color's red value, converted to a float.

◆ GetGreenAsFloat()

float BlamColor::GetGreenAsFloat ( )
inline

Gets the color's red value as a float, between 0 and 1.

Returns
The color's red value, converted to a float.

◆ GetRedAsFloat()

float BlamColor::GetRedAsFloat ( )
inline

Gets the color's red value as a float, between 0 and 1.

Returns
The color's red value, converted to a float.

◆ ToString() [1/2]

std::string BlamColor::ToString ( )
inline

Converts the color value to a string.

Returns
The color information in r,g,b,a format.

◆ ToString() [2/2]

std::string BlamColor::ToString ( std::string  format)
inline

Converts the color value to a string in the specified format.

The provided string can contain the following keys which will be replaced with the color values:

  • {r} - Red
  • {g} - Green
  • {b} - Blue
  • {a} - Alpha

Additionally, you can have a float representation of the value (instead of 0-255) by adding >f inside a color placeholder. Example: {r} of 255 would be 1.0 with {r>f}.

Parameters
format- The string containing any color placeholders to be replaced.
Returns
The string with the color placeholders replaced.

◆ ToStringForCSS()

std::string BlamColor::ToStringForCSS ( )
inline

Converts the color to a string that can be used with CSS.

Returns
The color represented as a string, in the following format: rgba(r,g,b,a)

Member Data Documentation

◆ a

short BlamColor::a = 255

The Alpha value of the color.

◆ b

short BlamColor::b = 255

The Blue value of the color.

◆ g

short BlamColor::g = 255

The Green value of the color.

◆ r

short BlamColor::r = 255

The Red value of the color.


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