Logo - Turtle World


Advertisements

Logo has a number of other additional drawing commands, some of these are given below.

  • home
  • cleartext or ct
  • label
  • setxy

The label command takes a single word as a quoted string (e.g. “a_string”) or a list of words in [ ] brackets without quotation (e.g. [a string of letters]) and prints them on the graphics window at the location of the turtle. Let us consider the following code.

Commander

The setxy command takes two arguments, treats the first as the value of the abscissa (horizontal axis) and the second as a value of the ordinate (vertical axis). It places the turtle at these coordinates, possibly leaving ink while reaching these coordinates. In the following three figures, we have shown how the setxy command can be used.

Figure1

Figure2

Figure3

The cleartext command, abbreviated ct, clears the text region of the command window.

Cleartext Command

Exercise

Following is an exercise to check your aptitude on what you have learned so far in this chapter.

What kind of figure does the following command sequence produce?

cs pu setxy -60 60 pd home rt 45 fd 85 lt 135 fd 120

Interpret these commands as you read them from left to right. Try it to find out the result.

Following is a table of command summary.

Command Name Purpose
setx 100

Sets the turtle's x-coordinate to +100

Moves it 100 points to the right of center

No vertical change

setx -200

Moves the turtle 200 points to the left of center

No vertical change

sety 150

Sets the turtle's y-coordinate to 150

Moves it 150 points above center

No horizontal change

sety - 50

Moves the turtle 50 points below center

No horizontal change

setxy 100 100

Moves the turtle to xy coordinate 100 100

show xcor

show ycor

Reports the turtle’s x-coordinate

Reports the turtle’s y-coordinate

setheading 0

seth 0

Points the turtle straight up, “high noon”

seth 120

Moves the turtle 120 degree to point to the four o’clock position

The following screenshot is a practical demonstration of some of the above commands.

Practical Demostration
Advertisements