Mozilla2:GFXColor: Difference between revisions

No edit summary
mNo edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Color Class ==
== gfxColor 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.
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.
''Why should color parsing be done here, rather than in the code that gets the string?''--[[User:Biesi|Biesi]] 16:58, 25 Jun 2005 (PDT)


=== The API ===
=== The API ===
struct RGBA {
[http://lxr.mozilla.org/mozilla/source/gfx/thebes/public/gfxColor.h gfxColor.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 {
    }
};

Latest revision as of 23:58, 25 June 2005

gfxColor 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.

Why should color parsing be done here, rather than in the code that gets the string?--Biesi 16:58, 25 Jun 2005 (PDT)

The API

gfxColor.h