RSTools 3.1.0
Versatile C++20 utility library
Loading...
Searching...
No Matches
RST::Color Namespace Reference

RGBA colors: hex and HSV conversions, blending, interpolation and named colors. More...

Classes

struct  Color
 8-bit RGBA color, packed in 4 bytes. More...
 
struct  Hsv
 HSV color: hue in degrees [0, 360), saturation, value and alpha in [0, 1]. More...
 

Functions

std::ostream & operator<< (std::ostream &out, const Color &color)
 Prints the color as #RRGGBBAA.
 
constexpr Color lerp (const Color &a, const Color &b, float t) noexcept
 Interpolates every component, alpha included, with t clamped to [0, 1].
 
constexpr Color blend (const Color &src, const Color &dst) noexcept
 Draws src over dst, taking the alpha of both into account.
 

Variables

Named colors
constexpr Color Black {0, 0, 0, 255}
 
constexpr Color White {255, 255, 255, 255}
 
constexpr Color Gray {128, 128, 128, 255}
 
constexpr Color Red {255, 0, 0, 255}
 
constexpr Color Green {0, 255, 0, 255}
 
constexpr Color Blue {0, 0, 255, 255}
 
constexpr Color Yellow {255, 255, 0, 255}
 
constexpr Color Magenta {255, 0, 255, 255}
 
constexpr Color Cyan {0, 255, 255, 255}
 
constexpr Color Orange {255, 165, 0, 255}
 
constexpr Color Purple {128, 0, 128, 255}
 
constexpr Color Transparent {0, 0, 0, 0}
 

Detailed Description

RGBA colors: hex and HSV conversions, blending, interpolation and named colors.

Function Documentation

◆ operator<<()

std::ostream & RST::Color::operator<< ( std::ostream &  out,
const Color &  color 
)

Prints the color as #RRGGBBAA.

◆ lerp()

constexpr Color RST::Color::lerp ( const Color &  a,
const Color &  b,
float  t 
)
constexprnoexcept

Interpolates every component, alpha included, with t clamped to [0, 1].

◆ blend()

constexpr Color RST::Color::blend ( const Color &  src,
const Color &  dst 
)
constexprnoexcept

Draws src over dst, taking the alpha of both into account.

Variable Documentation

◆ Black

constexpr Color RST::Color::Black {0, 0, 0, 255}
constexpr

◆ White

constexpr Color RST::Color::White {255, 255, 255, 255}
constexpr

◆ Gray

constexpr Color RST::Color::Gray {128, 128, 128, 255}
constexpr

◆ Red

constexpr Color RST::Color::Red {255, 0, 0, 255}
constexpr

◆ Green

constexpr Color RST::Color::Green {0, 255, 0, 255}
constexpr

◆ Blue

constexpr Color RST::Color::Blue {0, 0, 255, 255}
constexpr

◆ Yellow

constexpr Color RST::Color::Yellow {255, 255, 0, 255}
constexpr

◆ Magenta

constexpr Color RST::Color::Magenta {255, 0, 255, 255}
constexpr

◆ Cyan

constexpr Color RST::Color::Cyan {0, 255, 255, 255}
constexpr

◆ Orange

constexpr Color RST::Color::Orange {255, 165, 0, 255}
constexpr

◆ Purple

constexpr Color RST::Color::Purple {128, 0, 128, 255}
constexpr

◆ Transparent

constexpr Color RST::Color::Transparent {0, 0, 0, 0}
constexpr