CMPT 166 Lecture Notes - Lecture 29: Turtle Graphics, Object-Oriented Programming, Decagon
Document Summary
In these notes you will learn: how to draw shapes using turtle graphics, how to implement a turtle class for drawing turtle graphics. Turtle graphics is a simple yet useful approach to drawing pictures. As it moves, the turtle draws a line showing it"s path. So, for example, these commands would make the turtle draw a square: pen down. Forward 10: turn right 90 degrees, turn right 90 degrees, turn right 90 degrees, turn right 90 degrees. Turtle graphics is easy enough for young children to understand. It only has a few simple commands, and with a bit of experimentation you can draw some very interesting pictures. Processing doesn"t come with turtle graphics built-in, so lets add it ourselves. In an object- oriented language like processing, the natural approach is to create a class called turtle that represents an on-screen turtle. When it"s done, it should work like this: