Avara3D 0.2.0
C++ API reference
a3d::Color Class Reference

Represents a normalized RGBA color. More...

#include <a3d/Color.h>

Public Member Functions

 Color ()
 Creates opaque white. More...
 
 Color (const math::vec3 &rgb)
 Creates an opaque color from floating-point RGB components. More...
 
 Color (float r, float g, float b)
 Creates an opaque color from floating-point RGB components. More...
 
 Color (const math::vec4 &rgba)
 Creates a color from floating-point RGBA components. More...
 
 Color (float r, float g, float b, float a)
 Creates a color from floating-point RGBA components. More...
 
 Color (const math::u8vec3 &irgb)
 Creates an opaque color from 8-bit RGB components. More...
 
 Color (const math::u8vec4 &irgba)
 Creates a color from 8-bit RGBA components. More...
 
 Color (float white)
 Creates an opaque grayscale color with all RGB components set to white. More...
 
 Color (uint32_t color)
 Creates a color from a packed 0xRRGGBBAA value. More...
 
 Color (const std::string &hexString)
 Creates a color from hexadecimal RGB or RGBA text. More...
 
float r () const
 Returns the floating-point red component. More...
 
float g () const
 Returns the floating-point green component. More...
 
float b () const
 Returns the floating-point blue component. More...
 
float a () const
 Returns the floating-point alpha component. More...
 
uint8_t u8r () const
 Returns the red component converted to 8-bit form. More...
 
uint8_t u8g () const
 Returns the green component converted to 8-bit form. More...
 
uint8_t u8b () const
 Returns the blue component converted to 8-bit form. More...
 
uint8_t u8a () const
 Returns the alpha component converted to 8-bit form. More...
 
math::vec3 rgb () const
 Returns the floating-point RGB components. More...
 
math::vec4 rgba () const
 Returns the floating-point RGBA components. More...
 
math::u8vec3 u8rgb () const
 Returns the RGB components converted to 8-bit form. More...
 
math::u8vec4 u8rgba () const
 Returns the RGBA components converted to 8-bit form. More...
 

Static Public Member Functions

static Color Black ()
 Returns opaque black. More...
 
static Color DarkGray ()
 Returns opaque dark gray. More...
 
static Color Gray ()
 Returns opaque gray. More...
 
static Color LightGray ()
 Returns opaque light gray. More...
 
static Color White ()
 Returns opaque white. More...
 
static Color Maroon ()
 Returns opaque maroon. More...
 
static Color Red ()
 Returns opaque red. More...
 
static Color Orange ()
 Returns opaque orange. More...
 
static Color Yellow ()
 Returns opaque yellow. More...
 
static Color Olive ()
 Returns opaque olive. More...
 
static Color Lime ()
 Returns opaque lime. More...
 
static Color Green ()
 Returns opaque green. More...
 
static Color Cyan ()
 Returns opaque cyan. More...
 
static Color Blue ()
 Returns opaque blue. More...
 
static Color Navy ()
 Returns opaque navy. More...
 
static Color Teal ()
 Returns opaque teal. More...
 
static Color Magenta ()
 Returns opaque magenta. More...
 
static Color Purple ()
 Returns opaque purple. More...
 
static Color Brown ()
 Returns opaque brown. More...
 
static Color Random ()
 Returns an opaque color with independently randomized 8-bit RGB channels. More...
 

Detailed Description

Represents a normalized RGBA color.

Components are stored as floating-point values in the range [0, 1]. Floating-point inputs outside this range are clamped. Eight-bit accessors scale the stored components to [0, 255] and round to the nearest integer.

Definition at line 27 of file Color.h.

Constructor & Destructor Documentation

◆ Color() [1/10]

a3d::Color::Color ( )

Creates opaque white.

◆ Color() [2/10]

a3d::Color::Color ( const math::vec3 rgb)
explicit

Creates an opaque color from floating-point RGB components.

◆ Color() [3/10]

a3d::Color::Color ( float  r,
float  g,
float  b 
)

Creates an opaque color from floating-point RGB components.

◆ Color() [4/10]

a3d::Color::Color ( const math::vec4 rgba)
explicit

Creates a color from floating-point RGBA components.

◆ Color() [5/10]

