Defines RGBA (red, green, blue, alpha) values on the range [0, 1].
#include <drake/geometry/rgba.h>
Public Member Functions | |
Rgba ()=default | |
Default constructor produces fully opaque white. More... | |
Rgba (double r, double g, double b, double a=1.0) | |
Constructs with given (r, g, b, a) values. More... | |
double | r () const |
Red. More... | |
double | g () const |
Green. More... | |
double | b () const |
Blue. More... | |
double | a () const |
Alpha. More... | |
Eigen::Vector4d | rgba () const |
Returns all four elements in order. More... | |
void | set (double r, double g, double b, double a=1.0) |
Sets (r, g, b, a) values. More... | |
void | set (const Eigen::Ref< const Eigen::VectorXd > &rgba) |
Sets an (r, g, b, a) from a vector. More... | |
void | update (std::optional< double > r={}, std::optional< double > g={}, std::optional< double > b={}, std::optional< double > a={}) |
Updates individual (r, g, b, a) values; any values not provided will remain unchanged. More... | |
bool | AlmostEqual (const Rgba &other, double tolerance=0.0) const |
Reports if two Rgba values are equal within a given absolute tolerance . More... | |
bool | operator== (const Rgba &other) const |
bool | operator!= (const Rgba &other) const |
Rgba | operator * (const Rgba &other) const |
Computes the element-wise product of two rgba colors. More... | |
Rgba | scale_rgb (double scale) const |
Computes a new Rgba color by multiplying the color channels (rgb) by the given scalar scalar . More... | |
template<typename Archive > | |
void | Serialize (Archive *a) |
Passes this object to an Archive. More... | |
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable | |
Rgba (const Rgba &)=default | |
Rgba & | operator= (const Rgba &)=default |
Rgba (Rgba &&)=default | |
Rgba & | operator= (Rgba &&)=default |
Friends | |
std::ostream & | operator<< (std::ostream &out, const Rgba &rgba) |
|
default |
Default constructor produces fully opaque white.
Constructs with given (r, g, b, a) values.
double a | ( | ) | const |
Alpha.
Reports if two Rgba values are equal within a given absolute tolerance
.
They are "equal" so long as the difference in no single channel is larger than the specified tolerance
.
double b | ( | ) | const |
Blue.
double g | ( | ) | const |
Green.
Computes the element-wise product of two rgba colors.
This type of calculation is frequently used to modulate one color with another (e.g., for lighting or texturing).
bool operator!= | ( | const Rgba & | other | ) | const |
bool operator== | ( | const Rgba & | other | ) | const |
double r | ( | ) | const |
Red.
Eigen::Vector4d rgba | ( | ) | const |
Returns all four elements in order.
Computes a new Rgba color by multiplying the color channels (rgb) by the given scalar scalar
.
All resultant channel values saturate at one. The result has this
Rgba's alpha values.
void Serialize | ( | Archive * | a | ) |
Passes this object to an Archive.
In YAML, an Rgba is represented by an array-like list of three or four numbers. E.g.,
rgba: [0.5, 0.5, 1.0]
or
rgba: [0.5, 0.5, 1.0, 0.5]
such that the first three values are red, green, and blue, respectively. If no fourth value is provided, alpha is defined a 1.0.
Refer to YAML Serialization for background.
Sets (r, g, b, a) values.
std::exception | if any values are outside of the range [0, 1]. |
void set | ( | const Eigen::Ref< const Eigen::VectorXd > & | rgba | ) |
Sets an (r, g, b, a) from a vector.
std::exception | if the vector is not size 3 or 4. |
std::exception | if any values are outside of the range [0, 1]. |
void update | ( | std::optional< double > | r = {} , |
std::optional< double > | g = {} , |
||
std::optional< double > | b = {} , |
||
std::optional< double > | a = {} |
||
) |
Updates individual (r, g, b, a) values; any values not provided will remain unchanged.
std::exception | if any values are outside of the range [0, 1]. |
|
friend |