App Lab Documentation

penUp

Category:Turtle

Just like you sometimes lift your pen when drawing, the turtle pen can be lifted using penUp so the turtle will not draw a line as it moves.

Examples

Basic Example

// Move the turtle up from the turtle starting postion at the center of the screen without drawing a line.
penUp();
moveForward();

Example: Dotted Line

Use penUp and penDown to have the turtle draw a thick, dotted line.

// Use penUp and penDown to have the turtle draw a thick, dotted line.
penWidth(3);
penDown();
moveForward();
penUp();
moveForward();
penDown();
moveForward();
penUp();
moveForward();
penDown();
moveForward();

Example: Pair of Eyes

Draw a picture that has disconnected parts (a pair of eyes) using penUp to move between parts.

// Draw a picture that has disconnected parts (a pair of eyes) using penUp to move between parts.
hide();
// first eye
penDown();          
arcRight(360, 25);			
penUp();
move(25, 10);
dot(10); 
           
move(-100, -10);
// second eye
penDown();
arcRight(360, 25);
penUp();
move(25, 10);
dot(10);

Syntax

penUp();

Returns

No return value. Modifies turtle drawing only.

Tips

  • penDown() is often used with penUp. The default starting configuration for the turtle is with the pen down.
  • dot() is not effected by penUp.
  • 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.