Programming for Kids - ZedLX

The Easiest Way to Learn Computer Programming

Turtle Graphics [1/12]

Turtle Graphics

Let's imagine that the given program creates a pen for drawing lines on the screen.

This pen is at the middle of the screen has an initial direction to the right. When it is given the command FW(100), it moves forward by 100 pixels, and leaves a white trail on the screen.

The next command, LT(60), changes the direction of the pen by 60 degrees to the left. The command FW(250) makes the pen move 250 pixels forward and leave a trail.

The next command, RT(90), changes the direction of the pen by 90 degrees to the right. The command FW(150) makes the pen move 150 pixels forward and leave a trail.

The next command, SETCOLOR(/orange), changes the color of the pen. The command RT(90) changes the direction of the pen by 90 degrees to the right. The final command, FW(500) makes the pen move 500 pixels forward, but this time the trail is orange.

This way of drawing images is known as turtle graphics, in association with the turtle cursor of the Logo programming language, which was used as an educational programming language in the past.

The function-procedures FW, LT, RT and SETCOLOR are defined in the second part of the program. We will explore them in more detail later on.

Loading...