|
VisuTwin Canvas
C++ 3D Engine — Metal Backend
|
RGBA color with floating-point components in [0, 1]. More...
#include <core/math/color.h>
Public Member Functions | |
| Color | clone () const |
| Color (const Color &other)=default | |
| Color (const float *arr, size_t size) | |
| Color (const float r=0.0f, const float g=0.0f, const float b=0.0f, const float a=1.0f) | |
| Color (const std::vector< float > &arr) | |
| Color & | copy (const Color &rhs) |
| bool | equals (const Color &rhs) const |
| Color & | fromArray (const float *arr, size_t size, size_t offset=0) |
| Color & | fromArray (const std::vector< float > &arr, size_t offset=0) |
| Color & | fromString (const std::string &hex) |
| Color & | gamma (const Color *src=nullptr) |
| Color & | lerp (const Color &lhs, const Color &rhs, float alpha) |
| Color & | linear (const Color *src=nullptr) |
| Color & | mulScalar (float scalar) |
| bool | operator!= (const Color &other) const |
| Color & | operator= (const Color &other)=default |
| bool | operator== (const Color &other) const |
| Color & | set (float r, float g, float b, float a=1.0f) |
| void | toArray (float *arr, size_t size, size_t offset=0, bool alpha=true) const |
| std::vector< float > | toArray (std::vector< float > arr={}, size_t offset=0, bool alpha=true) const |
| std::string | toString (bool alpha=false, bool asArray=false) const |
Public Attributes | |
| float | a |
| float | b |
| float | g |
| float | r |
Static Public Attributes | |
| static const Color | BLACK |
| static const Color | BLUE |
| static const Color | CYAN |
| static const Color | GRAY |
| static const Color | GREEN |
| static const Color | MAGENTA |
| static const Color | RED |
| static const Color | WHITE |
| static const Color | YELLOW |
RGBA color with floating-point components in [0, 1].
The r, g, b components define a color in RGB space. The a (alpha) component defines transparency (1 = fully opaque, 0 = fully transparent).
|
inlineexplicit |
Definition at line 27 of file color.h.
Referenced by clone(), Color(), copy(), equals(), fromArray(), fromArray(), fromString(), gamma(), lerp(), linear(), mulScalar(), operator!=(), operator=(), operator==(), and set().
|
explicit |
| visutwin::canvas::Color::Color | ( | const float * | arr, |
| size_t | size ) |
|
default |
Copy constructor
References Color().
|
nodiscard |
|
nodiscard |
Reports whether two colors are equal.
| rhs | The color to compare to the specified color. |
Definition at line 66 of file color.cpp.
References a, b, Color(), g, and r.
Referenced by operator!=(), and operator==().
| Color & visutwin::canvas::Color::fromArray | ( | const float * | arr, |
| size_t | size, | ||
| size_t | offset = 0 ) |
| Color & visutwin::canvas::Color::fromArray | ( | const std::vector< float > & | arr, |
| size_t | offset = 0 ) |
| Color & visutwin::canvas::Color::fromString | ( | const std::string & | hex | ) |
Set the values of the color from a string representation '#11223344' or '#112233'.
| hex | A string representation in the format '#RRGGBBAA' or '#RRGGBB'. Where RR, GG, BB, AA are red, green, blue and alpha values. This is the same format used in HTML/CSS. |
Converts the color from linear to gamma color space.
| src | The color to convert to gamma color space. If not set, the operation is done in place. |
Definition at line 99 of file color.cpp.
References a, b, Color(), g, and r.
Referenced by visutwin::canvas::GlbParser::createFromModel(), visutwin::canvas::GlbParser::createFromPrepared(), and visutwin::canvas::GlbParser::parse().
Returns the result of a linear interpolation between two specified colors.
| lhs | The color to interpolate from. |
| rhs | The color to interpolate to. |
| alpha | The value controlling the point of interpolation. Between 0 and 1, the linear interpolant will occur on a straight line between lhs and rhs. Outside of this range, the linear interpolant will occur on a ray extrapolated from this line. |
Converts the color from gamma to linear color space.
| src | The color to convert to linear color space. If not set, the operation is done in place. |
Definition at line 89 of file color.cpp.
References a, b, Color(), g, and r.
Referenced by visutwin::canvas::MetalUniformBinder::setLightingUniforms().
| Color & visutwin::canvas::Color::mulScalar | ( | float | scalar | ) |
| bool visutwin::canvas::Color::operator!= | ( | const Color & | other | ) | const |
| bool visutwin::canvas::Color::operator== | ( | const Color & | other | ) | const |
| Color & visutwin::canvas::Color::set | ( | float | r, |
| float | g, | ||
| float | b, | ||
| float | a = 1.0f ) |
Assign values to the color components, including alpha.
| r | The value for red (0-1). |
| g | The value for green (0-1). |
| b | The value for blue (0-1). |
| a | The value for the alpha (0-1), defaults to 1. |
Definition at line 71 of file color.cpp.
References a, b, Color(), g, and r.
Referenced by fromString().
| void visutwin::canvas::Color::toArray | ( | float * | arr, |
| size_t | size, | ||
| size_t | offset = 0, | ||
| bool | alpha = true ) const |
Copies the color to a C-style array.
| arr | The array to populate with the color's number components. |
| size | Size of the target array. |
| offset | The zero-based index at which to start copying elements to the array. Default is 0. |
| alpha | If true, the output array will include the alpha value. |
|
nodiscard |
Converts the color to an array.
| arr | The array to populate with the color's number components. If empty, a new array is created. |
| offset | The zero-based index at which to start copying elements to the array. Default is 0. |
| alpha | If true, the output array will include the alpha value. |
|
nodiscard |
Converts the color to a string form. The format is '#RRGGBBAA', where RR, GG, BB, AA are the red, green, blue and alpha values. When the alpha value is not included (the default), this is the same format as used in HTML/CSS.
| alpha | If true, the output string will include the alpha value. |
| asArray | If true, the output will be an array of numbers. Defaults to false. |
| float visutwin::canvas::Color::a |
Definition at line 25 of file color.h.
Referenced by clone(), Color(), Color(), Color(), copy(), visutwin::canvas::GlbParser::createFromModel(), visutwin::canvas::GlbParser::createFromPrepared(), equals(), fromArray(), fromArray(), gamma(), visutwin::canvas::ImGuiOverlay::label3D(), lerp(), linear(), operator=(), visutwin::canvas::ImGuiOverlay::panelLabel3D(), visutwin::canvas::GlbParser::parse(), visutwin::canvas::ElementInput::renderElements(), set(), toArray(), toArray(), and toString().
| float visutwin::canvas::Color::b |
Definition at line 23 of file color.h.
Referenced by clone(), Color(), Color(), Color(), copy(), equals(), fromArray(), fromArray(), gamma(), visutwin::canvas::ImGuiOverlay::label3D(), lerp(), linear(), mulScalar(), operator=(), visutwin::canvas::ElementInput::renderElements(), set(), visutwin::canvas::MetalUniformBinder::setLightingUniforms(), toArray(), toArray(), and toString().
| float visutwin::canvas::Color::g |
Definition at line 21 of file color.h.
Referenced by clone(), Color(), Color(), Color(), copy(), equals(), fromArray(), fromArray(), gamma(), visutwin::canvas::ImGuiOverlay::label3D(), lerp(), linear(), mulScalar(), operator=(), visutwin::canvas::ElementInput::renderElements(), set(), visutwin::canvas::MetalUniformBinder::setLightingUniforms(), toArray(), toArray(), and toString().
| float visutwin::canvas::Color::r |
Definition at line 19 of file color.h.
Referenced by clone(), Color(), Color(), Color(), copy(), equals(), fromArray(), fromArray(), gamma(), visutwin::canvas::ImGuiOverlay::label3D(), lerp(), linear(), mulScalar(), operator=(), visutwin::canvas::ElementInput::renderElements(), set(), visutwin::canvas::MetalUniformBinder::setLightingUniforms(), toArray(), toArray(), and toString().