@@ -90,20 +90,17 @@ def __delitem__(self, key):
9090
9191
9292def get_named_colors_mapping ():
93- """Return the global mapping of names to named colors.
94- """
93+ """Return the global mapping of names to named colors."""
9594 return _colors_full_map
9695
9796
9897def _is_nth_color (c ):
99- """Return whether `c` can be interpreted as an item in the color cycle.
100- """
98+ """Return whether *c* can be interpreted as an item in the color cycle."""
10199 return isinstance (c , six .string_types ) and re .match (r"\AC[0-9]\Z" , c )
102100
103101
104102def is_color_like (c ):
105- """Return whether `c` can be interpreted as an RGB(A) color.
106- """
103+ """Return whether *c* can be interpreted as an RGB(A) color."""
107104 # Special-case nth color syntax because it cannot be parsed during
108105 # setup.
109106 if _is_nth_color (c ):
@@ -117,10 +114,10 @@ def is_color_like(c):
117114
118115
119116def to_rgba (c , alpha = None ):
120- """Convert `c` to an RGBA color.
117+ """Convert *c* to an RGBA color.
121118
122- If ` alpha` is not ` None` , it forces the alpha value, except if `c` is
123- "none" (case-insensitive), which always maps to `(0, 0, 0, 0)`.
119+ If * alpha* is not * None* , it forces the alpha value, except if *c* is
120+ `` "none"`` (case-insensitive), which always maps to `` (0, 0, 0, 0)` `.
124121 """
125122 # Special-case nth color syntax because it should not be cached.
126123 if _is_nth_color (c ):
@@ -140,10 +137,10 @@ def to_rgba(c, alpha=None):
140137
141138
142139def _to_rgba_no_colorcycle (c , alpha = None ):
143- """Convert `c` to an RGBA color, with no support for color-cycle syntax.
140+ """Convert *c* to an RGBA color, with no support for color-cycle syntax.
144141
145- If ` alpha` is not `None`, it forces the alpha value, except if `c` is
146- "none" (case-insensitive), which always maps to `(0, 0, 0, 0)`.
142+ If * alpha* is not `` None`` , it forces the alpha value, except if *c* is
143+ `` "none"`` (case-insensitive), which always maps to `` (0, 0, 0, 0)` `.
147144 """
148145 orig_c = c
149146 if isinstance (c , six .string_types ):
@@ -197,10 +194,10 @@ def _to_rgba_no_colorcycle(c, alpha=None):
197194
198195
199196def to_rgba_array (c , alpha = None ):
200- """Convert `c` to a (n, 4) array of RGBA colors.
197+ """Convert *c* to a (n, 4) array of RGBA colors.
201198
202- If ` alpha` is not `None`, it forces the alpha value. If `c` is "none"
203- (case-insensitive) or an empty list, an empty array is returned.
199+ If * alpha* is not `` None`` , it forces the alpha value. If *c* is
200+ ``"none"`` (case-insensitive) or an empty list, an empty array is returned.
204201 """
205202 # Special-case inputs that are already arrays, for performance. (If the
206203 # array has the wrong kind or shape, raise the error during one-at-a-time
@@ -235,16 +232,15 @@ def to_rgba_array(c, alpha=None):
235232
236233
237234def to_rgb (c ):
238- """Convert `c` to an RGB color, silently dropping the alpha channel.
239- """
235+ """Convert *c* to an RGB color, silently dropping the alpha channel."""
240236 return to_rgba (c )[:3 ]
241237
242238
243239def to_hex (c , keep_alpha = False ):
244- """Convert `c` to a hex color.
240+ """Convert *c* to a hex color.
245241
246- Uses the #rrggbb format if ` keep_alpha` is False (the default), `#rrggbbaa`
247- otherwise.
242+ Uses the `` #rrggbb`` format if * keep_alpha* is False (the default),
243+ ``#rrggbbaa`` otherwise.
248244 """
249245 c = to_rgba (c )
250246 if not keep_alpha :
0 commit comments