Chapter 7 Flashcards
Graphics
Discipline that underlies the representation and display of geometric
shapes in two‐ and three‐dimensional space
Turtle Graphics
Toolkit provides a simple and enjoyable way to draw pictures
in a window
- turtle is a non-standard, open-source Python module
How did turtle graphics originally develop?
I was part of the children’s programming language Logo
- Created by Seymour Papert and his colleagues at MIT in the late 1960s
- Analogy: Turtle crawling on a piece of paper, with a pen tied to its tail
* Sheet of paper is a window on a display screen
* Position specified with (x, y) coordinates- Cartesian coordinate system, with origin (0, 0) at the center of a window
Heading
Specified in degrees, the heading or direction increases in value as
the turtle turns to the left, or counterclockwise. Conversely, a
negative quantity of degrees indicates a right, or clockwise, turn. the
turtle is initially facing east, or 0 degrees. North is 90 degree.
color
Initially black, the color can be changed to any of more than 16
million other colors.
Width
This is the width of the line drawn when the turtle moves. The initial
width is 1 pixel.
Down
This attribute, which can be either true or false, controls whether the
turtle’s pen is up or down. When true (that is, when the pen is down),
the turtle draws a line when it moves. When false (that is, when the
pen is up), the turtle can move without drawing a line.
Interface
set of methods of a given class
- Used to interact with an object
- Use docstring mechanism to view an interface
help(<class>)
help(<class>.<method>)</method></class></class>
Turtle graphics configuration file (turtle.cfg) contains initial settings of several attributes which are?
Turtle, Screen, and Canvas objects
- Python creates default settings for these attributes
- to open a file with these settings: Open a text editor, enter the settings, and save the file as turtle.cfg
What must you do before applying methods to an object?
create the object (i.e., an instance)
instantiation
process of creating an object
Use a ____ to instantiate an object
- constructor
syntax:
<variable> = <class>(<any>)
for Turtle class:
t = Turtle()
</any></class></variable>
To close a turtle’s window, click its ___ box
close
- attempting to manipulate a turtle whose window has been closed raises an
error
Vector graphics
Drawing of 2 dimensional shapes, such as rectangles, triangles, and circles
Mutator methods
methods that change the internal state of a Turtle object