Outline for October 22, 2012
Reading
:
None
Assignment Due
: October 24, 2012 at 5:00PM
Turtle graphics
What turtle is;
import turtle
Drawing a figure: a box with a hat [
tbox.py
]
Set up the window to draw in:
Screen()
Create the turtle:
Turtle
Cursor for drawing
Move cursor forward:
forward
,
backward()
Turn cursor:
left()
,
right()
Wait for the window to close:
mainloop()
Titles, background, and such [
tfancybox.py
]
Window<
Color of the window background:
background()
Title of the window:
title
Turtle, more properly called “pen”
Shape of the turtle:
shape()
Speed of the drawing:
speed()
Color of the drawn line:
color()
Thickness of the line (pixels):
pensize()
Hide the turtle:
hideturtle()
Plotting points and graphing
Drawing lines:
penup()
,
pendown()
Move turtle:
setpos()
Write text:
write()
Draw a dot at the current position:
dot()
[
tchaos1.py
]
Draw a line from the current position to another:
goto()
[
tchaos2.py
]
A PDF version is available here.
ECS 10, Basic Concepts of Computing
Fall Quarter 2012