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)
| 1809 | |
| 1810 | |
| 1811 | def goto(self, x, y=None): |
| 1812 | """Move turtle to an absolute position. |
| 1813 | |
| 1814 | Aliases: setpos | setposition | goto: |
| 1815 | |
| 1816 | Arguments: |
| 1817 | x -- a number or a pair/vector of numbers |
| 1818 | y -- a number None |
| 1819 | |
| 1820 | call: goto(x, y) # two coordinates |
| 1821 | --or: goto((x, y)) # a pair (tuple) of coordinates |
| 1822 | --or: goto(vec) # e.g. as returned by pos() |
| 1823 | |
| 1824 | Move turtle to an absolute position. If the pen is down, |
| 1825 | a line will be drawn. The turtle's orientation does not change. |
| 1826 | |
| 1827 | Example (for a Turtle instance named turtle): |
| 1828 | >>> tp = turtle.pos() |
| 1829 | >>> tp |
| 1830 | (0.00,0.00) |
| 1831 | >>> turtle.setpos(60,30) |
| 1832 | >>> turtle.pos() |
| 1833 | (60.00,30.00) |
| 1834 | >>> turtle.setpos((20,80)) |
| 1835 | >>> turtle.pos() |
| 1836 | (20.00,80.00) |
| 1837 | >>> turtle.setpos(tp) |
| 1838 | >>> turtle.pos() |
| 1839 | (0.00,0.00) |
| 1840 | """ |
| 1841 | if y is None: |
| 1842 | self._goto(Vec2D(*x)) |
| 1843 | else: |
| 1844 | self._goto(Vec2D(x, y)) |
| 1845 | |
| 1846 | def home(self): |
| 1847 | """Move turtle to the origin - coordinates (0,0). |