slide1
Download
Skip this Video
Download Presentation
An introduction to Logo: drawing, moving, turning, repetition, and basic procedures.

Loading in 2 Seconds...

play fullscreen
1 / 53

An introduction to Logo: drawing, moving, turning, repetition, and basic procedures. - PowerPoint PPT Presentation


  • 77 Views
  • Uploaded on

B.A. (Mahayana Studies) 000-209 Introduction to Computer Science November 2005 - March 2006 12. Logo (Part 1). 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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' An introduction to Logo: drawing, moving, turning, repetition, and basic procedures.' - irina


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide1

B.A. (Mahayana Studies)000-209 Introduction to Computer ScienceNovember 2005 - March 200612. Logo (Part 1)

An introduction to Logo: drawing, moving, turning, repetition, and basic procedures.

overview
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

slide3
7. Procedures
  • 8. Circle and Square
  • 9. Drawing a Triangle
  • 10. Drawing a House
  • 11. Drawing a Checkboard
  • 12. MSW Logo Examples

000-209 Intro to CS. 12/logo1

1 what is logo
1. What is Logo?
  • A programming language developed at the MIT Artificial Intelligence Lab
    • MIT = Massachusetts Institute of Technology
  • Logo is easy to learn, but powerful.
  • Logo has been used in telecommunications, multimedia, and robotics.

000-209 Intro to CS. 12/logo1

2 installing logo
2. Installing Logo

We\'re using MSW Logo, but there are many other Logo systems.

  • MSW Logo Website:
    • http://www.softronix.com/logo.html
  • The set-up kit (Windows installer):
    • http://www.softronix.com/download/mswlogo65.exe
  • Tutorials
    • The Great Logo Adventurehttp://www.softronix.com/download/tgla.zip
    • An Introduction to MSW Logohttp://www.southwest.com.au/~jfuller/logotut/menu.htm

continued

000-209 Intro to CS. 12/logo1

slide6
Double click on mswlogo65.exe to start the installation.
  • The program will be added to the start menu as "Microsoft Windows Logo".
    • called MSW Logo
  • The MSWLogo directory contains an Examples/ folder (see end of these slides).

000-209 Intro to CS. 12/logo1

msw logo in action
MSW Logo in Action

the turtle

menus

status

window

editor

turtle drawing

area

command

window

command

box

command input window

000-209 Intro to CS. 12/logo1

what is the turtle
What is the Turtle?
  • Originally, the turtle was a robot that moved around the floor when the user typed Logo commands into a computer.
  • Today, it is a picture on the Logo drawing area
    • in MSW Logo, the turtle is drawn as a triangle

000-209 Intro to CS. 12/logo1

3 basic commands
3. Basic Commands
  • 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

slide10
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

000-209 Intro to CS. 12/logo1

4 drawing a square
4. Drawing a Square

type these commands into

the command input window,

pressing <enter> after each

command

forward 100

right 90

forward 100

right 90

forward 100

right 90

forward 100

000-209 Intro to CS. 12/logo1

error messages
Error Messages
  • Your input: forward 10 20
  • Your input: back

error

messages

000-209 Intro to CS. 12/logo1

5 more commands
5. More Commands
  • 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

slide14
setpencolor <number>
    • changes the colour of the turtle’s pen
    • e.g. setpencolor 5
      • make your turtle draw a pink line

MSW Logo has

command help

under "Index"

continued

000-209 Intro to CS. 12/logo1

slide15
clean
    • clears the turtle\'s drawing area
  • home
    • moves the turtle back to the center of the drawing area

000-209 Intro to CS. 12/logo1

example using setpencolor
Example Using Setpencolor

forward 100

setpencolor 5

right 72

forward 100

setpencolor 14

right 72

forward 100

setpencolor 3

right 72

forward 100

setpencolor 2

right 72

forward 100

Because the turtle

turned right

72 degrees

5 times, it made

a pentagon

000-209 Intro to CS. 12/logo1

6 the repeat command
6. The Repeat Command
  • Get the turtle to do things many times, by using the repeat command.
  • e.g. repeat 4 [forward 10]
    • move the turtle forward 10 spaces, 4 times
    • the turtle will move forward 40 spaces altogether
  • In general, you type:
    • repeat <number> [ <commands> ]

000-209 Intro to CS. 12/logo1

draw a square with repeat
Draw a Square with Repeat

repeat 4 [forward 100 right 90]

000-209 Intro to CS. 12/logo1

using repeat
Using Repeat
  • 1.What will the following command draw?
    • repeat 3 [forward 100 left 120]
  • 2. Make a circle using the repeat command.

000-209 Intro to CS. 12/logo1

answer 1 draw a triangle
Answer 1: Draw a Triangle

repeat 3 [forward 100 left 120]

000-209 Intro to CS. 12/logo1

answer 2 draw a circle
Answer 2: Draw a Circle

