Category: Turtle
Moves the turtle to a specific (x,y) position on the screen.
Use moveTo(x,y) when drawing a picture where parts of the picture need to be at very specific positions on the screen. Unlike move(x,y), which moves the turtle relative to it's current position, moveTo(x,y) moves the turtle to an absolute position on the screen. The direction that the turtle is facing remains unchanged.
// Move the turtle near the top, left of the screen. moveTo(50, 50);
Example: Square Draw a square by connecting the four corners in counterclockwise order.
// Draw a square by connecting the four corners in counterclockwise order. penUp(); moveTo(50, 50); penDown(); moveTo(50, 270); moveTo(270, 270); moveTo(270, 50); moveTo(50, 50); |
Example: Parabola Draw an half parabola opening downward.
// Draw an half parabola opening downward. penUp(); for (var x = 0; x < 200; x++) { var y = x*x/100; moveTo(x,y); penDown(); }
moveTo(x, y);
Name | Type | Required? | Description |
---|---|---|---|
x | number | Yes | The x coordinate on the screen to move the turtle to. |
y | number | Yes | The y coordinate on the screen to move the turtle to. |
No return value. Moves turtle only.
Found a bug in the documentation? Let us know at documentation@code.org
Found a bug in the documentation? Let us know at documentation@code.org