Color
The Color struct represents a four-component color with red, green, blue, and alpha channels, offering a flexible and efficient interface for defining, manipulating, and converting colors across different formats. It supports various constructors, including grayscale, HTML strings, RGBAu8 integers, HSV values, and temperature-based inputs. The struct provides utilities for setting and retrieving color data, checking color properties, and performing color arithmetic operations. It includes functions to convert between gamma and linear color spaces, as well as sRGB and linear formats, and supports multiple packed RGBA formats.
#include <math/TellusimColor.h>
Constructors
Color()
explicit Color(const char *src)
explicit Color(uint32_t color)
explicit Color(float32_t c)
Color(float32_t l, float32_t a)
Color(const Color &c, float32_t a)
explicit Color(const float32_t *c, uint32_t size = Size)
Color(uint32_t r, uint32_t g, uint32_t b, uint32_t a = 255)
Color(float32_t r, float32_t g, float32_t b, float32_t a = 1.0f)
Methods
Update color data.
void set(const Color &c, float32_t A)
void set(float32_t R, float32_t G, float32_t B, float32_t A)
void set(const float32_t *c, uint32_t size = Size)
void get(float32_t *c, uint32_t size = Size) const
Check color.
bool isValid() const
operator bool() const
Color parameters.
bool isBlack() const
bool isWhite() const
bool isTransparent() const
bool isOpaque() const
Color operators.
Color &operator*=(float32_t l)
Color &operator/=(float32_t l)
Color &operator+=(float32_t l)
Color &operator-=(float32_t l)
Color &operator*=(const Color &c)
Color &operator/=(const Color &c)
Color &operator+=(const Color &c)
Color &operator-=(const Color &c)
Gamma format.
void gammaToLinear(float32_t *v) const
void linearToGamma(float32_t *v) const
Color gammaToLinear() const
Color linearToGamma() const
SRGB format.
void sRGBtoLinear(float32_t *v) const
void linearToSRGB(float32_t *v) const
Color sRGBtoLinear() const
Color linearToSRGB() const
RGBAu8 color components.
void setRGBAu8(uint32_t R, uint32_t G, uint32_t B, uint32_t A)
uint8_t getRu8() const
uint8_t getGu8() const
uint8_t getBu8() const
uint8_t getAu8() const
RGBAu8 color format.
void setRGBAu8(uint32_t color)
void setBGRAu8(uint32_t color)
void setABGRu8(uint32_t color)
uint32_t getRGBAu8() const
uint32_t getBGRAu8() const
uint32_t getABGRu8() const
HTML color format.
bool setHTML(const char *src)
static Color html(const char *src)
HSV color format.
bool setHSV(float32_t h, float32_t s, float32_t v)
bool getHSV(float32_t &h, float32_t &s, float32_t &v) const
static Color hsv(float32_t h, float32_t s, float32_t v)
Temperature in K.
void setTemperature(float32_t t)
static Color temperature(float32_t t)
Color data.
const float32_t &operator[](uint32_t index) const
float32_t &operator[](uint32_t index)
Operators
Color to scalar operators.
Color operator*(const Color &c, float32_t l)
Color operator/(const Color &c, float32_t l)
Color operator+(const Color &c, float32_t l)
Color operator-(const Color &c, float32_t l)
Color to color operators.
Color operator*(const Color &c0, const Color &c1)
Color operator/(const Color &c0, const Color &c1)
Color operator+(const Color &c0, const Color &c1)
Color operator-(const Color &c0, const Color &c1)
Functions
Min/max functions.
Color min(const Color &c0, const Color &c1)
Color max(const Color &c0, const Color &c1)
Range functions.
Color saturate(const Color &c)
Color clamp(const Color &c, float32_t c0, float32_t c1)
Color clamp(const Color &c, const Color &c0, const Color &c1)
Color normalize(const Color &c)
Color lerp(const Color &c0, const Color &c1, float32_t k)
Enums
Name | Value |
---|---|
Size | 4 |
Variables
Type | Name | Description |
---|---|---|
static const Color | zero | Default colors. |
static const Color | black | |
static const Color | white | |
static const Color | gray | |
static const Color | red | Rgb colors. |
static const Color | yellow | |
static const Color | green | |
static const Color | cyan | |
static const Color | blue | |
static const Color | magenta |