penDown

Category:Turtle

penDown()

Category: Turtle

Puts the pen down so the turtle draws a line behind it as it moves.

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


// 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();

Parameters

penDown() does not take any parameters.

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 documentation@code.org

Found a bug in the documentation? Let us know at documentation@code.org