penDown
Category:Turtle
Just like you need to put the pen down on the paper to draw, the turtle pen needs to be put down to draw a line as it moves.
Examples
Basic Example
// Draw a line up from the turtle starting postion at the center of the screen.
penDown();
moveForward();
Example: Another Line
Move the turtle from the center of the screen without drawing a line, then draw a line up.
// Move the turtle from the center of the screen without drawing a line, then draw a line up.
penUp();
moveForward();
penDown();
moveForward();
Example: X Marks the Spot
Use penUp and penDown to have the turtle draw an 'X', returning the turtle to the starting point.
// Use penUp and penDown to have the turtle draw an 'X', returning the turtle to the starting point.
penUp();
move(-100,-100);
penDown();
move(200,200);
penUp();
move(-100,-100);
move(-100,100);
penDown();
move(200,-200);
penUp();
move(-100,100);

Syntax
penDown();
Returns
No return value. Modifies turtle drawing only.
Tips
- penUp() is often used with penDown.
- The default starting configuration for the turtle is with the pen down.
- The color and width of the turtle line can be changed using penColor(color) and penWidth(width).
- Turtle drawing commands are not effected by the show() and hide() commands, which control if the turtle icon is displayed or not.
- If you are not seeing the turtle's movement, slow the program execution down by adjusting the tortoise/hare slider bar in the Debug Console or by using the speed() command.
Found a bug in the documentation? Let us know at support@code.org.