(self, cstr)
| 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. |
no test coverage detected