Mozilla2:GFXColor: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
No edit summary
Line 3: Line 3:


=== The API ===
=== The API ===
struct RGBA {
[http://www.pavlov.net/projects/thebes/public/Color.h Color.h]
    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 {
    }
};

Revision as of 00:10, 2 April 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

Color.h