a3d::Color::Color ( float  r,
float  g,
float  b,
float  a 
)

Creates a color from floating-point RGBA components.

◆ Color() [6/10]

a3d::Color::Color ( const math::u8vec3 irgb)
explicit

Creates an opaque color from 8-bit RGB components.

◆ Color() [7/10]

a3d::Color::Color ( const math::u8vec4 irgba)
explicit

Creates a color from 8-bit RGBA components.

◆ Color() [8/10]

a3d::Color::Color ( float  white)
explicit

Creates an opaque grayscale color with all RGB components set to white.

◆ Color() [9/10]

a3d::Color::Color ( uint32_t  color)
explicit

Creates a color from a packed 0xRRGGBBAA value.

◆ Color() [10/10]

a3d::Color::Color ( const std::string &  hexString)
explicit

Creates a color from hexadecimal RGB or RGBA text.

Supported forms are RRGGBB, #RRGGBB, RRGGBBAA, and #RRGGBBAA.

Member Function Documentation

◆ a()

float a3d::Color::a ( ) const

Returns the floating-point alpha component.

◆ b()

float a3d::Color::b ( ) const

Returns the floating-point blue component.

◆ Black()

static Color a3d::Color::Black ( )
static

Returns opaque black.

◆ Blue()

static Color a3d::Color::Blue ( )
static

Returns opaque blue.

◆ Brown()

static Color a3d::Color::Brown ( )
static

Returns opaque brown.

◆ Cyan()

static Color a3d::Color::Cyan ( )
static

Returns opaque cyan.

◆ DarkGray()

static Color a3d::Color::DarkGray ( )
static

Returns opaque dark gray.

◆ g()

float a3d::Color::g ( ) const

Returns the floating-point green component.

◆ Gray()

static Color a3d::Color::Gray ( )
static

Returns opaque gray.

◆ Green()

static Color a3d::Color::Green ( )
static

Returns opaque green.

◆ LightGray()

static Color a3d::Color::LightGray ( )
static

Returns opaque light gray.

◆ Lime()

static Color a3d::Color::Lime ( )
static

Returns opaque lime.

◆ Magenta()

static Color a3d::Color::Magenta ( )
static

Returns opaque magenta.

◆ Maroon()

static Color a3d::Color::Maroon ( )
static

Returns opaque maroon.

◆ Navy()

static Color a3d::Color::Navy ( )
static

Returns opaque navy.

◆ Olive()

static Color a3d::Color::Olive ( )
static

Returns opaque olive.

◆ Orange()

static Color a3d::Color::Orange ( )
static

Returns opaque orange.

◆ Purple()

static Color a3d::Color::Purple ( )
static

Returns opaque purple.

◆ r()

float a3d::Color::r ( ) const

Returns the floating-point red component.

◆ Random()

static Color a3d::Color::Random ( )
static

Returns an opaque color with independently randomized 8-bit RGB channels.

◆ Red()

static Color a3d::Color::Red ( )
static

Returns opaque red.

◆ rgb()

math::vec3 a3d::Color::rgb ( ) const

Returns the floating-point RGB components.

◆ rgba()

math::vec4 a3d::Color::rgba ( ) const

Returns the floating-point RGBA components.

◆ Teal()

static Color a3d::Color::Teal ( )
static

Returns opaque teal.

◆ u8a()

uint8_t a3d::Color::u8a ( ) const

Returns the alpha component converted to 8-bit form.

◆ u8b()

uint8_t a3d::Color::u8b ( ) const

Returns the blue component converted to 8-bit form.

◆ u8g()

uint8_t a3d::Color::u8g ( ) const

Returns the green component converted to 8-bit form.

◆ u8r()

uint8_t a3d::Color::u8r ( ) const

Returns the red component converted to 8-bit form.

◆ u8rgb()

math::u8vec3 a3d::Color::u8rgb ( ) const

Returns the RGB components converted to 8-bit form.

◆ u8rgba()

math::u8vec4 a3d::Color::u8rgba ( ) const

Returns the RGBA components converted to 8-bit form.

◆ White()

static Color a3d::Color::White ( )
static

Returns opaque white.

◆ Yellow()

static Color a3d::Color::Yellow ( )
static

Returns opaque yellow.


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