Move turtle to an absolute position. Aliases: setpos | setposition | goto: Arguments: x -- a number or a pair/vector of numbers y -- a number None call: goto(x, y) # two coordinates --or: goto((x, y)) # a pair (tup
(self, x, y=None)
| 1640 | |
| 1641 | |
| 1642 | def goto(self, x, y=None): |
| 1643 | """Move turtle to an absolute position. |
| 1644 | |
| 1645 | Aliases: setpos | setposition | goto: |
| 1646 | |
| 1647 | Arguments: |
| 1648 | x -- a number or a pair/vector of numbers |
| 1649 | y -- a number None |
| 1650 | |
| 1651 | call: goto(x, y) # two coordinates |
| 1652 | --or: goto((x, y)) # a pair (tuple) of coordinates |
| 1653 | --or: goto(vec) # e.g. as returned by pos() |
| 1654 | |
| 1655 | Move turtle to an absolute position. If the pen is down, |
| 1656 | a line will be drawn. The turtle's orientation does not change. |
| 1657 | |
| 1658 | Example (for a Turtle instance named turtle): |
| 1659 | >>> tp = turtle.pos() |
| 1660 | >>> tp |
| 1661 | (0.00, 0.00) |
| 1662 | >>> turtle.setpos(60,30) |
| 1663 | >>> turtle.pos() |
| 1664 | (60.00,30.00) |
| 1665 | >>> turtle.setpos((20,80)) |
| 1666 | >>> turtle.pos() |
| 1667 | (20.00,80.00) |
| 1668 | >>> turtle.setpos(tp) |
| 1669 | >>> turtle.pos() |
| 1670 | (0.00,0.00) |
| 1671 | """ |
| 1672 | if y is None: |
| 1673 | self._goto(Vec2D(*x)) |
| 1674 | else: |
| 1675 | self._goto(Vec2D(x, y)) |
| 1676 | |
| 1677 | def home(self): |
| 1678 | """Move turtle to the origin - coordinates (0,0). |