#include <color.h>
Public Types | |
using | value_type = T |
![]() | |
using | Converter = std::function< void(const BaseColor &, BaseColor &, int)> |
Public Member Functions | |
Color () | |
Color (const std::array< T, CHANNELS > &colors) | |
Color (const nap::BaseColor &source) | |
rtti::TypeInfo | getValueType () const override |
bool | isPointer () const override |
T | getValue (EColorChannel channel) const |
T & | getValue (EColorChannel channel) |
void | setValue (EColorChannel channel, T value) |
const std::array< T, CHANNELS > & | getValues () const |
T * | getData () |
const T * | getData () const |
void | setData (const T *data) |
float | getDistance (const Color< T, CHANNELS > &other) const |
bool | operator== (const Color< T, CHANNELS > &rhs) const |
bool | operator!= (const Color< T, CHANNELS > &rhs) const |
bool | operator< (const Color< T, CHANNELS > &rhs) const |
bool | operator> (const Color< T, CHANNELS > &rhs) const |
bool | operator<= (const Color< T, CHANNELS > &rhs) const |
bool | operator>= (const Color< T, CHANNELS > &rhs) const |
T & | operator[] (std::size_t index) |
const T & | operator[] (std::size_t index) const |
![]() | |
BaseColor (int channels, int size) | |
virtual | ~BaseColor ()=default |
bool | operator== (const BaseColor &rhs)=delete |
bool | operator!= (const BaseColor &rhs)=delete |
int | getNumberOfChannels () const |
int | valueSize () const |
void | convert (BaseColor &target) const |
Converter | getConverter (const BaseColor &target) const |
template<typename T > | |
T | convert () const |
int | size () const |
Public Attributes | |
std::array< T, CHANNELS > | mValues |
Additional Inherited Members | |
![]() | |
static void | convertColor (const BaseColor &source, BaseColor &target) |
static void | convertColor (const BaseColor &source, BaseColor &target, const Converter &converter) |
static Converter | getConverter (const BaseColor &source, const BaseColor &target) |
Specific type of color where T defines the value type of the color. Every color has at least 1 or more channels. Colors are always packed in the following order RGBA. This class can also be used to store pointers to colors and can therefore act as a convenient wrapper around bitmap color values. All color types can be hashed for convenience. This makes most sense for 8 and 16 bit color types. For float colors a simple x/or is used. In order to hash colors you should use one of the explicitly defined successive color types, ie: RGBA8, R8, RGBFloat etc.
using value_type = T |
Color | ( | ) |
Constructor that simply creates a 0 initialized color
Color | ( | const std::array< T, CHANNELS > & | colors | ) |
Constructor that creates a color based on a list of values. Note that the number of values in the array must match the number of channels. The order is important: RGBA.
Color | ( | const nap::BaseColor< T, CHANNELS > & | source | ) |
Initializes this color using a different type of color. Colors are converted automatically. The source color must have an equal or higher amount of channels.
source | the color to initialize this color with. |
T* getData | ( | ) |
const T* getData | ( | ) | const |
float getDistance | ( | const Color< T, CHANNELS > & | other | ) | const |
Computes the distance between this and another color in Euclidean space. The result is not squared
other | the color to compare against |
T & getValue | ( | EColorChannel | channel | ) |
channel | the channel to get the value for |
T getValue | ( | EColorChannel | channel | ) | const |
Returns the color value associated with a given channel. This call asserts when the channel is not available.
channel | the channel to get the value for |
const std::array<T, CHANNELS>& getValues | ( | ) | const |
|
overridevirtual |
Implements BaseColor.
|
overridevirtual |
Implements BaseColor.
bool operator!= | ( | const Color< T, CHANNELS > & | rhs | ) | const |
bool operator< | ( | const Color< T, CHANNELS > & | rhs | ) | const |
bool operator<= | ( | const Color< T, CHANNELS > & | rhs | ) | const |
bool operator== | ( | const Color< T, CHANNELS > & | rhs | ) | const |
bool operator> | ( | const Color< T, CHANNELS > & | rhs | ) | const |
bool operator>= | ( | const Color< T, CHANNELS > & | rhs | ) | const |
T& operator[] | ( | std::size_t | index | ) |
Array subscript overload. Does not perform a bounds check!
const T& operator[] | ( | std::size_t | index | ) | const |
Array subscript overload. Does not perform a bounds check!
void setData | ( | const T * | data | ) |
Set the color data associated with this color. This call assumes the data is of the right size and length. When this color points to a location in memory, that memory location is copied. Otherwise the actual values are copied over.
data | the color data to copy, behind the scenes a memcopy is performed |
void setValue | ( | EColorChannel | channel, |
T | value | ||
) |
Sets the color value for the incoming channel. This call asserts when the channel is not available.
channel | the color channel to set |
value | the new color value |
std::array<T, CHANNELS> mValues |
Color values associated with this color