MSW
MSW
MSW
Microsoft Windows
Logic-Oriented
Graphic-Oriented
INTRODUCTION
We will write commands in the command line, i.e., the text box at the
bottom of the Commander Window. To execute or run these
commands, press Enter or click the Execute Button. We can also write
and run more than one command online at a time.
The command history will appear in the gray box. Click a line in the
history to make it jump to the respective command line, then we can
make changes (if required). Once this is done, press Enter or click the
Execute Button.
CONCEPT OF DRAWING IN MSW LOGO
In the centre of drawing window you will see a small triangle. This triangle is called
turtle.
We enter the commands to move the turtle on the screen.
As the turtle moves, it draws on the screen.
BASIC COMMANDS
Forward or FD :-The most basic command of the MSW LOGO is forward
command. It moves the turtle in the direction of it’s nose.
Clearing or cs :-The cs command clears the entire screen and moves the turtle
to its initial starting position
DRAWING STRAIGHT LINES
With the command back 100 or bk 100, you can move the turtle
backwards by 100 steps:
Right or rt :-The most basic command of the MSW LOGO is right direction
command. It moves the turtle in the direction of it’s nose.
Syntax:- right(turn right according to the angle) or rt(turn right according to the
angle)
Example:- right 90 or rt 90
left or lt :-The most basic command of the MSW LOGO is left direction
command. It moves the turtle in the direction of it’s nose.
Syntax:- left(turn left according to the angle) or lt(turn left according to the
angle)
Example:- left 90 or lt 90
Logo – Controlling the Turtle & Pen
Logo has a number of other drawing commands, some of which are given below.
pu – penup
pd – pendown
setpensize
Penup or pu :-means pick pen up, so you can move turtle without leaving tracks.
Syntax:- penup(forward or backward) or pu(fd or bk)
Example:- pu fd 30 , pu bk 30
Pendown or pd :-means pick pen down, so you can move turtle and leave tracks.
Syntax:- pendown(forward or backward) or pd(fd or bk)
Example:- pd fd 30 , pd bk 30
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.
label
setxy
Label command :-Label command takes a single word as a quoted string
(e.g.”a_string”) or a list of words in [] brakets without quotation(e.g.[a string of
letters]) and print them on the grapics window at the location of the turtle.
Setxy command :- The setxy command takes two arguments, treats as the value of the
abscissa( horizontal axis) and the second as a value of the ordinate (vertical axis). It places
the turtle coordinates, possibly leaving ink while reaching these coordinates .
Logo – Repetition :- Repeat command saves our time of typing-in to make The
general form is : repeat number [commands]. We must use the keyword - repeat
followed by a number and then sequence of commands in [ square brackets]
Logo – Randomization :- If you want a random angle between 0 to 359 degrees
.you can use random 360 to produce it.
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.