ASW Lib
A.D.S. Games SDL Wrapper Library. A library targeted at Allegro4 users who want to switch to SDL3 and use modern c++.
Loading...
Searching...
No Matches
asw::Color Struct Reference

RGBA color struct with 8-bit channels. More...

#include <color.h>

Public Member Functions

 Color ()
 Construct a default Color (black, fully opaque).
 
 Color (uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
 Construct a Color from RGBA values.
 
SDL_Color toSDLColor () const
 Convert to an SDL_Color.
 

Static Public Member Functions

static Color fromFloat (float r, float g, float b, float a=1.0F)
 From float RGBA values (0.0-1.0) to Color.
 
static Color fromSDLColor (const SDL_Color &sdlColor)
 Convert from an SDL_Color to a Color.
 
static Color fromHex (const std::string &hex)
 From a hex string (e.g. "#RRGGBBAA") to a Color.
 

Public Attributes

uint8_t r
 
uint8_t g
 
uint8_t b
 
uint8_t a
 

Detailed Description

RGBA color struct with 8-bit channels.

Definition at line 11 of file color.h.

Constructor & Destructor Documentation

◆ Color() [1/2]

asw::Color::Color ( )
inline

Construct a default Color (black, fully opaque).

Definition at line 15 of file color.h.

◆ Color() [2/2]

asw::Color::Color ( uint8_t r,
uint8_t g,
uint8_t b,
uint8_t a = 255 )
inline

Construct a Color from RGBA values.

Parameters
rRed channel (0-255).
gGreen channel (0-255).
bBlue channel (0-255).
aAlpha channel (0-255, default 255).

Definition at line 24 of file color.h.

Member Function Documentation

◆ fromFloat()

static Color asw::Color::fromFloat ( float r,
float g,
float b,
float a = 1.0F )
inlinestatic

From float RGBA values (0.0-1.0) to Color.

Parameters
rRed channel (0.0-1.0).
gGreen channel (0.0-1.0).
bBlue channel (0.0-1.0).
aAlpha channel (0.0-1.0, default 1.0).
Returns
The equivalent Color.

Definition at line 41 of file color.h.

◆ fromHex()

static Color asw::Color::fromHex ( const std::string & hex)
inlinestatic

From a hex string (e.g. "#RRGGBBAA") to a Color.

Parameters
hexThe hex string to convert.
Returns
The equivalent Color.

Definition at line 58 of file color.h.

◆ fromSDLColor()

static Color asw::Color::fromSDLColor ( const SDL_Color & sdlColor)
inlinestatic

Convert from an SDL_Color to a Color.

Parameters
sdlColorThe SDL_Color to convert.
Returns
The equivalent Color.

Definition at line 49 of file color.h.

◆ toSDLColor()

SDL_Color asw::Color::toSDLColor ( ) const
inline

Convert to an SDL_Color.

Returns
The equivalent SDL_Color.

Definition at line 31 of file color.h.

Member Data Documentation

◆ a

uint8_t asw::Color::a

Definition at line 12 of file color.h.

◆ b

uint8_t asw::Color::b

Definition at line 12 of file color.h.

◆ g

uint8_t asw::Color::g

Definition at line 12 of file color.h.

◆ r

uint8_t asw::Color::r

Definition at line 12 of file color.h.


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