User:Lucia Dossin/Protyping/Assignment 1

From XPUB & Lens-Based wiki
< User:Lucia Dossin‎ | Protyping
Revision as of 10:57, 30 September 2013 by Michael Murtaugh (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Python & Turtle

circle.py

 import turtle
 
 #by changing the value of step, the resulting graphic changes
 #the larger step is, the less accurate the curve is (and the faster the circle is rendered)
 step = 10
 #to have a full circle path, divide 360 by the step value. int() assures the result is an integer
 rg = int(360 / step)
 
 for i in range(rg):
     turtle.forward(step)
     turtle.left(step)
     #if you print(i) you will see the number of steps that were needed to make the circle
     #print(i) 
 
 turtle.exitonclick()

graphical result (used 60, 50, 10, 1, 0.5 and 0.1 as step) Circles.png

circle_function.py

import turtle

#turtle.circle(radius, extent=None, steps=None)

for i in range(0, 180, 30):
    turtle.circle(i)

turtle.exitonclick()

graphical result

Circle function.png

circle_function_centric.py same as previous function, but reseting the turtle position so that the circles have the same center

import turtle

for i in range(0, 180, 30):    
    turtle.pd()
    turtle.circle(i)
    turtle.pu()
    turtle.goto(0,-i)

turtle.exitonclick()

graphical result

Circle function centric.png

centric_expansion.py

import turtle

for i in range(360):
    turtle.forward(i)
    turtle.left(i)

graphical result

Centric-expansion.png