That Terminal
A terminal emulator designed for video making purposes.
color.hh File Reference

Defines conversions between different color formats and parsing colors defined in strings. More...

#include <array>
#include <string>
#include <algorithm>
Include dependency graph for color.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

unsigned ParseColorName (std::string_view s)
 
unsigned ParseColorName (std::u32string_view s)
 
constexpr std::array< unsigned, 3 > Unpack (unsigned rgb)
 
constexpr unsigned Repack (std::array< unsigned, 3 > rgb)
 
constexpr unsigned Mix (unsigned color1, unsigned color2, unsigned fac1, unsigned fac2, unsigned sum)
 
unsigned cmy2rgb (unsigned cmy)
 
unsigned cmyk2rgb (unsigned cmyk)
 

Detailed Description

Defines conversions between different color formats and parsing colors defined in strings.

Function Documentation

◆ cmy2rgb()

unsigned cmy2rgb ( unsigned  cmy)
inline

cmy2rgb() Converts CMY into RGB

◆ cmyk2rgb()

unsigned cmyk2rgb ( unsigned  cmyk)
inline

cmyk2rgb() Converts CMYK into RGB

◆ Mix()

constexpr unsigned Mix ( unsigned  color1,
unsigned  color2,
unsigned  fac1,
unsigned  fac2,
unsigned  sum 
)
inlineconstexpr

Mix() mixes two colors such that the resulting color is (color1*fac1 + color2*fac2) / sum.

◆ ParseColorName()

unsigned ParseColorName ( std::string_view  s)

ParseColorName() parses the given string and returns a corresponding RGB color as a 24-bit integer.

Recognized formats are: #RGB (each color channel is 4-bit hexadecimal number; range: 0-F) #RRGGBB (each color channel is 8-bit hexadecimal number; range: 00-FF) rgb:R/G/B (each color channel is 4-bit hexadecimal number; range: 0-F) rgbi:1/1/1 (each color channel is a decimal floating point value; range: 0-1) gold (color names recognized by X11 are recognized, case sensitive) Anything else produces undefined results.

◆ Repack()

constexpr unsigned Repack ( std::array< unsigned, 3 >  rgb)
inlineconstexpr

Repack() is the inverse of Unpack().

Packs an RGB color represented in three color channels into a single 24-bit integer.

◆ Unpack()

constexpr std::array<unsigned,3> Unpack ( unsigned  rgb)
inlineconstexpr

Unpack() unpacks an RGB color in a 24-bit integer to its constituent r,g,b components.