repeat 360 [forward 1 right 1]

000-209 Intro to CS. 12/logo1

7 procedures
7. Procedures
  • Add a new command to Logo by writing a procedure.
    • to <name of your procedure> <command 1> <command 2> :end

A procedure is a new command, built out of other commands

continued

000-209 Intro to CS. 12/logo1

slide23
For example:
    • to square repeat 4 [forward 100 right 90] end
  • The new command (procedure) is for drawing a square
    • it can be used just like other Logo commands

000-209 Intro to CS. 12/logo1

typing in a procedure
Typing in a Procedure
  • A "To Mode" window pops up after you type to <name of procedure>
  • You enter your procedure line by line, and type end or press Cancel to finish.

continued

000-209 Intro to CS. 12/logo1

slide25

After typing repeat 4 [forward 100 right 90] end

continued

000-209 Intro to CS. 12/logo1

slide26
Executing the procedure:
    • square

000-209 Intro to CS. 12/logo1

a circle procedure
A Circle Procedure
  • The program:
    • to circle repeat 360 [forward 2 right 1] end
  • Test it out:
    • circle

000-209 Intro to CS. 12/logo1

the edall button
The Edall Button
  • To add more procedures, or change one you\'ve already written, click on the Edall button.

000-209 Intro to CS. 12/logo1

using edall
Using Edall
  • Enter a procedure for drawing a purple pentagon:
    • to pentagon setpencolor 10 repeat 5 [forward 75 right 72] end
  • In the Editor "File" menu, select "Save and Exit" when you are finished.

000-209 Intro to CS. 12/logo1

a pentagon
A Pentagon

000-209 Intro to CS. 12/logo1

saving procedures
Saving Procedures
  • If want to use the procedures some other time, you should save them.

000-209 Intro to CS. 12/logo1

8 circle and square
8. Circle and Square
  • How would you write the procedure circle_and_square to make a drawing that looks like this?
  • The triangle is the position of the turtle at the end of the procedure.

000-209 Intro to CS. 12/logo1

procedure
Procedure
    • 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

slide34

A procedure calls

another procedure.

circle_and_square

calls

circle

000-209 Intro to CS. 12/logo1

9 drawing a triangle
9. Drawing a Triangle
  • We want a procedure that draws a triangle with a flat base.
  • This requires different turnings of the turtle:

start

120

30

120

90

000-209 Intro to CS. 12/logo1

10 drawing a house
10. Drawing a House
  • A simple house is a square with a triangle on top of it.
  • After drawing the square, the turtle must move to the start of the triangle.
  • After drawing the triangle, the turtle must move back to its original position.

000-209 Intro to CS. 12/logo1

procedure calls
Procedure Calls

square

house

calls

triangle

000-209 Intro to CS. 12/logo1

11 drawing a checkboard
11. Drawing a Checkboard
  • We\'re going to write a series of procedures that help us make a checkboard.
  • A checkboard is a series of columns.
  • A column is a series of squares.
  • A square is made from 4 corners.

000-209 Intro to CS. 12/logo1

procedure calls1
Procedure Calls
  • I\'ll write four procedures, that call each other in a chain.

checkboard

column

square

corner

calls

000-209 Intro to CS. 12/logo1

drawing a corner
Drawing a Corner
  • We want a procedure that draws a straight line, then turns 90 degrees to the right.
  • to cornerforward 20right 90end

000-209 Intro to CS. 12/logo1

where did the turtle go
Where did the Turtle Go?
  • hideturtle
    • make the turtle invisible
    • drawing still occurs, but with no turtle
  • showturtle
    • makes the turtle visible again

000-209 Intro to CS. 12/logo1

drawing a square with corners
Drawing a Square with Corners
  • A square is four calls to corner:

000-209 Intro to CS. 12/logo1

drawing a column with squares
Drawing a Column with Squares
  • A column is eight squares, followed by the turtle moving back to its starting position.
  • After drawing a square, the turtle needs to move up by 20 to get to the starting position for the next square.

start

start

continued

000-209 Intro to CS. 12/logo1

drawing a checkboard with columns
Drawing a Checkboard with Columns
  • A Checkboard is eight columns.
  • After drawing a column, the turtle must move right to the starting position for the next column.
  • At the end of drawing the checkboard, the turtle should move back to the lower-left corner of the checkboard.

000-209 Intro to CS. 12/logo1

12 msw logo examples
12. MSW Logo Examples

Examples/Misc/curves.lgo

continued

000-209 Intro to CS. 12/logo1

slide50

Examples/3D/Hilbert.lgo

continued

000-209 Intro to CS. 12/logo1

slide51

Examples/3D/solar.lgo

continued

000-209 Intro to CS. 12/logo1

slide52

Examples/Misc/clock.lgo

continued

000-209 Intro to CS. 12/logo1

slide53

Examples/Windows/calc.lgo

000-209 Intro to CS. 12/logo1

ad