34 #include "../../Core/Math/vec4.h"
67 Color(
unsigned char red,
unsigned char green,
unsigned char blue,
unsigned char alpha = 255)
76 Color(
const std::string &hexstr);
108 unsigned int get_argb8()
const {
return (((
unsigned int)
a) << 24) | (((
unsigned int)
r) << 16) | (((
unsigned int)
g) << 8) | (
unsigned int)
b; }
111 unsigned int get_abgr8()
const {
return (((
unsigned int)
a) << 24) | (((
unsigned int)
b) << 16) | (((
unsigned int)
g) << 8) | (
unsigned int)
r; }
114 unsigned int get_rgba8()
const {
return (((
unsigned int)
r) << 24) | (((
unsigned int)
g) << 16) | (((
unsigned int)
b) << 8) | (
unsigned int)
a; }
117 unsigned int get_bgra8()
const {
return (((
unsigned int)
b) << 24) | (((
unsigned int)
g) << 16) | (((
unsigned int)
r) << 8) | (
unsigned int)
a; }
124 return (
r ==
c.r) && (
g ==
c.g) && (
b ==
c.b) && (
a ==
c.a);
130 return (
r !=
c.r) || (
g !=
c.g) || (
b !=
c.b) || (
a !=
c.a);
623 void set_red_f(
float value) {
r = (
unsigned char) (value*255.0
f); }
632 void set_color(
unsigned char new_red,
unsigned char new_green,
unsigned char new_blue,
unsigned char new_alpha = 255)
633 {
r = new_red;
g = new_green;
b = new_blue;
a = new_alpha; }
648 void set_colorf(
float new_red,
float new_green,
float new_blue,
float new_alpha = 1.0f)
650 r = (
unsigned char) (new_red * 255.0
f);
651 g = (
unsigned char) (new_green * 255.0
f);
652 b = (
unsigned char) (new_blue * 255.0
f);
653 a = (
unsigned char) (new_alpha * 255.0
f);
691 :
Vec4f((array_rgba[0]), (array_rgba[1]), (array_rgba[2]), (array_rgba[3]))
711 Colorf(
unsigned char r,
unsigned char g,
unsigned char b,
unsigned char a=255)
780 r = (
r < 0.0f) ? 0.0
f : ((
r > 1.0
f) ? 1.0f :
r);
781 g = (
g < 0.0f) ? 0.0
f : ((
g > 1.0
f) ? 1.0f :
g);
782 b = (
b < 0.0f) ? 0.0
f : ((
b > 1.0
f) ? 1.0f :
b);
783 a = (
a < 0.0f) ? 0.0
f : ((
a > 1.0
f) ? 1.0f :
a);
801 return (
r ==
c.r) && (
g ==
c.g) && (
b ==
c.b) && (
a ==
c.a);
807 return (
r !=
c.r) || (
g !=
c.g) || (
b !=
c.b) || (
a !=
c.a);
static Colorf midnightblue
Definition: color.h:1110
static Color antiquewhite
Definition: color.h:142
static Colorf oldlace
Definition: color.h:1128
static Color darkorange
Definition: color.h:229
static Colorf steelblue
Definition: color.h:1227
static Color slateblue
Definition: color.h:529
static Color papayawhip
Definition: color.h:475
static Colorf darkturquoise
Definition: color.h:936
static Colorf greenyellow
Definition: color.h:990
static Colorf darkolivegreen
Definition: color.h:909
static Colorf transparent
rgba(0, 0, 0, 0).
Definition: color.h:1263
static Colorf pink
Definition: color.h:1167
Colorf(const std::string &hexstr)
Constructs a color.
Definition: color.h:741
static Color darkolivegreen
Definition: color.h:226
Color()
Constructs a color.
Definition: color.h:54
static Colorf gainsboro
Definition: color.h:969
static Colorf blanchedalmond
Definition: color.h:846
void normalize()
Normalize the color by ensuring that all color values lie inbetween (0.0, 1.0)
Definition: color.h:778
static Color floralwhite
Definition: color.h:277
static Color lightgoldenrodyellow
Definition: color.h:349
static Color aliceblue
Definition: color.h:139
static Colorf lightcoral
Definition: color.h:1026
static Color turquoise
Definition: color.h:559
static Colorf red
Definition: color.h:1179
static Colorf mediumpurple
Definition: color.h:1092
static Colorf mediumorchid
Definition: color.h:1089
static Color lightslategrey
Definition: color.h:376
static Colorf cornflowerblue
Definition: color.h:873
static Colorf salmon
Definition: color.h:1191
static Color springgreen
Definition: color.h:541
static Colorf hotpink
Definition: color.h:996
static Color darkred
Definition: color.h:235
static Color cornsilk
Definition: color.h:193
static Color mediumturquoise
Definition: color.h:421
static Color lightseagreen
Definition: color.h:367
static Color burlywood
Definition: color.h:175
static Color dimgray
Definition: color.h:265
static Colorf mediumturquoise
Definition: color.h:1104
static Color darkgoldenrod
Definition: color.h:208
static Color steelblue
Definition: color.h:544
static Colorf firebrick
Definition: color.h:957
static Colorf lightpink
Definition: color.h:1044
static Color goldenrod
Definition: color.h:295
static Color ghostwhite
Definition: color.h:289
unsigned int get_bgra8() const
Returns the color in BGRA8888 format.
Definition: color.h:117
static Color oldlace
Definition: color.h:445
static Colorf papayawhip
Definition: color.h:1158
float get_alpha_f() const
Returns the alpha color component, in the range 0-1.
Definition: color.h:96
static Color indianred
Definition: color.h:316
static Colorf green
Definition: color.h:987
static Color lightcyan
Definition: color.h:346
static Color silver
Definition: color.h:523
static Color darkseagreen
Definition: color.h:241
static Colorf orchid
Definition: color.h:1143
static Colorf chocolate
Definition: color.h:867
static Colorf gold
Definition: color.h:975
static Color mediumseagreen
Definition: color.h:412
static Colorf brown
Definition: color.h:855
static Color darkviolet
Definition: color.h:256
static Color tomato
Definition: color.h:556
static Colorf mistyrose
Definition: color.h:1116
void set_green_f(float value)
Set green color component, in the range 0-1.
Definition: color.h:626
static Color gray40
Definition: color.h:585
static Colorf lightgray
Definition: color.h:1035
static Colorf cyan
Definition: color.h:882
static Colorf mediumslateblue
Definition: color.h:1098
static Color fuchsia
Definition: color.h:283
static Colorf gray
Definition: color.h:981
static Color palevioletred
Definition: color.h:472
static Color mediumvioletred
Definition: color.h:424
static Color lightsalmon
Definition: color.h:364
static Color limegreen
Definition: color.h:388
void set_bgra8(unsigned int color)
Set color based on rgba color components.
static Color bisque
Definition: color.h:157
static Color peru
Definition: color.h:481
static Color orangered
Definition: color.h:457
Type g
Definition: vec4.h:81
static Colorf darkblue
Definition: color.h:885
static Color darkgray
Definition: color.h:211
Colorf(float r, float g, float b, float a=1.0f)
Constructs a color.
Definition: color.h:680
static Color lawngreen
Definition: color.h:334
Type r
Definition: vec4.h:80
static Colorf silver
Definition: color.h:1206
static Colorf cadetblue
Definition: color.h:861
static Color grey
Definition: color.h:301
Colorf()
Constructs a color.
Definition: color.h:667
static Color plum
Definition: color.h:487
static Colorf gray60
Definition: color.h:1270
static Color mediumslateblue
Definition: color.h:415
static Color red
Definition: color.h:496
static Colorf olive
Definition: color.h:1131
static Color brown
Definition: color.h:172
static Colorf darkkhaki
Definition: color.h:903
static Color gray
Definition: color.h:298
static Color khaki
Definition: color.h:325
static Color lightslategray
Definition: color.h:373
static Color thistle
Definition: color.h:553
static Colorf lemonchiffon
Definition: color.h:1020
static Color chocolate
Definition: color.h:184
static Colorf whitesmoke
Definition: color.h:1254
static Color pink
Definition: color.h:484
static Color lavenderblush
Definition: color.h:331
static Colorf powderblue
Definition: color.h:1173
static Color seagreen
Definition: color.h:514
static Colorf slategrey
Definition: color.h:1218
static Colorf skyblue
Definition: color.h:1209
static Color find_color(const std::string &name)
Find and returns the static color matching a string.
static Color gray90
Definition: color.h:590
static Color gray20
Definition: color.h:583
static Colorf lightslategray
Definition: color.h:1056
static Colorf khaki
Definition: color.h:1008
static Color teal
Definition: color.h:550
Floating point color description class (for float).
Definition: color.h:661
static Color navajowhite
Definition: color.h:439
static Colorf purple
Definition: color.h:1176
static Colorf beige
Definition: color.h:837
static Color lightsteelblue
Definition: color.h:379
static Color linen
Definition: color.h:391
static Colorf dimgrey
Definition: color.h:951
static Colorf darkorange
Definition: color.h:912
static Color coral
Definition: color.h:187
static Color honeydew
Definition: color.h:310
static Colorf gray10
Definition: color.h:1265
static Colorf snow
Definition: color.h:1221
static Colorf deepskyblue
Definition: color.h:945
static Colorf ghostwhite
Definition: color.h:972
static Colorf mediumaquamarine
Definition: color.h:1083
static Color lightpink
Definition: color.h:361
static Color darkslateblue
Definition: color.h:244
void set_rgb8(unsigned int color)
Set color based on rgb color components. Alpha is set to 255.
static Color forestgreen
Definition: color.h:280
static Color cornflowerblue
Definition: color.h:190
static Color lime
Definition: color.h:385
static Colorf grey
Definition: color.h:984
static Colorf tomato
Definition: color.h:1239
static Colorf lightsalmon
Definition: color.h:1047
static Colorf mintcream
Definition: color.h:1113
void set_red(unsigned char value)
Set red color component, in the range 0-255.
Definition: color.h:611
static Colorf royalblue
Definition: color.h:1185
static Colorf lightsteelblue
Definition: color.h:1062
bool operator!=(const Color &c) const
Color != Color operator (deep compare)
Definition: color.h:128
static Color purple
Definition: color.h:493
static Colorf sienna
Definition: color.h:1203
static Color ivory
Definition: color.h:322
static Colorf lightgrey
Definition: color.h:1041
Color(const std::string &hexstr)
Constructs a color.
static Colorf yellowgreen
Definition: color.h:1260
static Color palegreen
Definition: color.h:466
static Colorf coral
Definition: color.h:870
Color description class.
Definition: color.h:47
Colorf(unsigned char r, unsigned char g, unsigned char b, unsigned char a=255)
Constructs a color.
Definition: color.h:711
static Colorf floralwhite
Definition: color.h:960
Colorf(const Vec4f &color)
Constructs a color.
Definition: color.h:698
unsigned int get_argb8() const
Returns the color in ARGB8888 format.
Definition: color.h:108
static Colorf seagreen
Definition: color.h:1197
static Colorf darkgoldenrod
Definition: color.h:891
static Color slategrey
Definition: color.h:535
static Colorf tan
Definition: color.h:1230
float get_blue_f() const
Returns the blue color component, in the range 0-1.
Definition: color.h:105
static Colorf gray50
Definition: color.h:1269
static Color mediumpurple
Definition: color.h:409
static Color gray80
Definition: color.h:589
static Color lavender
Definition: color.h:328
static Color cadetblue
Definition: color.h:178
static Colorf thistle
Definition: color.h:1236
unsigned int get_abgr8() const
Returns the color in ABGR8888 format.
Definition: color.h:111
static Color yellowgreen
Definition: color.h:577
static Color indigo
Definition: color.h:319
static Color darkorchid
Definition: color.h:232
static Color palegoldenrod
Definition: color.h:463
unsigned char get_red() const
Returns the red color component, in the range 0-255.
Definition: color.h:87
static Colorf fuchsia
Definition: color.h:966
static Color maroon
Definition: color.h:397
static Colorf chartreuse
Definition: color.h:864
void set_red_f(float value)
Set red color component, in the range 0-1.
Definition: color.h:623
static Color rosybrown
Definition: color.h:499
static Colorf bisque
Definition: color.h:840
static Colorf lightskyblue
Definition: color.h:1053
static Colorf palegreen
Definition: color.h:1149
static Color orange
Definition: color.h:454
static Color transparent
rgba(0, 0, 0, 0).
Definition: color.h:580
unsigned int get_rgba8() const
Returns the color in RGBA8888 format.
Definition: color.h:114
static Color violet
Definition: color.h:562
void set_green(float value)
Set green color component, in the range 0-1.
Definition: color.h:793
static Color deepskyblue
Definition: color.h:262
static Colorf darksalmon
Definition: color.h:921
unsigned char get_green() const
Returns the green color component, in the range 0-255.
Definition: color.h:90
static Color gray60
Definition: color.h:587
Colorf(const float *array_rgba)
Constructs a color.
Definition: color.h:690
void set_color(unsigned char new_red, unsigned char new_green, unsigned char new_blue, unsigned char new_alpha=255)
Set color based on rgba color components in the range 0-255.
Definition: color.h:632
static Color cyan
Definition: color.h:199
void set_alpha_f(float value)
Set alpha color component, in the range 0-1.
Definition: color.h:620
static Colorf azure
Definition: color.h:834
static Color lightgray
Definition: color.h:352
static Colorf forestgreen
Definition: color.h:963
static Colorf dodgerblue
Definition: color.h:954
static Colorf sandybrown
Definition: color.h:1194
Type a
Definition: vec4.h:83
static Color lightyellow
Definition: color.h:382
static Color mediumorchid
Definition: color.h:406
static Colorf lightyellow
Definition: color.h:1065
static Colorf turquoise
Definition: color.h:1242
static Colorf olivedrab
Definition: color.h:1134
static Colorf plum
Definition: color.h:1170
void set_red(float value)
Set red color component, in the range 0-1.
Definition: color.h:790
static Color wheat
Definition: color.h:565
static Colorf linen
Definition: color.h:1074
static Colorf darkmagenta
Definition: color.h:906
static Color navy
Definition: color.h:442
static Color mintcream
Definition: color.h:430
static Color darkturquoise
Definition: color.h:253
static Color darkgrey
Definition: color.h:217
static Color deeppink
Definition: color.h:259
static Colorf crimson
Definition: color.h:879
static Color magenta
Definition: color.h:394
static Colorf lawngreen
Definition: color.h:1017
static Color azure
Definition: color.h:151
static Color mediumaquamarine
Definition: color.h:400
static Colorf navy
Definition: color.h:1125
void set_green(unsigned char value)
Set green color component, in the range 0-255.
Definition: color.h:614
static Colorf darkslategrey
Definition: color.h:933
static Colorf wheat
Definition: color.h:1248
static Colorf lavenderblush
Definition: color.h:1014
static Colorf maroon
Definition: color.h:1080
static Color lightcoral
Definition: color.h:343
static Color salmon
Definition: color.h:508
static Colorf darkred
Definition: color.h:918
float get_green_f() const
Returns the green color component, in the range 0-1.
Definition: color.h:102
static Colorf gray40
Definition: color.h:1268
static Color darkkhaki
Definition: color.h:220
static Color skyblue
Definition: color.h:526
4D vector
Definition: size.h:47
static Colorf violet
Definition: color.h:1245
static Colorf lightcyan
Definition: color.h:1029
static Color lemonchiffon
Definition: color.h:337
static Color blueviolet
Definition: color.h:169
static Color dodgerblue
Definition: color.h:271
static Colorf lightgoldenrodyellow
Definition: color.h:1032
static Colorf ivory
Definition: color.h:1005
Color(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255)
Constructs a color.
Definition: color.h:67
static Colorf darkseagreen
Definition: color.h:924
static Colorf mediumblue
Definition: color.h:1086
static Colorf slateblue
Definition: color.h:1212
static Colorf darkslateblue
Definition: color.h:927
static Color beige
Definition: color.h:154
static Colorf seashell
Definition: color.h:1200
static Colorf paleturquoise
Definition: color.h:1152
static Color royalblue
Definition: color.h:502
static Colorf blueviolet
Definition: color.h:852
static Colorf blue
Definition: color.h:849
void set_blue(unsigned char value)
Set blue color component, in the range 0-255.
Definition: color.h:617
static Color blue
Definition: color.h:166
static Color moccasin
Definition: color.h:436
static Color green
Definition: color.h:304
static Color white
Definition: color.h:568
void set_argb8(unsigned int color)
Set color based on argb color components.
static Colorf antiquewhite
Definition: color.h:825
static Colorf limegreen
Definition: color.h:1071
static Color paleturquoise
Definition: color.h:469
static Color black
Definition: color.h:160
static Color darkgreen
Definition: color.h:214
static Color yellow
Definition: color.h:574
static Colorf mediumvioletred
Definition: color.h:1107
static Color dimgrey
Definition: color.h:268
static Colorf darkgray
Definition: color.h:894
static Colorf palegoldenrod
Definition: color.h:1146
static Color snow
Definition: color.h:538
void set_rgba8(unsigned int color)
Set color based on rgba color components.
float get_green() const
Get Green.
Definition: color.h:760
bool operator==(const Colorf &c) const
Color == Color operator (deep compare)
Definition: color.h:799
static Colorf honeydew
Definition: color.h:993
static Colorf slategray
Definition: color.h:1215
static Colorf rosybrown
Definition: color.h:1182
void set_blue(float value)
Set blue color component, in the range 0-1.
Definition: color.h:796
static Colorf darkorchid
Definition: color.h:915
static Colorf burlywood
Definition: color.h:858
Type b
Definition: vec4.h:82
static Colorf darkslategray
Definition: color.h:930
static Colorf black
Definition: color.h:843
static Color darksalmon
Definition: color.h:238
static Colorf lightseagreen
Definition: color.h:1050
static Colorf dimgray
Definition: color.h:948
unsigned char get_alpha() const
Returns the alpha color component, in the range 0-255.
Definition: color.h:84
static Color lightblue
Definition: color.h:340
static Color midnightblue
Definition: color.h:427
static Colorf aqua
Definition: color.h:828
static Colorf lightgreen
Definition: color.h:1038
static Color tan
Definition: color.h:547
static Colorf magenta
Definition: color.h:1077
static Colorf aliceblue
Definition: color.h:822
static Colorf darkviolet
Definition: color.h:939
static Color darkcyan
Definition: color.h:205
static Colorf gray20
Definition: color.h:1266
static Colorf yellow
Definition: color.h:1257
Colorf(const Color &color)
Definition: color.h:730
static Color mediumblue
Definition: color.h:403
static Color darkslategrey
Definition: color.h:250
static Color firebrick
Definition: color.h:274
static Color mediumspringgreen
Definition: color.h:418
static Color sienna
Definition: color.h:520
static Color seashell
Definition: color.h:517
static Color lightgreen
Definition: color.h:355
static std::vector< std::string > & get_names()
Returns the names of static colors defined.
static Color orchid
Definition: color.h:460
static Colorf gray70
Definition: color.h:1271
float get_red_f() const
Returns the red color component, in the range 0-1.
Definition: color.h:99
static Color aqua
Definition: color.h:145
static Colorf springgreen
Definition: color.h:1224
static Color greenyellow
Definition: color.h:307
static Colorf gray80
Definition: color.h:1272
static Colorf orange
Definition: color.h:1137
float get_alpha() const
Get Alpha.
Definition: color.h:770
static Colorf orangered
Definition: color.h:1140
static Colorf peru
Definition: color.h:1164
static Colorf lightblue
Definition: color.h:1023
static Colorf moccasin
Definition: color.h:1119
float get_red() const
Get Red.
Definition: color.h:755
static Colorf goldenrod
Definition: color.h:978
static Colorf palevioletred
Definition: color.h:1155
static Colorf navajowhite
Definition: color.h:1122
static Colorf indianred
Definition: color.h:999
static Color darkmagenta
Definition: color.h:223
void set_alpha(unsigned char value)
Set alpha color component, in the range 0-255.
Definition: color.h:608
static Colorf gray90
Definition: color.h:1273
static Color gold
Definition: color.h:292
static Color blanchedalmond
Definition: color.h:163
static Color darkblue
Definition: color.h:202
static Color gray50
Definition: color.h:586
static Color whitesmoke
Definition: color.h:571
static Color lightgrey
Definition: color.h:358
bool operator!=(const Colorf &c) const
Color != Color operator (deep compare)
Definition: color.h:805
static Colorf gray30
Definition: color.h:1267
float get_blue() const
Get Blue.
Definition: color.h:765
static Color gainsboro
Definition: color.h:286
unsigned char get_blue() const
Returns the blue color component, in the range 0-255.
Definition: color.h:93
static Color saddlebrown
Definition: color.h:505
static Color aquamarine
Definition: color.h:148
static Colorf peachpuff
Definition: color.h:1161
static Color mistyrose
Definition: color.h:433
static Colorf lavender
Definition: color.h:1011
static Color slategray
Definition: color.h:532
void set_colorf(float new_red, float new_green, float new_blue, float new_alpha=1.0f)
Set color based on rgba color components in the range 0-1.
Definition: color.h:648
static Colorf indigo
Definition: color.h:1002
static Color lightskyblue
Definition: color.h:370
void set_alpha(float value)
Set alpha color component, in the range 0-1.
Definition: color.h:787
static Colorf darkgreen
Definition: color.h:897
static Color hotpink
Definition: color.h:313
Colorf(int r, int g, int b, int a=255)
Constructs a color.
Definition: color.h:725
bool operator==(const Color &c) const
Color == Color operator (deep compare)
Definition: color.h:122
static Color chartreuse
Definition: color.h:181
static Color olivedrab
Definition: color.h:451
static Colorf darkcyan
Definition: color.h:888
static Color powderblue
Definition: color.h:490
void set_blue_f(float value)
Set blue color component, in the range 0-1.
Definition: color.h:629
static Colorf saddlebrown
Definition: color.h:1188
static Colorf teal
Definition: color.h:1233
static Color sandybrown
Definition: color.h:511
static Color gray70
Definition: color.h:588
static Colorf cornsilk
Definition: color.h:876
static Colorf lime
Definition: color.h:1068
static Color gray30
Definition: color.h:584
static Colorf lightslategrey
Definition: color.h:1059
static Colorf mediumseagreen
Definition: color.h:1095
static Colorf deeppink
Definition: color.h:942
static Color gray10
Definition: color.h:582
static Color darkslategray
Definition: color.h:247
static Colorf mediumspringgreen
Definition: color.h:1101
static Colorf aquamarine
Definition: color.h:831
static Colorf white
Definition: color.h:1251
static Color peachpuff
Definition: color.h:478
static Color crimson
Definition: color.h:196
static Color olive
Definition: color.h:448
static Colorf darkgrey
Definition: color.h:900