This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
ideas:color-object [2014/07/07 16:20] – created tabatkins | ideas:color-object [2021/10/01 15:36] (current) – fantasai | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | [Constructor(double r, double g, double b, optional double a=1)] | + | < |
- | interface RGBAColor { | + | This has been superseded by work on a common color API for the Web Platform and by work on Typed OM for manipulating CSS syntax specifically. |
- | attribute double r; | + | </ |
- | attribute double g; | + | |
- | attribute double b; | + | |
- | attribute double | + | |
- | + | ||
- | HSLAColor asHSL(); | + | |
- | HexColor asHex(); | + | |
- | + | ||
- | static RGBAColor fromHSLA(double h, double s, double l, optional double a=1); | + | |
- | static RGBAColor fromHex(octet r, octet g, octet b, optional octet a=255); | + | |
- | + | ||
- | stringifier DOMString (optional DOMString type=" | + | |
- | static readonly attribute Map serializationTypes; | + | |
- | }; | + | |
- | The stringifier looks up the type in the RGBAColor.serializationTypes Map; if it finds a function, it calls that with the RGBAColor | + | <code idl> |
+ | [Constructor(double r, double g, double b, optional double a=1), | ||
+ | | ||
+ | interface | ||
+ | attribute double r; | ||
+ | attribute double g; | ||
+ | attribute double b; | ||
+ | attribute double | ||
+ | |||
+ | HSLAColorInit asHSL(); | ||
+ | static | ||
+ | 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="rgba"); | ||
+ | static readonly attribute Map serializationTypes; | ||
+ | }; | ||
+ | </ | ||
- | Authors can define their own color formats by adding a fromFoo() to RGBAColor, a toFoo() to RGBAColor.prototype, and adding an appropriate serialization tag to RGBAColor.serializationTypes. | + | The '' |
- | dictionary HSLAColor { | + | Authors can define their own color formats by adding |
- | double h; | + | |
- | double s; | + | |
- | double l; | + | |
- | double | + | |
- | }; | + | |
- | dictionary | + | <code idl> |
- | octet r; | + | |
- | octet g; | + | double r = 0; |
- | octet b; | + | double g = 0; |
- | octet a; | + | double b = 0; |
- | }; | + | double a = 1; |
+ | | ||
+ | |||
+ | dictionary HSLAColorInit { | ||
+ | double h = 0; | ||
+ | double s = 1; | ||
+ | double l = .5; | ||
+ | double a = 1; | ||
+ | }; | ||
+ | |||
+ | dictionary HexColorInit { | ||
+ | | ||
+ | octet g = 0; | ||
+ | octet b = 0; | ||
+ | octet a = 255; | ||
+ | }; | ||
+ | |||
+ | partial interface CSS { | ||
+ | RGBAColor parseColor(DOMString color, optional Element el); | ||
+ | }; | ||
+ | </ | ||
- | partial interface CSS { | + | '' |
- | CSSColor | + | |
- | }; | + | |
- | If parseColor | + | The optional second argument |
- | such as '' | + | |
- | but no el argument | + | |
- | throw a XXX error. | + |