Mozilla2:GFXColor: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
mNo edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== The Class ==
== gfxColor Class ==
struct RGBA {
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.
    double r, g, b, a;
 
   
''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)
    RGBA() { }
 
    RGBA(const RGBA& c) : r(c.r), g(c.g), b(c.b), a(c.a) {}
=== The API ===
    RGBA(double _r, double _g, double _b, double _a=1.0) :
[http://lxr.mozilla.org/mozilla/source/gfx/thebes/public/gfxColor.h gfxColor.h]
        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