MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / clone

Method clone

tools/python-3.11.9-amd64/Lib/turtle.py:2714–2752  ·  view source on GitHub ↗

Create and return a clone of the turtle. No argument. Create and return a clone of the turtle with same position, heading and turtle properties. Example (for a Turtle instance named mick): mick = Turtle() joe = mick.clone()

(self)

Source from the content-addressed store, hash-verified

2712 return "#%02x%02x%02x" % (r, g, b)
2713
2714 def clone(self):
2715 """Create and return a clone of the turtle.
2716
2717 No argument.
2718
2719 Create and return a clone of the turtle with same position, heading
2720 and turtle properties.
2721
2722 Example (for a Turtle instance named mick):
2723 mick = Turtle()
2724 joe = mick.clone()
2725 """
2726 screen = self.screen
2727 self._newLine(self._drawing)
2728
2729 turtle = self.turtle
2730 self.screen = None
2731 self.turtle = None # too make self deepcopy-able
2732
2733 q = deepcopy(self)
2734
2735 self.screen = screen
2736 self.turtle = turtle
2737
2738 q.screen = screen
2739 q.turtle = _TurtleImage(screen, self.turtle.shapeIndex)
2740
2741 screen._turtles.append(q)
2742 ttype = screen._shapes[self.turtle.shapeIndex]._type
2743 if ttype == "polygon":
2744 q.turtle._item = screen._createpoly()
2745 elif ttype == "image":
2746 q.turtle._item = screen._createimage(screen._shapes["blank"]._data)
2747 elif ttype == "compound":
2748 q.turtle._item = [screen._createpoly() for item in
2749 screen._shapes[self.turtle.shapeIndex]._data]
2750 q.currentLineItem = screen._createline()
2751 q._update()
2752 return q
2753
2754 def shape(self, name=None):
2755 """Set turtle shape to shape with given name / return current shapename.

Callers

nothing calls this directly

Calls 8

_newLineMethod · 0.95
deepcopyFunction · 0.90
_TurtleImageClass · 0.85
_createpolyMethod · 0.80
_createimageMethod · 0.80
_createlineMethod · 0.80
appendMethod · 0.45
_updateMethod · 0.45

Tested by

no test coverage detected