Encyclopedia > Turtle graphics

  Article Content

Logo programming language

Redirected from Turtle graphics

Logo is a computer programming language designed by Seymour Papert in the late 1960s to teach computer skills to children. Papert is a professor at MIT, and the author of Mindstorms: Children, Computers, and Powerful Ideas. Logo is from the Greek word "logos" meaning "word".

Papert used LISP but changed the syntax so it is much easier to read. One could say that Logo is Lips without the parentheses.

Turtle Graphics

One of its most notable features was called "Turtle Graphics"; a system for creating graphics that allowed a Logo user to easily produce visual effects from simple programs. The idea was that a turtle with a pen strapped to it could be instructed to do simple things like move forward 100 spaces or turn around. From these building blocks you could draw more complex shapes like squares, triangles, circles--using these to draw houses or sail boats.

The turtle moved with commands that were relative to its own position, "LEFT 90" meant rotate left by 90 degrees. A student could understand (and predict and reason about) the turtle's motion by imagining what she would do if she were the turtle. Papert called this "body syntonic" reasoning.

The idea of turtle graphics is also useful for example in Lindenmayer system for generating fractals.

Turtle Programming

Titles can be given to groups of instructions; essentially creating libraries of more complex commands. (er, how?)

 
 FORWARD 100
 LEFT 90
 FORWARD 100
 LEFT 90
 FORWARD 100
 LEFT 90
 FORWARD 100
 

This would draw a square with sides 100 units long.

 
 FORWARD 100
 RIGHT 120
 FORWARD 100
 RIGHT 120
 FORWARD 100
 

Would draw a triangle.

The turtle's pen could be lifted and lowered; drawing a dotted line was rudimentary. In this example we'll use the the shorthand for FORWARD, which is FD.

 FD 10 
   (drawing a line and moving)
 PENUP 
   (now we've lifted the pen so it won't draw anything even if we do move)
 FD 10 
   (not drawing but moving)
 PENDOWN 
   (now we've lowered the pen so it draws a line wherever the turtle moves)
 FD 10 
   (drawing a line and moving)
 PENUP
 FD 10 
   (etc...)
 PENDOWN
 FD 10
 

You could also use loop (repeat) commands. This would draw the exact same box in the first example:

 
 REPEAT 4 [FD 100 RIGHT 90]
 

Which would execute the command "FD 100 RIGHT 90" four times.

A simplistic circle consists of 360 individual rotations with a step forward, so "REPEAT 360 [FD 1 RIGHT 1]" would have the expected result.

You could title groups of instructions, ie. make procedures. These needed to be done from the Editor, that was known as Ed.

 ED (to enter the editor mode, then the actual procedure)
 
 
 TO BOBSAGET
 REPEAT 4 [FD 100 RT 90]
 FD 30
 END
 

Now any time BOBSAGET is entered, "REPEAT 4 [FD 100 LEFT 90] FD 30" will be executed. You could compound these by REPEAT 4 [BOBSAGET] if you wanted.

External Link

  • rLogo (http://www.embry.com/rLogo/): Play with Logo online (you will need a Java-enabled browser).
  • MIT StarLogo (http://education.mit.edu/starlogo/)
  • Berkeley Logo (http://www.cs.berkeley.edu/~bh/logo) (UCBLogo, GNU)



All Wikipedia text is available under the terms of the GNU Free Documentation License

 
  Search Encyclopedia

Search over one million articles, find something about almost anything!
 
 
  
  Featured Article
U.S. presidential election, 1804

... election, 1804 - Wikipedia <<Up     Contents U.S. presidential election, 1804 Presidential CandidateElectoral Vote Party Running ...

 
 
 
This page was created in 38 ms