5 #ifndef _LUMIVERSECOLOR_H_
6 #define _LUMIVERSECOLOR_H_
10 #include <unordered_map>
15 #include "lib/Eigen/Dense"
16 #include "../LumiverseType.h"
47 ColorModeToString[
ADDITIVE] =
"ADDITIVE";
49 ColorModeToString[
BASIC_RGB] =
"BASIC_RGB";
50 ColorModeToString[
BASIC_CMY] =
"BASIC_CMY";
52 return ColorModeToString[m];
57 StringToColorMode[
"ADDITIVE"] =
ADDITIVE;
59 StringToColorMode[
"BASIC_RGB"] =
BASIC_RGB;
60 StringToColorMode[
"BASIC_CMY"] =
BASIC_CMY;
62 return StringToColorMode[s];
103 LumiverseColor(unordered_map<string, double> params, map<string, Eigen::Vector3d> basis,
ColorMode mode,
double weight);
125 virtual void reset();
128 virtual JSONNode toJSON(
string name);
135 virtual string asString();
166 Eigen::Vector3d
getXYZ() {
return Eigen::Vector3d(getX(), getY(), getZ()); }
196 void setRGB(
double r,
double g,
double b,
double weight = 1.0,
RGBColorSpace cs =
sRGB);
214 void setxy(
double x,
double y,
double weight = 1.0);
221 Eigen::Vector3d getxyY();
228 Eigen::Vector3d getLab(ReferenceWhite refWhite);
237 Eigen::Vector3d getLab(Eigen::Vector3d refWhite);
244 Eigen::Vector3d getLCHab(ReferenceWhite refWhite);
251 Eigen::Vector3d getLCHab(Eigen::Vector3d refWhite);
258 Eigen::Vector2d getupvp();
265 Eigen::Vector2d getuv();
277 Eigen::Vector2d getCCT();
283 bool addColorChannel(
string name);
290 bool deleteColorChannel(
string name);
302 bool setColorChannel(
string name,
double val);
317 double& operator[](
string name);
327 void setWeight(
double weight);
338 bool setRGBRaw(
double r,
double g,
double b,
double weight = 1.0);
347 bool setHSV(
double H,
double S,
double V,
double weight = 1.0);
403 virtual bool isDefault();
423 void setBasisVector(
string channel,
double x,
double y,
double z);
431 void removeBasisVector(
string channel);
438 Eigen::Vector3d getBasisVector(
string channel);
445 size_t numBasisVectors() {
return m_basisVectors.size(); }
482 double sumComponent(
int i);
485 Eigen::Vector3d RGBtoXYZ(
double r,
double g,
double b,
RGBColorSpace cs);
500 void matchChroma(
double x,
double y,
double weight = 1.0);
505 inline bool doubleEq(
double a,
double b) {
506 return (abs(a - b) < DBL_EPSILON);
511 inline bool operator==(LumiverseColor& a, LumiverseColor& b) {
512 if (a.getTypeName() !=
"color" || b.getTypeName() !=
"color")
Definition: LumiverseColor.h:27
This class is a wapper around a variety of different possible data types that might be needed by a De...
Definition: LumiverseType.h:33
Eigen::Vector3d getXYZ()
Returns a vector representing the color in XYZ coordinates.
Definition: LumiverseColor.h:166
This class describes a color.
Definition: LumiverseColor.h:83
static unordered_map< int, string > ColorModeToString
Converts ColorMode to a string.
Definition: LumiverseColor.h:32
Eigen::Vector3d m_XYZ
Cached XYZ value to avoid recomputation if color has not changed.
Definition: LumiverseColor.h:476
mutex m_mapMutex
Protects access to the deviceChannels map.
Definition: LumiverseColor.h:459
Contains information for calculating various colors from incandescent sources.
unordered_map< string, double > getColorParams()
Gets the current values for the color parameters.
Definition: LumiverseColor.h:352
Definition: LumiverseColorLib.h:30
RGBColorSpace
Selects a RGB color space to use in color conversion functions.
Definition: LumiverseColorLib.h:29
Definition: LumiverseColor.h:24
const map< string, Eigen::Vector3d > & getBasisVectors()
Returns the map of channel name to basis vector.
Definition: LumiverseColor.h:443
shared_ptr< LumiverseType > lerp(LumiverseType *lhs, LumiverseType *rhs, float t)
Lerps the values of a LumiverseType and returns the value.
Definition: LumiverseTypeUtils.cpp:98
map< string, Eigen::Vector3d > m_basisVectors
Basis vectors for each LED source in the light. Represented in XYZ.
Definition: LumiverseColor.h:470
double getColorChannel(string name)
Gets the weighted value for the color channel.
Definition: LumiverseColor.h:309
virtual string getTypeName()
Returns the name of the type.
Definition: LumiverseColor.h:120
Definition: LumiverseColor.h:25
double getWeight()
Gets the weight.
Definition: LumiverseColor.h:355
unordered_map< string, double > m_deviceChannels
Contains a map from device channel to current value.
Definition: LumiverseColor.h:467
ColorMode getMode()
Gets the mode of the color.
Definition: LumiverseColor.h:416
Contains all core Lumiverse functions and variables.
Definition: Device.cpp:2
double m_weight
Parameter that controls the overall values of the device channels.
Definition: LumiverseColor.h:453
ColorMode
Selects the color mode for a LumiverseColor.
Definition: LumiverseColor.h:23
bool m_XYZupdated
Is true if the XYZ cache has been updated.
Definition: LumiverseColor.h:473
ColorMode m_mode
Color mode for this color.
Definition: LumiverseColor.h:456
static unordered_map< string, ColorMode > StringToColorMode
Converts a string to ColorMode.
Definition: LumiverseColor.h:39
Definition: LumiverseColor.h:26