17 #define _ucolor_hpp_ 1 19 #include <ubit/uattr.hpp> 26 URgba() {comps[0] = comps[1] = comps[2] = 0; comps[3] = 255u;}
28 URgba(
unsigned int r,
unsigned int g,
unsigned int b,
unsigned int a = 255u)
29 {comps[0] = r; comps[1] = g; comps[2] = b; comps[3] = a;}
31 URgba(
float r,
float g,
float b,
float a = 1.0f) {setRgbaF(r,g,b,a);}
33 void setRgbaI(
unsigned int r,
unsigned int g,
unsigned int b,
unsigned int a = 255u)
34 {comps[0] = r; comps[1] = g; comps[2] = b; comps[3] = a;}
36 void setRgbaF(
float r,
float g,
float b,
float a = 1.0f);
38 bool operator==(
const URgba& c)
const {
39 return (comps[0]==c.comps[0] && comps[1]==c.comps[1]
40 && comps[2]==c.comps[2] && comps[3]==c.comps[3]);
48 unsigned int getRedI()
const {
return comps[0];}
49 unsigned int getGreenI()
const {
return comps[1];}
50 unsigned int getBlueI()
const {
return comps[2];}
51 unsigned int getAlphaI()
const {
return comps[3];}
53 void setRedI(
unsigned int c) {comps[0] = c;}
54 void setGreenI(
unsigned int c) {comps[1] = c;}
55 void setBlueI(
unsigned int c) {comps[2] = c;}
56 void setAlphaI(
unsigned int c) {comps[3] = c;}
58 unsigned char comps[4];
77 static
UColor none, inherit, white, black, grey, lightgrey, darkgrey,
78 navy, lightblue, blue, red, green, yellow, orange, wheat, teal, disabled;
99 UColor(
float r,
float g,
float b,
float a = 1.0f);
105 UColor(
unsigned int r,
unsigned int g,
unsigned int b,
unsigned int a = 255u);
119 UColor& setRgba(const URgba&);
122 UColor& setRgbaF(
float r,
float g,
float b,
float a = 1.0f);
125 UColor& setRgbaI(
unsigned int r,
unsigned int g,
unsigned int b,
unsigned int a=255u);
128 UColor& setNamedColor(const
UStr& color_name,
float a = 1.);
137 const URgba& getRgba()
const {
return rgba;}
139 bool operator==(
const UColor& c)
const {
return equals(c);}
140 bool operator!=(
const UColor& c)
const {
return !equals(c);}
142 virtual bool equals(
const UColor&)
const;
143 virtual bool equals(
const URgba&)
const;
144 virtual bool equals(
float r,
float g,
float b,
float a)
const;
145 virtual bool equals(
unsigned int r,
unsigned int g,
unsigned int b,
unsigned int a)
const;
147 virtual void update();
151 static void addNamedColor(
const char* name,
const URgba&);
154 static bool parseColor(
const char* name,
URgba&);
163 mutable std::vector<unsigned long> pixels;
165 unsigned long getPixel(
UDisp*)
const;
167 UColor(
unsigned int r,
unsigned int g,
unsigned int b,
unsigned int a,
UConst);
180 inline UColor& ucolor(
float r,
float g,
float b,
float a = 1.)
181 {
return *
new UColor(r,g,b,a);}
184 inline UColor& ucolor(
unsigned int r,
unsigned int g,
unsigned int b,
unsigned int a = 255)
185 {
return *
new UColor(r,g,b,a);}
188 inline UColor& ucolor(
const UStr& color_name,
float alpha = 1.)
189 {
return *
new UColor(color_name, alpha);}
Base class for attributes.
Definition: uattr.hpp:97
Definition: uobject.hpp:282
class for drawing on widgets.
Definition: ugraph.hpp:44
Display Context.
Definition: udisp.hpp:44
Color attribute of an element or a widget.
Definition: ucolor.hpp:73
Specifies a RGBA value for defining UColor(s).
Definition: ucolor.hpp:24
lightweight general purpose container.
Definition: uelem.hpp:44
Definition: uupdatecontext.hpp:32
Definition: uhardfont.hpp:31
Ubit String.
Definition: ustr.hpp:72