34 #include "../api_display.h"
35 #include "../../Core/Math/vec4.h"
68 Color(
unsigned char red,
unsigned char green,
unsigned char blue,
unsigned char alpha = 255)
69 :
Vec4ub(red, green, blue, alpha) {
return; }
77 Color(
const std::string &hexstr);
88 unsigned char get_red()
const {
return r; }
109 unsigned int get_argb8()
const {
return (((
unsigned int)a) << 24) | (((
unsigned int)r) << 16) | (((
unsigned int)g) << 8) | (
unsigned int)b; }
112 unsigned int get_abgr8()
const {
return (((
unsigned int)a) << 24) | (((
unsigned int)b) << 16) | (((
unsigned int)g) << 8) | (
unsigned int)r; }
115 unsigned int get_rgba8()
const {
return (((
unsigned int)r) << 24) | (((
unsigned int)g) << 16) | (((
unsigned int)b) << 8) | (
unsigned int)a; }
118 unsigned int get_bgra8()
const {
return (((
unsigned int)b) << 24) | (((
unsigned int)g) << 16) | (((
unsigned int)r) << 8) | (
unsigned int)a; }
125 return (r == c.
r) && (g == c.
g) && (b == c.
b) && (a == c.
a);
131 return (r != c.
r) || (g != c.
g) || (b != c.
b) || (a != c.
a);
598 static Color find_color(
const std::string &name);
601 static std::vector<std::string> &get_names();
612 void set_red(
unsigned char value) { r = value; }
621 void set_alpha_f(
float value) { a = (
unsigned char) (value*255.0f); }
624 void set_red_f(
float value) { r = (
unsigned char) (value*255.0f); }
627 void set_green_f(
float value) { g = (
unsigned char) (value*255.0f); }
630 void set_blue_f(
float value) { b = (
unsigned char) (value*255.0f); }
633 void set_color(
unsigned char red,
unsigned char green,
unsigned char blue,
unsigned char alpha = 255)
634 { r = red; g = green; b = blue; a = alpha; }
637 void set_rgba8(
unsigned int color);
640 void set_bgra8(
unsigned int color);
643 void set_rgb8(
unsigned int color);
646 void set_argb8(
unsigned int color);
649 void set_colorf(
float red,
float green,
float blue,
float alpha = 1.0f)
651 r = (
unsigned char) (red * 255.0f);
652 g = (
unsigned char) (green * 255.0f);
653 b = (
unsigned char) (blue * 255.0f);
654 a = (
unsigned char) (alpha * 255.0f);
692 :
Vec4f((array_rgba[0]), (array_rgba[1]), (array_rgba[2]), (array_rgba[3]))
705 Colorf(
unsigned char r,
unsigned char g,
unsigned char b,
unsigned char a=255)
706 :
Vec4f((r/255.0f), (g/255.0f), (b/255.0f), (
a/255.0f))
720 :
Vec4f((r/255.0f), (g/255.0f), (b/255.0f), (
a/255.0f))
774 r = (
r < 0.0f) ? 0.0f : ((
r > 1.0f) ? 1.0f :
r);
775 g = (
g < 0.0f) ? 0.0f : ((
g > 1.0f) ? 1.0f :
g);
776 b = (
b < 0.0f) ? 0.0f : ((
b > 1.0f) ? 1.0f :
b);
777 a = (
a < 0.0f) ? 0.0f : ((
a > 1.0f) ? 1.0f :
a);
795 return (
r == c.
r) && (
g == c.
g) && (
b == c.
b) && (
a == c.
a);
801 return (
r != c.
r) || (
g != c.
g) || (
b != c.
b) || (
a != c.
a);
static Color black
Definition: color.h:161
static Color gray30
Definition: color.h:585
void set_colorf(float red, float green, float blue, float alpha=1.0f)
Set color based on rgba color components in the range 0-1.
Definition: color.h:649
static Colorf beige
Definition: color.h:831
static Colorf green
Definition: color.h:981
static Color linen
Definition: color.h:392
static Colorf skyblue
Definition: color.h:1203
static Colorf snow
Definition: color.h:1215
static Colorf honeydew
Definition: color.h:987
static Colorf deepskyblue
Definition: color.h:939
bool operator!=(const Color &c) const
Color != Color operator (deep compare)
Definition: color.h:129
static Colorf ghostwhite
Definition: color.h:966
static Colorf mediumaquamarine
Definition: color.h:1077
static Color lightpink
Definition: color.h:362
Floating point color description class (for float).
Definition: color.h:661
static Colorf aliceblue
Definition: color.h:816
static Color darkgoldenrod
Definition: color.h:209
static Color ghostwhite
Definition: color.h:290
static Color seashell
Definition: color.h:518
static Colorf papayawhip
Definition: color.h:1152
static Color lime
Definition: color.h:386
static Color indianred
Definition: color.h:317
static Colorf mintcream
Definition: color.h:1107
static Colorf purple
Definition: color.h:1170
static Color fuchsia
Definition: color.h:284
static Color darksalmon
Definition: color.h:239
static Colorf gray80
Definition: color.h:1266
static Colorf white
Definition: color.h:1245
void set_color(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255)
Set color based on rgba color components in the range 0-255.
Definition: color.h:633
unsigned int get_abgr8() const
Returns the color in ABGR8888 format.
Definition: color.h:112
static Color midnightblue
Definition: color.h:428
Colorf(const std::string &hexstr)
Constructs a color.
Definition: color.h:735
static Colorf lightgrey
Definition: color.h:1035
static Color olive
Definition: color.h:449
bool operator==(const Colorf &c) const
Color == Color operator (deep compare)
Definition: color.h:793
static Colorf indianred
Definition: color.h:993
static Colorf yellow
Definition: color.h:1251
static Color blanchedalmond
Definition: color.h:164
static Colorf mistyrose
Definition: color.h:1110
static Color aliceblue
Definition: color.h:140
static Color darkslategrey
Definition: color.h:251
static Color antiquewhite
Definition: color.h:143
static Color lightgrey
Definition: color.h:359
Colorf(unsigned char r, unsigned char g, unsigned char b, unsigned char a=255)
Constructs a color.
Definition: color.h:705
void set_green_f(float value)
Set green color component, in the range 0-1.
Definition: color.h:627
static Color gray40
Definition: color.h:586
static Colorf cyan
Definition: color.h:876
static Color lightgreen
Definition: color.h:356
static Colorf steelblue
Definition: color.h:1221
static Colorf gray70
Definition: color.h:1265
static Color papayawhip
Definition: color.h:476
static Color aquamarine
Definition: color.h:149
static Color darkred
Definition: color.h:236
static Color purple
Definition: color.h:494
static Color ivory
Definition: color.h:323
static Color lightseagreen
Definition: color.h:368
Color()
Constructs a color.
Definition: color.h:55
static Colorf yellowgreen
Definition: color.h:1254
unsigned char get_green() const
Returns the green color component, in the range 0-255.
Definition: color.h:91
static Color thistle
Definition: color.h:554
static Color gold
Definition: color.h:293
static Color lightgoldenrodyellow
Definition: color.h:350
static Color steelblue
Definition: color.h:545
static Color orangered
Definition: color.h:458
static Colorf whitesmoke
Definition: color.h:1248
static Colorf slategrey
Definition: color.h:1212
unsigned char get_blue() const
Returns the blue color component, in the range 0-255.
Definition: color.h:94
static Color palegoldenrod
Definition: color.h:464
static Color saddlebrown
Definition: color.h:506
static Colorf lavender
Definition: color.h:1005
static Color gray20
Definition: color.h:584
static Colorf darkkhaki
Definition: color.h:897
static Color khaki
Definition: color.h:326
static Color lightslategray
Definition: color.h:374
static Color mediumpurple
Definition: color.h:410
float get_blue() const
Get Blue.
Definition: color.h:759
void set_green(float value)
Set green color component, in the range 0-1.
Definition: color.h:787
static Color deepskyblue
Definition: color.h:263
static Color lavender
Definition: color.h:329
static Color navajowhite
Definition: color.h:440
static Color oldlace
Definition: color.h:446
static Color lavenderblush
Definition: color.h:332
static Colorf lightgray
Definition: color.h:1029
static Color gray10
Definition: color.h:583
unsigned char get_alpha() const
Returns the alpha color component, in the range 0-255.
Definition: color.h:85
static Color chartreuse
Definition: color.h:182
bool operator==(const Color &c) const
Color == Color operator (deep compare)
Definition: color.h:123
static Colorf mediumspringgreen
Definition: color.h:1095
static Color olivedrab
Definition: color.h:452
static Colorf turquoise
Definition: color.h:1236
static Color rosybrown
Definition: color.h:500
static Color mediumvioletred
Definition: color.h:425
static Colorf gold
Definition: color.h:969
static Color wheat
Definition: color.h:566
float get_alpha() const
Get Alpha.
Definition: color.h:764
static Colorf khaki
Definition: color.h:1002
static Colorf teal
Definition: color.h:1227
static Color gray60
Definition: color.h:588
static Colorf cornsilk
Definition: color.h:870
bool operator!=(const Colorf &c) const
Color != Color operator (deep compare)
Definition: color.h:799
static Color navy
Definition: color.h:443
static Colorf azure
Definition: color.h:828
static Colorf forestgreen
Definition: color.h:957
static Color darkorange
Definition: color.h:230
void set_red(unsigned char value)
Set red color component, in the range 0-255.
Definition: color.h:612
static Color lightyellow
Definition: color.h:383
static Colorf lightyellow
Definition: color.h:1059
unsigned char get_red() const
Returns the red color component, in the range 0-255.
Definition: color.h:88
static Color peachpuff
Definition: color.h:479
static Color lightsalmon
Definition: color.h:365
static Colorf sienna
Definition: color.h:1197
static Color red
Definition: color.h:497
static Colorf coral
Definition: color.h:864
static Colorf darkslategrey
Definition: color.h:927
static Colorf mediumorchid
Definition: color.h:1083
static Color lightcoral
Definition: color.h:344
static Colorf lightsalmon
Definition: color.h:1041
static Color slateblue
Definition: color.h:530
static Colorf seagreen
Definition: color.h:1191
static Colorf darkolivegreen
Definition: color.h:903
static Colorf ivory
Definition: color.h:999
Colorf()
Constructs a color.
Definition: color.h:668
static Color gray90
Definition: color.h:591
static Colorf gray60
Definition: color.h:1264
static Color mediumslateblue
Definition: color.h:416
static Color magenta
Definition: color.h:395
static Colorf gray50
Definition: color.h:1263
static Colorf paleturquoise
Definition: color.h:1146
static Color royalblue
Definition: color.h:503
static Colorf navy
Definition: color.h:1119
static Colorf salmon
Definition: color.h:1185
static Colorf gray40
Definition: color.h:1262
static Colorf lightcyan
Definition: color.h:1023
float get_green_f() const
Returns the green color component, in the range 0-1.
Definition: color.h:103
static Colorf chartreuse
Definition: color.h:858
static Colorf dimgrey
Definition: color.h:945
static Colorf antiquewhite
Definition: color.h:819
static Color silver
Definition: color.h:524
static Colorf tan
Definition: color.h:1224
static Colorf lightskyblue
Definition: color.h:1047
static Colorf orchid
Definition: color.h:1137
static Colorf mediumblue
Definition: color.h:1080
static Color cornsilk
Definition: color.h:194
Type a
Definition: vec4.h:84
static Colorf darkslateblue
Definition: color.h:921
static Colorf seashell
Definition: color.h:1194
static Color violet
Definition: color.h:563
static Color mediumseagreen
Definition: color.h:413
static Color darkviolet
Definition: color.h:257
static Color gray80
Definition: color.h:590
static Colorf lightpink
Definition: color.h:1038
Colorf(const float *array_rgba)
Constructs a color.
Definition: color.h:691
static Color tomato
Definition: color.h:557
static Color forestgreen
Definition: color.h:281
static Color yellowgreen
Definition: color.h:578
static Color cyan
Definition: color.h:200
void set_alpha_f(float value)
Set alpha color component, in the range 0-1.
Definition: color.h:621
static Color indigo
Definition: color.h:320
static Color moccasin
Definition: color.h:437
static Colorf tomato
Definition: color.h:1233
void set_red_f(float value)
Set red color component, in the range 0-1.
Definition: color.h:624
static Colorf gray
Definition: color.h:975
static Colorf royalblue
Definition: color.h:1179
static Colorf darkorange
Definition: color.h:906
static Colorf burlywood
Definition: color.h:852
static Color transparent
rgba(0, 0, 0, 0).
Definition: color.h:581
static Colorf darkgray
Definition: color.h:888
static Color bisque
Definition: color.h:158
static Colorf lightseagreen
Definition: color.h:1044
static Color peru
Definition: color.h:482
static Color palegreen
Definition: color.h:467
static Color cornflowerblue
Definition: color.h:191
static Color lightblue
Definition: color.h:341
Type r
Definition: vec4.h:81
static Color lightgray
Definition: color.h:353
static Color mintcream
Definition: color.h:431
static Color lawngreen
Definition: color.h:335
static Colorf silver
Definition: color.h:1200
static Color palevioletred
Definition: color.h:473
static Colorf darkslategray
Definition: color.h:924
static Color plum
Definition: color.h:488
static Color brown
Definition: color.h:173
static Colorf crimson
Definition: color.h:873
static Color gray
Definition: color.h:299
static Colorf moccasin
Definition: color.h:1113
static Colorf darkmagenta
Definition: color.h:900
static Colorf palevioletred
Definition: color.h:1149
static Colorf lightgreen
Definition: color.h:1032
static Colorf powderblue
Definition: color.h:1167
static Colorf darkviolet
Definition: color.h:933
static Color skyblue
Definition: color.h:527
float get_red_f() const
Returns the red color component, in the range 0-1.
Definition: color.h:100
static Colorf fuchsia
Definition: color.h:960
static Color firebrick
Definition: color.h:275
static Color mediumspringgreen
Definition: color.h:419
static Colorf darkgoldenrod
Definition: color.h:885
static Color sienna
Definition: color.h:521
Color(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255)
Constructs a color.
Definition: color.h:68
static Colorf bisque
Definition: color.h:834
static Colorf palegreen
Definition: color.h:1143
static Color orange
Definition: color.h:455
static Colorf lightslategray
Definition: color.h:1050
static Colorf orangered
Definition: color.h:1134
static Colorf lightblue
Definition: color.h:1017
static Color mistyrose
Definition: color.h:434
static Colorf maroon
Definition: color.h:1074
static Color seagreen
Definition: color.h:515
static Color salmon
Definition: color.h:509
float get_blue_f() const
Returns the blue color component, in the range 0-1.
Definition: color.h:106
static Color darkmagenta
Definition: color.h:224
void set_alpha(unsigned char value)
Set alpha color component, in the range 0-255.
Definition: color.h:609
float get_red() const
Get Red.
Definition: color.h:749
static Color lightsteelblue
Definition: color.h:380
static Color darkblue
Definition: color.h:203
static Colorf sandybrown
Definition: color.h:1188
static Color maroon
Definition: color.h:398
static Color coral
Definition: color.h:188
static Color honeydew
Definition: color.h:311
static Colorf gray10
Definition: color.h:1259
static Colorf mediumvioletred
Definition: color.h:1101
unsigned int get_bgra8() const
Returns the color in BGRA8888 format.
Definition: color.h:118
static Color darkslateblue
Definition: color.h:245
static Color teal
Definition: color.h:551
static Colorf darksalmon
Definition: color.h:915
static Color green
Definition: color.h:305
static Colorf grey
Definition: color.h:978
static Color lightskyblue
Definition: color.h:371
static Color gray70
Definition: color.h:589
static Colorf darkgreen
Definition: color.h:891
static Colorf dodgerblue
Definition: color.h:948
static Color paleturquoise
Definition: color.h:470
static Color yellow
Definition: color.h:575
static Colorf lime
Definition: color.h:1062
static Colorf plum
Definition: color.h:1164
static Colorf dimgray
Definition: color.h:942
static Color mediumaquamarine
Definition: color.h:401
static Colorf aquamarine
Definition: color.h:825
static Color powderblue
Definition: color.h:491
static Colorf linen
Definition: color.h:1068
static Colorf wheat
Definition: color.h:1242
static Color tan
Definition: color.h:548
unsigned int get_argb8() const
Returns the color in ARGB8888 format.
Definition: color.h:109
void set_blue_f(float value)
Set blue color component, in the range 0-1.
Definition: color.h:630
static Colorf floralwhite
Definition: color.h:954
static Color darkturquoise
Definition: color.h:254
static Colorf gray20
Definition: color.h:1260
static Colorf midnightblue
Definition: color.h:1104
static Colorf saddlebrown
Definition: color.h:1182
static Color darkkhaki
Definition: color.h:221
static Colorf violet
Definition: color.h:1239
static Color blueviolet
Definition: color.h:170
static Colorf lightsteelblue
Definition: color.h:1056
static Colorf deeppink
Definition: color.h:936
static Color aqua
Definition: color.h:146
static Colorf peru
Definition: color.h:1158
void set_green(unsigned char value)
Set green color component, in the range 0-255.
Definition: color.h:615
static Colorf aqua
Definition: color.h:822
static Colorf thistle
Definition: color.h:1230
static Colorf lavenderblush
Definition: color.h:1008
static Colorf magenta
Definition: color.h:1071
static Colorf gainsboro
Definition: color.h:963
static Color floralwhite
Definition: color.h:278
static Color darkorchid
Definition: color.h:233
Colorf(const Color &color)
Definition: color.h:724
unsigned int get_rgba8() const
Returns the color in RGBA8888 format.
Definition: color.h:115
static Color slategrey
Definition: color.h:536
static Color dodgerblue
Definition: color.h:272
static Colorf red
Definition: color.h:1173
static Colorf mediumpurple
Definition: color.h:1086
static Color darkgreen
Definition: color.h:215
static Colorf lightgoldenrodyellow
Definition: color.h:1026
float get_alpha_f() const
Returns the alpha color component, in the range 0-1.
Definition: color.h:97
static Color greenyellow
Definition: color.h:308
static Color beige
Definition: color.h:155
static Colorf greenyellow
Definition: color.h:984
static Colorf transparent
rgba(0, 0, 0, 0).
Definition: color.h:1257
static Colorf peachpuff
Definition: color.h:1155
static Colorf hotpink
Definition: color.h:990
static Color mediumturquoise
Definition: color.h:422
static Color blue
Definition: color.h:167
static Colorf navajowhite
Definition: color.h:1116
static Color cadetblue
Definition: color.h:179
void set_alpha(float value)
Set alpha color component, in the range 0-1.
Definition: color.h:781
static Colorf firebrick
Definition: color.h:951
static Colorf darkorchid
Definition: color.h:909
Colorf(int r, int g, int b, int a=255)
Constructs a color.
Definition: color.h:719
static Color white
Definition: color.h:569
static Color mediumorchid
Definition: color.h:407
static Color lightslategrey
Definition: color.h:377
static Colorf gray30
Definition: color.h:1261
static Colorf olivedrab
Definition: color.h:1128
static Color dimgrey
Definition: color.h:269
static Colorf black
Definition: color.h:837
static Colorf palegoldenrod
Definition: color.h:1140
static Color lightcyan
Definition: color.h:347
Type b
Definition: vec4.h:83
static Color darkseagreen
Definition: color.h:242
static Color slategray
Definition: color.h:533
void set_blue(float value)
Set blue color component, in the range 0-1.
Definition: color.h:790
static Color burlywood
Definition: color.h:176
static Colorf mediumturquoise
Definition: color.h:1098
static Color sandybrown
Definition: color.h:512
static Color hotpink
Definition: color.h:314
static Color goldenrod
Definition: color.h:296
static Color mediumblue
Definition: color.h:404
static Color darkgrey
Definition: color.h:218
static Color deeppink
Definition: color.h:260
static Colorf lightslategrey
Definition: color.h:1053
static Colorf mediumseagreen
Definition: color.h:1089
void set_red(float value)
Set red color component, in the range 0-1.
Definition: color.h:784
static Colorf lawngreen
Definition: color.h:1011
static Color orchid
Definition: color.h:461
static Color darkslategray
Definition: color.h:248
static Colorf springgreen
Definition: color.h:1218
static Colorf darkcyan
Definition: color.h:882
static Colorf orange
Definition: color.h:1131
4D vector
Definition: size.h:48
static Colorf chocolate
Definition: color.h:861
static Color crimson
Definition: color.h:197
static Colorf darkgrey
Definition: color.h:894
static Color darkcyan
Definition: color.h:206
static Colorf brown
Definition: color.h:849
static Colorf darkred
Definition: color.h:912
static Color whitesmoke
Definition: color.h:572
static Colorf darkblue
Definition: color.h:879
static Colorf slateblue
Definition: color.h:1206
static Colorf mediumslateblue
Definition: color.h:1092
static Colorf darkturquoise
Definition: color.h:930
static Color azure
Definition: color.h:152
static Color gainsboro
Definition: color.h:287
static Color grey
Definition: color.h:302
static Color limegreen
Definition: color.h:389
static Color darkolivegreen
Definition: color.h:227
static Colorf goldenrod
Definition: color.h:972
void normalize()
Normalize the color by ensuring that all color values lie inbetween (0.0, 1.0)
Definition: color.h:772
static Colorf indigo
Definition: color.h:996
static Colorf lemonchiffon
Definition: color.h:1014
static Colorf gray90
Definition: color.h:1267
Color description class.
Definition: color.h:47
static Color lemonchiffon
Definition: color.h:338
static Color gray50
Definition: color.h:587
static Colorf lightcoral
Definition: color.h:1020
static Color turquoise
Definition: color.h:560
static Color chocolate
Definition: color.h:185
static Colorf oldlace
Definition: color.h:1122
static Colorf limegreen
Definition: color.h:1065
static Color pink
Definition: color.h:485
static Colorf cornflowerblue
Definition: color.h:867
static Color darkgray
Definition: color.h:212
static Colorf darkseagreen
Definition: color.h:918
Colorf(float r, float g, float b, float a=1.0f)
Constructs a color.
Definition: color.h:681
static Color springgreen
Definition: color.h:542
Type g
Definition: vec4.h:82
static Color snow
Definition: color.h:539
static Colorf cadetblue
Definition: color.h:855
static Colorf blueviolet
Definition: color.h:846
static Colorf pink
Definition: color.h:1161
static Color find_color(const std::string &name)
Find and returns the static color matching a string.
static Colorf blue
Definition: color.h:843
void set_blue(unsigned char value)
Set blue color component, in the range 0-255.
Definition: color.h:618
static Colorf slategray
Definition: color.h:1209
static Colorf rosybrown
Definition: color.h:1176
static Colorf olive
Definition: color.h:1125
static Colorf blanchedalmond
Definition: color.h:840
static Color dimgray
Definition: color.h:266
float get_green() const
Get Green.
Definition: color.h:754