Donner
C++20 SVG rendering library
Loading...
Searching...
No Matches
donner::css::RGBA Struct Reference

Represents as 32-bit RGBA color, with each component in the range [0, 255]. More...

#include "donner/css/Color.h"

Public Member Functions

constexpr RGBA ()=default
 Default constructor, initializes to fully opaque white.
 
constexpr RGBA (uint8_t r, uint8_t g, uint8_t b, uint8_t a)
 Constructor, initializes to the given RGBA values.
 
bool operator== (const RGBA &) const =default
 Equality operator.
 
std::string toHexString () const
 Convert the color to a hex string, such as #ff0000.
 

Static Public Member Functions

static constexpr RGBA RGB (uint8_t r, uint8_t g, uint8_t b)
 Constructor, for RGB colors, which are fully opaque.
 

Public Attributes

uint8_t r = 0xFF
 Red component, in the range [0, 255].
 
uint8_t g = 0xFF
 Green component, in the range [0, 255].
 
uint8_t b = 0xFF
 Blue component, in the range [0, 255].
 
uint8_t a = 0xFF
 Alpha component, in the range [0, 255].
 

Friends

std::ostream & operator<< (std::ostream &os, const RGBA &color)
 Ostream output operator.
 

Detailed Description

Represents as 32-bit RGBA color, with each component in the range [0, 255].

To construct, with an alpha channel:

RGBA(r, g, b, a);
uint8_t r
Red component, in the range [0, 255].
Definition Color.h:25
constexpr RGBA()=default
Default constructor, initializes to fully opaque white.
uint8_t a
Alpha component, in the range [0, 255].
Definition Color.h:28
uint8_t g
Green component, in the range [0, 255].
Definition Color.h:26
uint8_t b
Blue component, in the range [0, 255].
Definition Color.h:27

With no alpha:

static constexpr RGBA RGB(uint8_t r, uint8_t g, uint8_t b)
Constructor, for RGB colors, which are fully opaque.
Definition Color.h:37

Member Function Documentation

◆ toHexString()

std::string donner::css::RGBA::toHexString ( ) const

Convert the color to a hex string, such as #ff0000.

Returns
'#rrggbb' if the color is opaque, or '#rrggbbaa' if the color has an alpha channel.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const RGBA & color )
friend

Ostream output operator.

Outputs: rgba(r, g, b, a).

Parameters
osThe output stream.
colorThe color to output.

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