This shows you the differences between two versions of the page.
Next revision | Previous revisionLast revisionBoth sides next revision | ||
ideas:color-object [2014/07/07 16:20] – created tabatkins | ideas:color-object [2014/12/09 15:48] – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | [Constructor(double r, double g, double b, optional double a=1)] | + | <code idl> |
- | interface RGBAColor { | + | |
- | attribute double r; | + | |
- | attribute double g; | + | interface RGBAColor { |
- | attribute double b; | + | attribute double r; |
- | attribute double a; | + | attribute double g; |
+ | attribute double b; | ||
+ | attribute double a; | ||
+ | |||
+ | HSLAColorInit asHSL(); | ||
+ | static RGBAColor fromHSLA(double h, double s, double l, optional double a=1); | ||
+ | static RGBAColor fromHSLA(optional HSLAColorInit color); | ||
+ | |||
+ | HexColorInit asHex(); | ||
+ | static RGBAColor fromHex(octet r, octet g, octet b, optional octet a=255); | ||
+ | static RGBAColor fromHex(optional HexColorInit color); | ||
+ | |||
+ | DOMString? asName(); | ||
+ | |||
+ | DOMString toString(optional DOMString type=" | ||
+ | static readonly attribute Map serializationTypes; | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | The '' | ||
+ | |||
+ | Authors can define their own color formats by adding a '' | ||
+ | |||
+ | <code idl> | ||
+ | dictionary RGBAColorInit { | ||
+ | double r = 0; | ||
+ | double g = 0; | ||
+ | double b = 0; | ||
+ | double a = 1; | ||
+ | }; | ||
| | ||
- | | + | |
- | | + | double h = 0; |
+ | double s = 1; | ||
+ | double l = .5; | ||
+ | double a = 1; | ||
+ | | ||
| | ||
- | | + | |
- | | + | octet r = 0; |
+ | octet g = 0; | ||
+ | | ||
+ | | ||
+ | }; | ||
| | ||
- | | + | |
- | static readonly attribute Map serializationTypes; | + | RGBAColor parseColor(DOMString color, |
- | }; | + | }; |
- | + | </ | |
- | The stringifier 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. | + | |
- | + | ||
- | Authors can define their own color formats by adding a fromFoo() to RGBAColor, a toFoo() to RGBAColor.prototype, | + | |
- | + | ||
- | dictionary HSLAColor { | + | |
- | double h; | + | |
- | | + | |
- | double l; | + | |
- | double a; | + | |
- | }; | + | |
- | + | ||
- | dictionary HexColor { | + | |
- | octet r; | + | |
- | octet g; | + | |
- | octet b; | + | |
- | octet a; | + | |
- | }; | + | |
- | partial interface CSS { | + | '' |
- | CSSColor | + | |
- | }; | + | |
- | If parseColor | + | The optional second argument |
- | such as '' | + | |
- | but no el argument | + | |
- | throw a XXX error. | + |