MSW Logo
MSW Logo
MSW Logo
COMMANDS
The simple Logo Drawing Commands move the Turtle forward and backward and
also turn it right or left. The commands and their abbreviations are given below:
fd – forward
bk – backward
rt – right
lt – left
cs – clearscreen
forward 60 or fd 60 means go forward 60 steps
right 90 or rt 90 means right turn 90 degrees
left 90 or lt 90 means left turn 90 degrees
back 60 or bk 60 means go back 60 steps
clearscreen or cs means erase all drawings.
DRAWING STRAIGHT LINES
The command forward 100 or fd 100 moves the turtle 100 steps
forward:
With the command back 100 or bk 100, you can move the turtle
backwards by 100 steps:
Logo – Controlling the Turtle & Pen
Logo has a number of other drawing commands, some of which are given below.
pu – penup
pd – pendown
ht – hideturtle
dt – showturtle
setpensize
penup or pu means pick pen up, so you can move turtle without leaving tracks.
pendown or pd means pick pen down, so you can move the turtle and leave
tracks.
hideturtle or ht means hide the turtle, so you can admire your drawing.
showturtle or st means show the turtle, so you can continue your drawing.
setpensize means it can make the pen larger, easier to see. Default pen size is –[1
1].
ADDITIONAL DRAWING
COMMANDS
Logo has a number of other additional drawing commands, some of these are
given below.
home
cleartext or ct
label
setxy
Logo – Repetition
Logo – Randomization
Logo – Recursive Procedures
In a recursive procedure, there will be a recurrence call of the procedure within the
procedure. Let us consider the following code:
to spiral_recur :n
if :n < 1 [stop]
fd :n
rt 20
spiral_recur 0.95 * :n
end
EXAMPLE
Logo – Color
On Logo's Set menu, we can set the color of three screen elements
The turtle's pen
The turtle's fill (like a paint bucket for enclosures)
The screen background
STEPS
You can make a colored square using the following steps:
Step 1: Draw the square with side length 40 using the following command.
repeat 4 [fd 40 rt 90]
Step 2: Pen up using the following command.
pu
Step 3: Go to a point inside the square. For example, place the turtle at coordinate
(20, 20) using the following command.
setxy 20 20 Logo
Step 4: Fill the square with the set floodcolor. For example, to set the floodcolor to
blue use the following command.
setfloodcolor [0 0 255]
Try executing the following set of commands –
cs – To clear the screen.
home – To bring the turtle at the home place.
setpensize [5 5] – Setting the pen size.
setpencolor [255 0 0] – Setting the pen color to red.
setfloodcolor [0 0 255] – Setting the flood color to blue.
setscreencolor [0 255 0] – Setting the screen color to green.
repeat 4 [fd 40 rt 90] – Draw a square with side length 40.
pu – Pen up.
setxy 20 20 – Put the turtle at coordinate (20, 20).
fill – Fill the square with the set floodcolor blue.
ht – Hide turtle.