![]() |
Gamedev Framework (gf) 1.2.0
A C++17 framework for 2D games
|
Predefined colors and utilities. More...
#include <gf/Color.h>
Static Public Member Functions | |
static constexpr Color4< T > | Opaque (T value=T(0.5)) |
Opaque predefined color. More... | |
static constexpr Color4< T > | Gray (T value=T(0.5)) |
Gray predefined color. More... | |
static constexpr Color4< T > | lighter (Color4< T > color, T percent=T(0.5)) |
Compute a lighter color. More... | |
static constexpr Color4< T > | darker (Color4< T > color, T percent=T(0.5)) |
Compute a darker color. More... | |
static constexpr Color4< T > | fromRgb (T r, T g, T b) |
Get an opaque color from 3 RGB floats in \( [0, 1] \). More... | |
static constexpr Color4< T > | fromRgba32 (uint8_t r, uint8_t g, uint8_t b, uint8_t a=255) |
Get a color from 4 8-bit channels. More... | |
static constexpr Color4< T > | fromRgba32 (uint32_t color) |
Get a color from 32-bit value. More... | |
static constexpr Color4< T > | fromRgba32 (Color4u color) |
Get a color from a 32-bit color. More... | |
static constexpr Color4u | toRgba32 (Color4< T > color) |
Convert a color to a 32-bit color. More... | |
Static Public Attributes | |
static constexpr Color4< T > | Black {T(0), T(0), T(0), T(1)} |
Black predefined color. More... | |
static constexpr Color4< T > | White {T(1), T(1), T(1), T(1)} |
White predefined color. More... | |
static constexpr Color4< T > | Red {T(1), T(0), T(0), T(1)} |
Red predefined color. More... | |
static constexpr Color4< T > | Green {T(0), T(1), T(0), T(1)} |
Green predefined color. More... | |
static constexpr Color4< T > | Blue {T(0), T(0), T(1), T(1)} |
Blue predefined color. More... | |
static constexpr Color4< T > | Cyan {T(0), T(1), T(1), T(1)} |
Cyan predefined color. More... | |
static constexpr Color4< T > | Magenta {T(1), T(0), T(1), T(1)} |
Magenta predefined color. More... | |
static constexpr Color4< T > | Yellow {T(1), T(1), T(0), T(1)} |
Yellow predefined color. More... | |
static constexpr Color4< T > | Transparent {T(0), T(0), T(0), T(0)} |
Transparent (black) predefined color. More... | |
static constexpr Color4< T > | Orange {T(1), T(0.5), T(0), T(1)} |
Orange predefined color. More... | |
static constexpr Color4< T > | Rose {T(1), T(0), T(0.5), T(1)} |
Rose predefined color. More... | |
static constexpr Color4< T > | Chartreuse {T(0.5), T(1), T(0), T(1)} |
Chartreuse predefined color. More... | |
static constexpr Color4< T > | Spring {T(0), T(1), T(0.5), T(1)} |
Spring (green) predefined color. More... | |
static constexpr Color4< T > | Violet {T(0.5), T(0), T(1), T(1)} |
Violet predefined color. More... | |
static constexpr Color4< T > | Azure {T(0), T(0.5), T(1), T(1)} |
Azure predefined color. More... | |
Predefined colors and utilities.
This class does not contain anything but predefined colors. All the primary, secondary and tertiary colors are defined by their usual names.
If you want to define a color, you should use gf::Color4f.
If you want to use the functions of this class, you can use:
float
double
|
inlinestaticconstexpr |
Compute a darker color.
This function takes a color and gives a darker color based on a percentage. If this percentage is 0, the same color is returned. If this percentage is 1, the black color is returned.
color | The color |
percent | The percentage, must be in \( [0, 1] \) |
|
inlinestaticconstexpr |
Get an opaque color from 3 RGB floats in \( [0, 1] \).
r | The red channel |
g | The green channel |
b | The blue channel |
|
inlinestaticconstexpr |
Get a color from a 32-bit color.
color | A 32-bit color |
|
inlinestaticconstexpr |
Get a color from 32-bit value.
color | The 32-bit color |
|
inlinestaticconstexpr |
Get a color from 4 8-bit channels.
r | The red channel |
g | The green channel |
b | The blue channel |
a | The alpha channel |
|
inlinestaticconstexpr |
Gray predefined color.
value | The gray value |
|
inlinestaticconstexpr |
Compute a lighter color.
This function takes a color and gives a lighter color based on a percentage. If this percentage is 0, the same color is returned. If this percentage is 1, the white color is returned.
color | The color |
percent | The percentage, must be in \( [0, 1] \) |
|
inlinestaticconstexpr |
Opaque predefined color.
value | The opacity value |
|
inlinestaticconstexpr |
Convert a color to a 32-bit color.
color | A color |
|
staticconstexpr |
Azure predefined color.
|
staticconstexpr |
Black predefined color.
|
staticconstexpr |
Blue predefined color.
|
staticconstexpr |
Chartreuse predefined color.
|
staticconstexpr |
Cyan predefined color.
|
staticconstexpr |
Green predefined color.
|
staticconstexpr |
Magenta predefined color.
|
staticconstexpr |
Orange predefined color.
|
staticconstexpr |
Red predefined color.
|
staticconstexpr |
Rose predefined color.
|
staticconstexpr |
Spring (green) predefined color.
|
staticconstexpr |
Transparent (black) predefined color.
|
staticconstexpr |
Violet predefined color.
|
staticconstexpr |
White predefined color.
|
staticconstexpr |
Yellow predefined color.