1 #ifndef JUGIMAP_COLOR_H
2 #define JUGIMAP_COLOR_H
17 unsigned char r = 255;
18 unsigned char g = 255;
19 unsigned char b = 255;
20 unsigned char a = 255;
27 ColorRGBA(
unsigned char _r,
unsigned char _g,
unsigned char _b,
unsigned char _a=255) :
r(_r),
g(_g),
b(_b),
a(_a){}
33 g = (_rgba >> 8) & 0xFF;
34 b = (_rgba >> 16) & 0xFF;
35 a = (_rgba >> 24) & 0xFF;
42 return (
r==_colorRGBA.
r &&
g==_colorRGBA.
g &&
b==_colorRGBA.
b &&
a==_colorRGBA.
a)? true :
false;
48 return (
r==_ColorRGBA.
r &&
g==_ColorRGBA.
g &&
b==_ColorRGBA.
b &&
a==_ColorRGBA.
a)? false :
true;
55 return r | (
g << 8) | (
b << 16) | (
a << 24);
59 void Set(
unsigned char _r,
unsigned char _g,
unsigned char _b,
unsigned char _a)
72 g = (_rgba >> 8) & 0xFF;
73 b = (_rgba >> 16) & 0xFF;
74 a = (_rgba >> 24) & 0xFF;
77 static ColorRGBA ParseFromHexString(std::string _hexColor);
95 ColorRGBAf(
float _r,
float _g,
float _b,
float _a=1.0) :
r(_r),
g(_g),
b(_b),
a(_a){}
102 bool operator !=(
ColorRGBAf _colorRGBA) {
return !(operator ==(_colorRGBA)); }
113 int Add(
ColorRGBA _colorRGBA,
const std::string &_name){ colors.push_back({_name, _colorRGBA});
return colors.size()-1; }
134 std::vector<std::pair<std::string, ColorRGBA>> colors;
The ColorsLibrary defines storage for ColorRGBA objects.
Definition: jmColor.h:108
void Set(unsigned char _r, unsigned char _g, unsigned char _b, unsigned char _a)
Set the given **_r**, **_g**, **_b** and **_a**.
Definition: jmColor.h:59
Color in RGBA color space - integer variant.
Definition: jmColor.h:15
ColorRGBAf(const ColorRGBA &_colorRGBA)
Constructs a color from the given **_colorRGBA**.
Definition: jmColor.h:98
float r
The red component of the color in the range 0.0 - 1.0.
Definition: jmColor.h:85
unsigned char g
Green component of the color in the range 0 - 255.
Definition: jmColor.h:18
ColorRGBA(unsigned char _r, unsigned char _g, unsigned char _b, unsigned char _a=255)
Constructs a color with the given **_r**, **_g**, **_b** and **_a**.
Definition: jmColor.h:27
float b
The blue component of the color in the range 0.0 - 1.0.
Definition: jmColor.h:87
void Clear()
Clear all colors in this library.
Definition: jmColor.h:117
ColorRGBA Find(const std::string &_name)
Find and returns a color with the given *_name*. If the color is not found the function returns white...
Definition: jmColor.cpp:55
ColorRGBA(int _rgba)
Constructs a color from the given **_rgba**.
Definition: jmColor.h:30
int GetSize()
Returns the number of stored colors.
Definition: jmColor.h:129
bool operator==(ColorRGBA _colorRGBA)
Returns true if the given **_colorRGBA** is equal to this color; otherwise return false;.
Definition: jmColor.h:40
void Set(int _rgba)
Set the color from the given **_rgba**.
Definition: jmColor.h:69
ColorRGBAf(float _r, float _g, float _b, float _a=1.0)
Constructs a color with the given **_r**, **_g**, **_b** and **_a**.
Definition: jmColor.h:95
float a
The alpha component of the color in the range 0.0 - 1.0.
Definition: jmColor.h:88
ColorRGBA()
Constructs a color with r=0, g=0, b=0 and a=0.
Definition: jmColor.h:24
unsigned char b
Red component of the color in the range 0 - 255.
Definition: jmColor.h:19
ColorRGBA At(int _index)
Returns the color at the given index. If the index is out of storage bounds the white color is return...
Definition: jmColor.cpp:68
float g
The green component of the color in the range 0.0 - 1.0.
Definition: jmColor.h:86
Color in RGBA color space - float variant.
Definition: jmColor.h:83
unsigned char r
Red component of the color in the range 0 - 255.
Definition: jmColor.h:17
ColorRGBAf()
Constructs a color with r=0.0, g=0.0, b=0.0 and a=0.0.
Definition: jmColor.h:92
int GetRGBA()
Returns this color as an rgba integer value.
Definition: jmColor.h:53
unsigned char a
Alpha component of the color in the range 0 - 255.
Definition: jmColor.h:20
ColorsLibrary textColorsLibrary
A global library for text colors.
Definition: jmColor.cpp:81
bool operator!=(ColorRGBA _ColorRGBA)
Returns true if the given **_colorRGBA** is not equal to this color; otherwise return false;.
Definition: jmColor.h:46
int Add(ColorRGBA _colorRGBA, const std::string &_name)
Add the given color *_colorRGBA* with identification name *_name* to this library....
Definition: jmColor.h:113