@@ -90,20 +90,17 @@ def __delitem__(self, key):
90
90
91
91
92
92
def 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."""
95
94
return _colors_full_map
96
95
97
96
98
97
def _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."""
101
99
return isinstance (c , six .string_types ) and re .match (r"\AC[0-9]\Z" , c )
102
100
103
101
104
102
def 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."""
107
104
# Special-case nth color syntax because it cannot be parsed during
108
105
# setup.
109
106
if _is_nth_color (c ):
@@ -117,10 +114,10 @@ def is_color_like(c):
117
114
118
115
119
116
def to_rgba (c , alpha = None ):
120
- """Convert `c` to an RGBA color.
117
+ """Convert *c* to an RGBA color.
121
118
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)` `.
124
121
"""
125
122
# Special-case nth color syntax because it should not be cached.
126
123
if _is_nth_color (c ):
@@ -140,10 +137,10 @@ def to_rgba(c, alpha=None):
140
137
141
138
142
139
def _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.
144
141
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)` `.
147
144
"""
148
145
orig_c = c
149
146
if isinstance (c , six .string_types ):
@@ -197,10 +194,10 @@ def _to_rgba_no_colorcycle(c, alpha=None):
197
194
198
195
199
196
def 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.
201
198
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.
204
201
"""
205
202
# Special-case inputs that are already arrays, for performance. (If the
206
203
# 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):
235
232
236
233
237
234
def 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."""
240
236
return to_rgba (c )[:3 ]
241
237
242
238
243
239
def to_hex (c , keep_alpha = False ):
244
- """Convert `c` to a hex color.
240
+ """Convert *c* to a hex color.
245
241
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.
248
244
"""
249
245
c = to_rgba (c )
250
246
if not keep_alpha :
0 commit comments