Mozilla2:GFXColor: Difference between revisions
Jump to navigation
Jump to search
m (→The Class) |
No edit summary |
||
Line 1: | Line 1: | ||
== The | == Color Class == | ||
We should be using RGBA colors all over the tree. It needs to be able to accept packed uint32 colors (nscolor) that we currently use as well as accept strings of hex colors or named colors. | |||
=== The API === | |||
struct RGBA { | struct RGBA { | ||
double r, g, b, a; | double r, g, b, a; |
Revision as of 21:51, 12 March 2005
Color Class
We should be using RGBA colors all over the tree. It needs to be able to accept packed uint32 colors (nscolor) that we currently use as well as accept strings of hex colors or named colors.
The API
struct RGBA { double r, g, b, a; RGBA() { } RGBA(const RGBA& c) : r(c.r), g(c.g), b(c.b), a(c.a) {} RGBA(double _r, double _g, double _b, double _a=1.0) : r(_r), g(_g), b(_b), a(_a) {} RGBA(unsigned long c) { a = (c & 0xff) / 255.0; r = ((c >> 8) & 0xff) / 255.0; g = ((c >> 16) & 0xff) / 255.0; b = ((c >> 24) & 0xff) / 255.0; } RGBA(const nsAString& str) { a = 1.0; // if aString[0] is a #, parse it as hex // if aString[0] is a letter, parse it as a color name // if aString[0] is a number, parse it loosely as hex } const nsAString& hex() const { } };