MCPcopy Index your code
hub / github.com/python/cpython / _color

Method _color

Lib/turtle.py:1161–1170  ·  view source on GitHub ↗
(self, cstr)

Source from the content-addressed store, hash-verified

1159 return "#%02x%02x%02x" % (r, g, b)
1160
1161 def _color(self, cstr):
1162 if not cstr.startswith("#"):
1163 return cstr
1164 if len(cstr) == 7:
1165 cl = [int(cstr[i:i+2], 16) for i in (1, 3, 5)]
1166 elif len(cstr) == 4:
1167 cl = [16*int(cstr[h], 16) for h in cstr[1:]]
1168 else:
1169 raise TurtleGraphicsError("bad colorstring: %s" % cstr)
1170 return tuple(c * self._colormode/255 for c in cl)
1171
1172 def colormode(self, cmode=None):
1173 """Return the colormode or set it to 1.0 or 255.

Callers 1

bgcolorMethod · 0.95

Calls 2

TurtleGraphicsErrorClass · 0.85
startswithMethod · 0.45

Tested by

no test coverage detected