MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / _cc

Method _cc

Python/Turtle.py:2597–2610  ·  view source on GitHub ↗

Convert colortriples to hexstrings.

(self, args)

Source from the content-addressed store, hash-verified

2595 return self.screen._colorstr(args)
2596
2597 def _cc(self, args):
2598 """Convert colortriples to hexstrings.
2599 """
2600 if isinstance(args, str):
2601 return args
2602 try:
2603 r, g, b = args
2604 except (TypeError, ValueError):
2605 raise TurtleGraphicsError("bad color arguments: %s" % str(args))
2606 if self.screen._colormode == 1.0:
2607 r, g, b = [round(255.0*x) for x in (r, g, b)]
2608 if not ((0 <= r <= 255) and (0 <= g <= 255) and (0 <= b <= 255)):
2609 raise TurtleGraphicsError("bad color sequence: %s" % str(args))
2610 return "#%02x%02x%02x" % (r, g, b)
2611
2612 def clone(self):
2613 """Create and return a clone of the turtle.

Callers 2

_drawturtleMethod · 0.95
stampMethod · 0.95

Calls 1

TurtleGraphicsErrorClass · 0.85

Tested by

no test coverage detected