This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
ideas:color-object [2014/07/09 19:25] – Add asKeyword(). tabatkins | ideas:color-object [2014/07/11 12:07] – Switch "asKeyword" to "asName", invoking "named colors" more explicitly. tabatkins | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <code idl> | ||
[Constructor(double r, double g, double b, optional double a=1), | [Constructor(double r, double g, double b, optional double a=1), | ||
| | ||
Line 15: | Line 16: | ||
static RGBAColor fromHex(optional HexColorInit color); | static RGBAColor fromHex(optional HexColorInit color); | ||
| | ||
- | DOMString? | + | DOMString? |
- | /* Add fromKeyword()? | + | |
| | ||
DOMString toString(optional DOMString type=" | DOMString toString(optional DOMString type=" | ||
static readonly attribute Map serializationTypes; | static readonly attribute Map serializationTypes; | ||
}; | }; | ||
+ | </ | ||
- | The toString() method looks up the type in the RGBAColor.serializationTypes Map; if it finds a function, it calls that with the RGBAColor as the sole argument and returns whatever the function returns. | + | The '' |
- | Authors can define their own color formats by adding a fromFoo() to RGBAColor, a toFoo() to RGBAColor.prototype, | + | Authors can define their own color formats by adding a '' |
+ | <code idl> | ||
dictionary RGBAColorInit { | dictionary RGBAColorInit { | ||
double r = 0; | double r = 0; | ||
Line 50: | Line 52: | ||
RGBAColor parseColor(DOMString color, optional Element el); | RGBAColor parseColor(DOMString color, optional Element el); | ||
}; | }; | ||
+ | </ | ||
- | parseColor() takes a string containing any CSS color, and returns an RGBAColor for it. If the string isn't parseable as a color, throw a SyntaxError exception. | + | '' |
The optional second argument is used to resolve colors that vary based on the element, such as '' | The optional second argument is used to resolve colors that vary based on the element, such as '' |