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

Method teleport

Lib/turtle.py:2797–2843  ·  view source on GitHub ↗

Instantly move turtle to an absolute position. Arguments: x -- a number or None y -- a number None fill_gap -- a boolean This argument must be specified by name. call: teleport(x, y) # two coordinates --or: teleport(x

(self, x=None, y=None, *, fill_gap: bool = False)

Source from the content-addressed store, hash-verified

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.
2799
2800 Arguments:
2801 x -- a number or None
2802 y -- a number None
2803 fill_gap -- a boolean This argument must be specified by name.
2804
2805 call: teleport(x, y) # two coordinates
2806 --or: teleport(x) # teleport to x position, keeping y as is
2807 --or: teleport(y=y) # teleport to y position, keeping x as is
2808 --or: teleport(x, y, fill_gap=True)
2809 # teleport but fill the gap in between
2810
2811 Move turtle to an absolute position. Unlike goto(x, y), a line will not
2812 be drawn. The turtle's orientation does not change. If currently
2813 filling, the polygon(s) teleported from will be filled after leaving,
2814 and filling will begin again after teleporting. This can be disabled
2815 with fill_gap=True, which makes the imaginary line traveled during
2816 teleporting act as a fill barrier like in goto(x, y).
2817
2818 Example (for a Turtle instance named turtle):
2819 >>> tp = turtle.pos()
2820 >>> tp
2821 (0.00,0.00)
2822 >>> turtle.teleport(60)
2823 >>> turtle.pos()
2824 (60.00,0.00)
2825 >>> turtle.teleport(y=10)
2826 >>> turtle.pos()
2827 (60.00,10.00)
2828 >>> turtle.teleport(20, 30)
2829 >>> turtle.pos()
2830 (20.00,30.00)
2831 """
2832 pendown = self.isdown()
2833 was_filling = self.filling()
2834 if pendown:
2835 self.pen(pendown=False)
2836 if was_filling and not fill_gap:
2837 self.end_fill()
2838 new_x = x if x is not None else self._position[0]
2839 new_y = y if y is not None else self._position[1]
2840 self._position = Vec2D(new_x, new_y)
2841 self.pen(pendown=pendown)
2842 if was_filling and not fill_gap:
2843 self.begin_fill()
2844
2845 def clone(self):
2846 """Create and return a clone of the turtle.

Callers

nothing calls this directly

Calls 6

fillingMethod · 0.95
end_fillMethod · 0.95
begin_fillMethod · 0.95
isdownMethod · 0.80
penMethod · 0.80
Vec2DClass · 0.70

Tested by

no test coverage detected