|
9 | 9 | class RGBA(collections.namedtuple('RGBA', ['red', 'green', 'blue', 'alpha'])): |
10 | 10 | """An RGBA color. |
11 | 11 |
|
12 | | - A tuple of four floats in the 0..1 range: ``(r, g, b, a)``. |
13 | | - Also has :attr:`red`, :attr:`green`, :attr:`blue` and :attr:`alpha` |
14 | | - attributes to access the same values. |
| 12 | + A tuple of four floats in the 0..1 range: ``(red, green, blue, alpha)``. |
| 13 | +
|
| 14 | + .. attribute:: red |
| 15 | +
|
| 16 | + Convenience access to the red channel. Same as ``rgba[0]``. |
| 17 | +
|
| 18 | + .. attribute:: green |
| 19 | +
|
| 20 | + Convenience access to the green channel. Same as ``rgba[1]``. |
| 21 | +
|
| 22 | + .. attribute:: blue |
| 23 | +
|
| 24 | + Convenience access to the blue channel. Same as ``rgba[2]``. |
| 25 | +
|
| 26 | + .. attribute:: alpha |
| 27 | +
|
| 28 | + Convenience access to the alpha channel. Same as ``rgba[3]``. |
15 | 29 |
|
16 | 30 | """ |
17 | | - type = 'rgba' |
18 | 31 |
|
19 | 32 |
|
20 | 33 | def parse_color(input): |
21 | 34 | """Parse a color value as defined in `CSS Color Level 3 |
22 | 35 | <http://www.w3.org/TR/css3-color/>`_. |
23 | 36 |
|
24 | | - :param token: |
| 37 | + :param input: |
25 | 38 | A :term:`string`, or a single :term:`component value`. |
26 | 39 | :returns: |
27 | | - * :obj:`None` if the token is not a valid CSS 3 color value. |
| 40 | + * :obj:`None` if the input is not a valid color value. |
28 | 41 | (No exception is raised.) |
29 | 42 | * The string ``'currentColor'`` for the *currentColor* keyword |
30 | 43 | * Or a :class:`RGBA` object for every other values |
31 | 44 | (including keywords, HSL and HSLA.) |
32 | | - The alpha channel is clipped to [0, 1], but R, G, or B can be |
33 | | - out of range (eg. ``rgb(-51, 306, 0)`` is represented as |
34 | | - ``(-.2, 1.2, 0, 1)``.) |
| 45 | + The alpha channel is clipped to [0, 1] |
| 46 | + but red, green, or blue can be out of range |
| 47 | + (eg. ``rgb(-10%, 120%, 0%)`` is represented as ``(-0.1, 1.2, 0, 1)``.) |
35 | 48 |
|
36 | 49 | """ |
37 | 50 | if isinstance(input, basestring): |
|
0 commit comments