CMPT 166 Lecture Notes - Lecture 21: Turtle Graphics, Pentagon

88 views6 pages

Document Summary

In these notes you will learn: how to draw simple turtle graphics using a string of commands, what an l-system is, how to use an l-system to draw pictures. In this note we will see a remarkable way of creating a wide variety of patterns using sets of rules called l-systems. For instance, l-systems can be used to generate realistic looking trees and plants. Recall this program for drawing a square using turtle graphics: Turtle t = new turtle(); t. forward(10); t. right(90); t. forward(10); t. right(90); t. forward(10); t. right(90); t. forward(10); We could simplify it using a code, e. g. f means t. forward(10: + means t. right(90) Then the drawing for the square is the string f+f+f+f. We"ll call this a turtle string, or a turtle program. Treating the string f+f+f+f as a program may seem strange at first, but it makes sense. It"s just a very compact encoding of the instructions for drawing a square.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents