Beispiel #1
0
 def draw_circle(self, t):
     t.pu()
     t.goto(self.c.x, self.c.y)
     t.fd(self.r)
     t.lt(90)
     t.pd()
     polygon.circle(t, self.r)
def draw_o(t):
    """Function to draw a 'o' character. """
    fd(t, 20)
    circle(t, 20)
    pu(t)
    bk(t, 20)
    pd(t)
Beispiel #3
0
def draw_o(t):
    """Function to draw a 'o' character. """
    fd(t, 20)
    circle(t, 20)
    pu(t)
    bk(t, 20)
    pd(t)
Beispiel #4
0
def draw_circle(t, circle):
    '''Move the turtle in (x,y) and draw a circle
    t: turtle
    circle: Circle object
    '''
    t.pu()
    t.goto(circle.corner.x, circle.corner.y)
    t.fd(circle.radius)
    t.lt(90)
    t.pd()
    polygon.circle(t, circle.radius)
Beispiel #5
0
def draw_circle(t, circle):
    """Draws a circle.

    t: Turtle
    circle: Circle
    """
    t.pu()
    t.goto(circle.center.x, circle.center.y)
    t.fd(circle.radius)
    t.lt(90)
    t.pd()
    polygon.circle(t, circle.radius)
Beispiel #6
0
def draw_circle(t, circle):
    """Draws a circle.

    t: Turtle
    circle: Circle
    """
    t.pu()
    t.goto(circle.center.x, circle.center.y)
    t.fd(circle.radius)
    t.lt(90)
    t.pd()
    polygon.circle(t, circle.radius)
Beispiel #7
0
def main():
    world = TurtleWorld()
    bob = Turtle()
    bob.delay = 0.005
    # square(bob,45)
    # square(bob,100)
    # square(bob,180)
    # polygon(bob,15,30)
    # square(bob,60)
    circle(bob, 60)
    #arc(bob,80,180)
    polyline
    wait_for_user()
Beispiel #8
0
def draw_o(t, n):
    skip(t, n)
    circle(t, n)
    skip(t, n)
Beispiel #9
0
def draw_o(t, n):
    skip(t, n)
    circle(t, n)
    skip(t, n)
Beispiel #10
0
# running as a script, in which case run the test code,
# or being imported, in which case don't.

if __name__ == '__main__':
    world = TurtleWorld()    

    bob = Turtle()
    bob.delay = 0.001

    # draw a circle centered on the origin
    radius = 100
    pu(bob)
    fd(bob, radius)
    lt(bob)
    pd(bob)
    circle(bob, radius)

    wait_for_user()


# LEVEL 1 PRIMITIVES are simple combinations of Level 0 primitives.
# They have no pre- or post-conditions.

def fdlt(t, n, angle=90):
    """forward and left"""
    fd(t, n)
    lt(t, angle)

def fdbk(t, n):
    """forward and back, ending at the original position"""
    fd(t, n)
Beispiel #11
0
# TODO; there are more exercises in section 4.3 page 31.
# TODO; A 2 monitor system gets the previous centered on the 2 monitor break; move it.

import polygon
import turtle

print("Exercise 4.1")
# download http://greenteapress.com/thinkpython2/code/polygon.py
# http://web.cecs.pdx.edu/~lmd/cs161/turtle-excerpt.htm (not everything works with Dale's version of turtle.
# https://docs.python.org/3/library/turtle.html#module-turtle

bob = turtle.Turtle()

#bob.reset()
#bob.screen.setworldcoordinates(100,100,250,207.5)
#bob.screen.setworldcoordinates(-50,-7.5,50,7.5)
#for _ in range(72):
#     left(10)
#for _ in range(8):
#     left(45); fd(2)   # a regular octagon
#reply = input("Tap ENTER to continue...")

#bob.reset()
bob.penup()
#bob.setx(100)
#bob.sety(100)
radius = 20
bob.pendown()
polygon.circle(bob, radius)
reply = input("Tap ENTER to continue...")