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

Method _cc

Lib/turtle.py:2782–2795  ·  view source on GitHub ↗

Convert colortriples to hexstrings.

(self, args)

Source from the content-addressed store, hash-verified

2780 return self.screen._colorstr(args)
2781
2782 def _cc(self, args):
2783 """Convert colortriples to hexstrings.
2784 """
2785 if isinstance(args, str):
2786 return args
2787 try:
2788 r, g, b = args
2789 except (TypeError, ValueError):
2790 raise TurtleGraphicsError("bad color arguments: %s" % str(args))
2791 if self.screen._colormode == 1.0:
2792 r, g, b = [round(255.0*x) for x in (r, g, b)]
2793 if not ((0 <= r <= 255) and (0 <= g <= 255) and (0 <= b <= 255)):
2794 raise TurtleGraphicsError("bad color sequence: %s" % str(args))
2795 return "#%02x%02x%02x" % (r, g, b)
2796
2797 def teleport(self, x=None, y=None, *, fill_gap: bool = False) -> None:
2798 """Instantly move turtle to an absolute position.

Callers 2

_drawturtleMethod · 0.95
stampMethod · 0.95

Calls 2

TurtleGraphicsErrorClass · 0.85
strFunction · 0.85

Tested by

no test coverage detected