Date post: | 02-Jan-2016 |
Category: |
Documents |
Upload: | todd-jones |
View: | 216 times |
Download: | 0 times |
Python's Etch-a-Sketch
A new human-computer interface?
from turtle import *
reset()
left(90)
forward(50)
right(90)
backward(50)
down() or up()
color('green')
tracer(1) or tracer(0)
width(5)
done()
and lots more!
degrees!
states if the pen draws or not
states if the pen animates
or not
Recursive Graphics
def tri(): """ draws a polygon """ forward(100) left(120) forward(100) left(120) forward(100) left(120)
there is no tri … Could we tri this with recursion?(1)
Could we create any regular n-gon?(2)
def chai(size): """ mystery! """ forward(size) left(90) forward(size/2.0) right(90) right(90) forward(size) left(90) left(90) forward(size/2.0) right(90) backward(size)
What does chai draw?(1)
How could you add more to each end?
Why are there two identical commands in a row?
Spiral
100
90
81
72.9
spiral( initLength, angle, multiplier )
close-up of innermost part of the spiral…
spiral( 100, 90, 0.9 )
svTree
svTree( trunkLength, levels )
svTree( 100, 4 )
and more! (if you want)
Help! My turtle window froze!
Your turtle window becomes unresponsive after your programruns. Type:
>>> done()
to unlock it (but then you have to close it)
The Koch curve
snowflake( 100, 0 )snowflake( 100, 1 ) snowflake( 100, 2 )
snowflake( 100, 3 ) snowflake( 100, 4 ) snowflake( 100, 5 )
Have fun!
fill(1) color("blue")