Documente Academic
Documente Profesional
Documente Cultură
(Mahayana Studies)
000-209 Introduction to Computer Science
November 2005 - March 2006
An introduction to Logo:
drawing, moving, turning,
repetition, and basic procedures.
Overview
1. What is Logo?
2. Installing Logo
3. Basic Commands
4. Drawing a Square
5. More Commands
6. The Repeat Command
continued
000-209 Intro to CS. 12/logo1 2
7. Procedures
8. Circle and Square
9. Drawing a Triangle
10. Drawing a House
11. Drawing a Checkboard
12. MSW Logo Examples
Tutorials
The Great Logo Adventure
http://www.softronix.com/download/tgla.zip
An Introduction to MSW Logo
http://www.southwest.com.au/~jfuller/logotut/menu.htm
continued
000-209 Intro to CS. 12/logo1 5
Double click on mswlogo65.exe to start the
installation.
status
window editor
turtle drawing
area
command command
box window
forward <number>
the larger the number the farther the turtle will go
if you use a large enough number, the turtle will walk
off the screen and wrap around to the other side
e.g. forward 40
back <number>
the turtle will move backwards
e.g. back 33
continued
000-209 Intro to CS. 12/logo1 9
right <number>
the number is how many degrees the turtle will turn
right
e.g. RIGHT 90
turn the turtle to the right by 90 degrees.
left <number>
turns the turtle to the left
forward 100
right 90
forward 100
right 90
forward 100
right 90
forward 100
Your input:
forward 10 20
Your input:
back
error
messages
penup
causes the turtle to pick up its pen so that when it
moves no line is drawn
pendown
puts the pen back down so drawing starts again
continued
000-209 Intro to CS. 12/logo1 13
setpencolor <number>
changes the colour of the turtle’s pen
e.g. setpencolor 5
make your turtle draw a pink line
continued
000-209 Intro to CS. 12/logo1 14
clean
clears the turtle's drawing area
home
moves the turtle back to the center of the drawing area
forward 100
setpencolor 5
right 72
forward 100
setpencolor 14 Because the turtle
right 72 turned right
forward 100 72 degrees
setpencolor 3 5 times, it made
right 72 a pentagon
forward 100
setpencolor 2
right 72
forward 100
continued
000-209 Intro to CS. 12/logo1 22
For example:
to square
repeat 4 [forward 100 right 90]
end
continued
000-209 Intro to CS. 12/logo1 24
• After typing
repeat 4 [forward 100 right 90]
end
continued
000-209 Intro to CS. 12/logo1 25
Executing the procedure:
square
000-209 Intro to CS. 12/logo1 26
A Circle Procedure
The program:
to circle
repeat 360 [forward 2 right 1]
end
Test it out:
circle
to circle_and_square
home
clean
repeat 360 [forward 2 right 1]
forward 50
repeat 3 [left 90 forward 100]
left 90
forward 50
end
Now change circle_and_square so it uses the
circle procedure.
continued
000-209 Intro to CS. 12/logo1 33
A procedure calls
another procedure.
circle_and_square
calls
circle
start
120
3
0
9 120
0
000-209 Intro to CS. 12/logo1 35
000-209 Intro to CS. 12/logo1 36
10. Drawing a House
square
house
calls
triangle
to corner
forward 20
right 90
end
hideturtle
make the turtle invisible
drawing still occurs, but with no turtle
showturtle
makes the turtle visible again
A square is four
calls to corner:
start
continued
000-209 Intro to CS. 12/logo1 45
000-209 Intro to CS. 12/logo1 46
Drawing a Checkboard with Columns
Examples/Misc/curves.lgo continued
000-209 Intro to CS. 12/logo1 49
Examples/3D/Hilbert.lgo
continued
000-209 Intro to CS. 12/logo1 50
Examples/3D/solar.lgo
continued
000-209 Intro to CS. 12/logo1 51
Examples/Misc/clock.lgo
continued
000-209 Intro to CS. 12/logo1 52
Examples/Windows/calc.lgo