Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
ideas:color-object [2014/07/07 16:20] – created tabatkinsideas:color-object [2021/10/01 15:36] (current) fantasai
Line 1: Line 1:
-[Constructor(double r, double g, double b, optional double a=1)] +<note> 
-interface RGBAColor { +This has been superseded by work on common color API for the Web Platform and by work on Typed OM for manipulating CSS syntax specifically. 
-  attribute double r; +</note>
-  attribute double g; +
-  attribute double b; +
-  attribute double a+
-   +
-  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="rgba"); +
-  static readonly attribute Map serializationTypes; +
-};+
  
-The stringifier looks up the type in the RGBAColor.serializationTypes Mapif it finds function, it calls that with the RGBAColor as the sole argument and returns whatever the function returns.  It'preloaded with UA-defined functions for "hex3""hex6""rgb""rgba""hsl"and "hsla"+<code idl> 
 +  [Constructor(double r, double g, double b, optional double a=1), 
 +   Constructor(RGBAColorInit color)] 
 +  interface RGBAColor 
 +    attribute double r; 
 +    attribute double g; 
 +    attribute double b; 
 +    attribute double a
 +     
 +    HSLAColorInit asHSL(); 
 +    static RGBAColor fromHSLA(double h, double s, double loptional double a=1); 
 +    static RGBAColor fromHSLA(optional HSLAColorInit color); 
 +     
 +    HexColorInit asHex(); 
 +    static RGBAColor fromHex(octet roctet goctet boptional octet a=255); 
 +    static RGBAColor fromHex(optional HexColorInit color); 
 +     
 +    DOMString? asName(); 
 +     
 +    DOMString toString(optional DOMString type="rgba"); 
 +    static readonly attribute Map serializationTypes; 
 +  }; 
 +</code>
  
-Authors can define their own color formats by adding a fromFoo() to RGBAColortoFoo() to RGBAColor.prototype, and adding an appropriate serialization tag to RGBAColor.serializationTypes.+The ''toString()'' method looks up the type in the ''RGBAColor.serializationTypes Map''; if it finds function, it calls that with the ''RGBAColor'' as the sole argument and returns whatever the function returns It's preloaded with UA-defined functions for "hex3", "hex6", "rgb", "rgba", "hsl", and "hsla"
  
-dictionary HSLAColor { +Authors can define their own color formats by adding ''fromFoo()'' to ''RGBAColor'', a ''toFoo()'' to ''RGBAColor.prototype'', and adding an appropriate serialization tag to ''RGBAColor.serializationTypes''.
-  double h; +
-  double s; +
-  double l; +
-  double a+
-};+
  
-dictionary HexColor +<code idl> 
-  octet r; +  dictionary RGBAColorInit { 
-  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 r = 0
 +    octet g = 0
 +    octet b = 0
 +    octet a = 255
 +  }; 
 +   
 +  partial interface CSS { 
 +    RGBAColor parseColor(DOMString color, optional Element el); 
 +  }; 
 +</code>
  
-partial interface CSS { +''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.
- CSSColor parseColor(DOMString color, optional Element el); +
-};+
  
-If parseColor is called with a color that depends on the element on which it is used, +The optional second argument is used to resolve colors that vary based on the element, such as ''currentcolor''.  If such a color is parsed but the second argument is not provided, throw a XXX exception.
-such as ''currentcolor'' or ''inherit'', +
-but no el argument was passed, +
-throw a XXX error.+
 
ideas/color-object.1404775258.txt.gz · Last modified: 2014/12/09 15:48 (external edit)
Recent changes RSS feed Valid XHTML 1.0 Valid CSS Driven by DokuWiki