def desenharElem(self, classe, metodo):
        """
        Desc: Funcção chamada por Botão: Visualizar Elemento
        Mostra o elemento seleciona na janela Visualizar elemento
        """

        # Limpar a janela
        self.tat.reset()

        # Configurações gerais da tat
        #self.tat.hideturtle()

        self.tat.penup()
        self.tat.right(90)
        self.tat.forward( 150/2 - 150/10 )
        self.tat.left(90)
        self.tat.pendown()


        # Desenhar elemento selecionado
        #  Selecionando a tat correta

        # Desenhar elemento
        #  Formatando elemento
        if classe == "Portas":
            portas.turtle  = self.tat
            self._string = "portas."
        elif classe == "Janelas":
            janelas.turtle = self.tat
            self._string = "janelas."
        elif classe == "Tetos":
            tetos.turtle   = self.tat
            self.tat.left(90)
            self._string = "tetos."
        else:
            cb.janelaErro("Classe selecionada estranha... o.O")

        self._string += metodo + "()"


        # Desenhar
        exec(self._string)
        #turtle.forward(25)

        #  Retornando a tat original
        '''
        if classe == "Portas":
            portas.turtle  = turtle.getturtle()
        elif classe == "Janelas":
            janelas.turtle = turtle.getturtle()
        elif classe == "Tetos":
            self.tat.right(90)
            tetos.turtle   = turtle.getturtle()
        else:
            cb.janelaErro("Classe selecionada estranha... o.O\n\"" + classe + "\"")
        '''
        portas.turtle  = turtle.getturtle()
        janelas.turtle = turtle.getturtle()
        tetos.turtle   = turtle.getturtle()
Exemplo n.º 2
0
def main():

    #Window setup
    screen_width = 800
    screen_height = 800
    turtle.setup(screen_width, screen_height)
    window = turtle.Screen()
    window.title('DRUNK BIRD')
    Drunk_Man = turtle.getturtle()
    Drunk_Man.penup()
    Drunk_Man.setposition(0, 160)
    Drunk_Man.pendown()

    Drunk_Man.shape("circle")

    #gretting
    print("This is the drunk simulator")
    #duration of flight
    print("Choose your character")
    print("1=Drunk bird 2=Drunk deer 3=Drunk man")
    Character = int(input(">"))
    print('Enter number of seconds to move')
    Seconds = int(input(">"))
    Seconds = Seconds * 100
    #Enter speed
    print("Enter speed (1-slow, 2-faster, ..., 10-fastest:)")
    Speed = int(input(">"))
    random_walk(Seconds, Speed, Drunk_Man, window)
    Speed = Speed * 2
Exemplo n.º 3
0
def simple():
    # create the screen for the turtle to exist in
    ts = turtle.getscreen()

    # create a turtle, assign to a variable
    a = turtle.getturtle()

    # code below here moves the turtle around

    # move the turtle around, left and right use degrees, forward
    # (and backwards) are approximately pixels

    # at the beginning the turtle points to the right, in middle of the screen
    a.forward(50)
    # turn 90 degrees left, so it now points up
    a.left(90)
    # go forward (i.e. up)
    a.forward(30)
    # turn left again, so now pointing to the left
    a.left(90)
    # go back, i.e. to the right
    a.backward(100)

    # code above here moves the turtle around

    # loop around - hit control-c to exit the function back to the shell
    ts.mainloop()
Exemplo n.º 4
0
def draw():
    tri = turtle.getturtle()
    tri.resizemode("auto")
    tri.shape("classic")
    tri.up()
    tri.goto(300, -200)
    tri.down()

    rabbit = turtle.Turtle()
    rabbit.resizemode("auto")
    rabbit.shape("turtle")
    rabbit.reset()
    rabbit.left(90)
    rabbit.speed(0)
    rabbit.up()
    rabbit.goto(360, 0)
    rabbit.setheading(90)
    rabbit.down()
    rabbit.speed(6)
    rabbit.color("blue", "orange")
    rabbit.pensize(2)

    tri.speed(6)
    tri.setheading(tri.towards(rabbit))

    while tri.distance(rabbit) > 2:
        rabbit.fd(20.20)
        rabbit.lt(3.2)

        tri.setheading(tri.towards(rabbit))
        tri.fd(20.6)

    tri.write("CAUGHT! ", font=("Arial", 16, "bold"), align="right")
    tri.pencolor("black")
    tri.pencolor("red")
Exemplo n.º 5
0
def displayBanner(banner, position):
	the_turtle = turtle.getturtle()
	the_turtle.hideturtle()
	the_turtle.penup()
	the_turtle.setposition(position[0], position[1])	
	the_turtle.showturtle()		
	the_turtle.shape(banner)
	the_turtle.stamp()
Exemplo n.º 6
0
def displayBanner(banner, position):
    the_turtle = turtle.getturtle()
    turtle.penup()
    turtle.hideturtle()
    turtle.setposition(position[0], position[1])
    turtle.pendown()
    turtle.showturtle()
    turtle.shape(banner)
    turtle.stamp()
 def gotPing(event):
   global loop
   print "gotPing",event,loop
   import turtle
   t = turtle.getturtle()
   t.right(90)
   t.pd()
   t.forward(100)
   t.pu()
def display_banner(banner, position):
    """ (str, tuple) -> turtle
    Displays <banner> (a valid shapename) at
    <position>
    """
    the_turtle = turtle.getturtle()
    turtle.setposition(position[0], position[1])
    turtle.shape(banner)
    turtle.stamp()
Exemplo n.º 9
0
    def __init__(self):
        # Variáveis globais
        self.tetosHotel = ['teto0', 'teto1']
        self.tetosCasa  = ['teto0', 'teto2']
        self.tetosLoja  = ['teto0']
        self.tetosTodas = ['teto0', 'teto1', 'teto2']


        # Nome da tartaruga controladora
        self.turtle = turtle.getturtle()
Exemplo n.º 10
0
def drawpoint(point, color):
    p = turtle.getturtle()
    p.hideturtle()
    turtle.delay(1)
    for i in point:
        p.pu()
        p.color(color)
        p.goto(i)
        p.pd()
        p.dot()
Exemplo n.º 11
0
def drawpoint(point,color):
    p=turtle.getturtle()
    p.hideturtle()
    p.speed(10)
    for i in point:
        p.up()
        p.color(color)
        p.goto(i)
        p.down()
        p.dot()
Exemplo n.º 12
0
def drawpoint(point,color):
    p=turtle.getturtle()
    p.hideturtle()
    turtle.delay(1)
    for i in point:
        p.pu()
        p.color(color)
        p.goto(i)
        p.pd()
        p.dot()
Exemplo n.º 13
0
def main():

    turtle.setup(800, 600)  # Set window size
    the_turtle = turtle.getturtle()  # Get the (default) turtle

    # Set the order
    order = 5
    size = 250

    koch(the_turtle, order, size)
Exemplo n.º 14
0
def drawpoint(point, color):
    p = turtle.getturtle()
    p.hideturtle()
    p.speed(10)
    for i in point:
        p.up()
        p.color(color)
        p.goto(i)
        p.down()
        p.dot()
Exemplo n.º 15
0
def displayBanner(banner, position):
    """
    Show banner
    :param banner: banner
    :param position: location in list
    :return: None
    """
    the_turtle = turtle.getturtle()
    turtle.setposition(position[0], position[1])
    turtle.shape(banner)
    turtle.stamp()  # Show banner
Exemplo n.º 16
0
def drawline(lineset,color):
    p=turtle.getturtle()
    p.hideturtle()
    p.speed(10)
    p.up()
    p.goto(lineset[0])
    p.down()
    p.color(color)
    for point in lineset:
        p.goto(point)
    p.goto(lineset[0])
Exemplo n.º 17
0
def drawline(lineset, color):
    p = turtle.getturtle()
    p.hideturtle()
    p.speed(10)
    p.up()
    p.goto(lineset[0])
    p.down()
    p.color(color)
    for point in lineset:
        p.goto(point)
    p.goto(lineset[0])
Exemplo n.º 18
0
 def __init__(self):
     # Gets the TKinter canvas and its upper window to be able to change TK window properties
     root = turtle.getturtle()._screen.getcanvas().winfo_toplevel()
     # Shows the window in fullscreen
     root.attributes('-fullscreen', True)
     # Shows the window
     turtle.getscreen()
     turtle.hideturtle()
     # The speed is set to 20,
     # to minimize delay between drawing texts
     turtle.speed(20)
Exemplo n.º 19
0
    def __init__(self):
        # Variáveis globais
        self.portasHotel = ['porta0', 'porta1']
        self.portasCasa  = ['porta2', 'porta3', 'porta4', 'porta5',
                            'porta6', 'porta7', 'porta8', 'porta9']
        self.portasLoja  = ['porta2']
        self.portasTodas = ['porta0', 'porta1', 'porta2', 'porta3', 'porta4', 'porta5',
                            'porta6', 'porta7', 'porta8', 'porta9']

        # Nome da tartaruga controladora
        self.turtle = turtle.getturtle()
Exemplo n.º 20
0
    def __init__(self):
        # Definindo variáveis globais
        self.janelasHotel = ['janela8', 'janela9', 'janela10']
        self.janelasCasa  = ['janela0', 'janela1', 'janela2', 'janela3', 'janela4',
                             'janela5', 'janela6', 'janela7', 'janela10']
        self.janelasLoja  = ['janela0']
        self.janelasTodas = ['janela0', 'janela1', 'janela2', 'janela3', 'janela4',
                             'janela5', 'janela6', 'janela7', 'janela8', 'janela9',
                             'janela10']

        # Nome da tartaruga controladora
        self.turtle = turtle.getturtle()
Exemplo n.º 21
0
def drawSquare(myturtle, x, y, a):
    myturtle = turtle.getturtle()
    
    myturtle.penup()
    myturtle.setposition(x, y)
    
    myturtle.pendown()
    myturtle.setposition(x-a, y)
    myturtle.setposition(x-a, y-a)
    myturtle.setposition(x, y-a)
    myturtle.setposition(x, y)
    myturtle.penup()
Exemplo n.º 22
0
def get_artist(width=600, height=400, startx=0, starty=0,
               color='forest green', thickness=2, speed='fastest'):
    """Set up for drawing to screen."""
    turtle.setup(width, height)
    artist = turtle.getturtle()
    artist.penup()
    artist.setpos(startx, starty)
    artist.pendown()
    artist.color(color)
    artist.width(thickness)
    artist.speed(speed)
    return artist
Exemplo n.º 23
0
def main():
    #startTime = time.clock()
    #for i in range(32):
    #    temp = fibonacciIteratively(i)
    #endTime = time.clock()
    #print()
    #print("Iterative Fibonacci took", endTime - startTime, "seconds")
    startTime = time.clock()
    #for i in range(32):
    #    temp = fibonacciRecursively(i)
    #endTime = time.clock()
    #print()
    #print("Recursive Fibonacci took", endTime - startTime, "seconds")
    #drawTree(turtle.getturtle(), 100)
    #drawSierpinski(turtle.getturtle(), (-200, -173), (200, -173), (0, 173), 6)
    #drawLogarithmicSpiral(turtle.getturtle(), 200.0, 190.0, 20, 18)
    drawKoch(turtle.getturtle(), 300, 4)
Exemplo n.º 24
0
def get_artist(width=600,
               height=400,
               startx=0,
               starty=0,
               color='forest green',
               thickness=2,
               speed='fastest'):
    """Set up for drawing to screen."""
    turtle.setup(width, height)
    artist = turtle.getturtle()
    artist.penup()
    artist.setpos(startx, starty)
    artist.pendown()
    artist.color(color)
    artist.width(thickness)
    artist.speed(speed)
    return artist
Exemplo n.º 25
0
def triangle2():
    ts = turtle.getscreen()

    a = turtle.getturtle()

    ts.bgcolor("lightblue")
    ts.title("Playground")

    a.color("hotpink")
    a.pensize(5)

    a.forward(80)
    a.left(120)
    a.forward(80)
    a.left(120)
    a.forward(80)
    a.left(120)

    ts.mainloop()
Exemplo n.º 26
0
Arquivo: pfun.py Projeto: Choeeojin/p
def setup():
    global t1
    global wn
    global myhome
    global mywd
    global plantdir
    global myCoords

    import sys
    import os
    import turtle
    myhome=os.path.expanduser('~')
    mywd=os.path.dirname(os.path.realpath(__file__))
    plantdir=os.path.join(mywd,'../lib/')
    sys.path.append(mywd)
    myCoords=[ [(100, 100), (200, 200)],[(50, 50), (150, -50)]]
    print "if t1 exists {0}...".format('t1' in vars())
    t1=turtle.getturtle() # 
    wn=turtle.getscreen()
Exemplo n.º 27
0
def main():

    #Window setup
    screen_width=800
    screen_height=800
    turtle.setup(screen_width,screen_height)
    window = turtle.Screen()
    window.title("DRUNKARD'S WALK")
    drunkard = turtle.getturtle()
    drunkard.penup()
    drunkard.setposition(0,0)
    
    #Define shape
    drunkard.shape("circle")
    
    #Welcome Screen
    print("This program simulates a random (Drunkard's) walk")
    
    #User sets the time
    input_time = int(input("Enter number of seconds to run: "))
    
    #User sets the speed
    print("Enter speed (1-slow, 2-faster, ..., 10-fastest:)")
    speed = int(input("Enter speed (1-slow, 2-faster, ..., 10-fastest): "))
    drunkard.speed(speed)
    
    #call function to convert speed
    time = convert_time(input_time, speed)
    
    #allows the walk to continue until the time depletes.
    while time > 0:

        #call random_direction to set a random direction
        degree_turn = random_direction(window, drunkard)

        #move drunkard
        drunkard.pendown()
        drunkard.left(degree_turn)
        drunkard.forward(10)

        #increment the time
        time = time - 1
Exemplo n.º 28
0
def main():
    # set window size
    screen_width = 800
    screen_height = 600
    turtle.setup(screen_width, screen_height)

    # get reference to turtle window
    window = turtle.Screen()

    # set window title bar
    window.title('Lab 7')
    my_turtle = turtle.getturtle()

    drawX(my_turtle)

    drawW(my_turtle)

    movingTurtle(my_turtle)

    turtle.exitonclick()
Exemplo n.º 29
0
def main():
    """Fractals - Sierpinski Triangle Program 
    
    Does the needed preparation before drawing can begin.

    """
    turtle.setup(800, 600)  # Set window size

    the_turtle = turtle.getturtle()  # Get the (default) turtle

    # Init turtle: drawing capability(off) and hidden
    # only graphics to be produced by the turtle is when its (triangle) shape is stamped.
    the_turtle.penup()
    the_turtle.hideturtle()

    # Set number of levels:
    # by changing this value, a Sierpinski triangle of various levels can be
    # created.
    num_levels = 2

    # Create triangle shape
    # a tuple of coordinates that creates an equilateral triangle.
    # (The absolute positions of these coordinates are not relevant, only their
    # relative positions are used for defining the shape.)
    coords = ((-240, -150), (240, -150), (0, 266))
    create_triangle_shape(coords)
    # length of the triangle, matching the length of the triangle given by the specified coordinates.
    len_side = 480

    # create first triangle
    the_turtle.shape('my_triangle')  # set to shape (register)
    the_turtle.setposition(
        0, -50)  #  position on screen (a little below the center)
    the_turtle.setheading(90)  #  ensure that the triangle is pointing up

    # call recursive function
    draw_sierpinski_triangle(the_turtle, len_side, num_levels)
    the_turtle.hideturtle()

    # terminate prog when close window
    turtle.exitonclick()
Exemplo n.º 30
0
def drawpoint(point, color, line):
    p = turtle.getturtle()
    p.hideturtle()
    turtle.delay(1)
    if (line == 'p'):
        p.speed(0)
        for i in point:
            p.pu()
            p.color(color)
            p.goto(i)
            p.pd()
            p.dot()
    elif (line == 'l'):
        p.pu()
        p.speed(1)
        for i in point:
            p.color(color)
            p.goto(i)
            p.pd()
            p.dot()
        p.goto(point[0])
Exemplo n.º 31
0
def tri_circle():
    my_turtle.reset()
    ghost = turtle.getturtle()
    ghost.hideturtle()
    ghost.pu()
    ghost.begin_fill()
    colors = ["red", "green", "blue"]
    c_place = 0
    for i in range(3):
        ghost.fd(60)
        my_turtle.fd(60)
        my_turtle.begin_fill()
        my_turtle.fillcolor(colors[c_place])
        my_turtle.circle(10, 360)
        my_turtle.end_fill()
        c_place += 1
        my_turtle.rt(120)
        ghost.rt(120)
    ghost.end_fill()
    my_turtle.hideturtle()
    full_reset()
Exemplo n.º 32
0
def main():
    #set window size
    screen_width = 800
    screen_height = 600
    turtle.setup(screen_width, screen_height)

    #get reference to turtle window
    window = turtle.Screen()
    window.bgcolor('white')

    #set window title bar
    window.title('My First Turtle Graphing Program - Lab 7')

    #give turtle a name and print turtle
    my_turtle = turtle.getturtle()

    #create square (absolute positioning)
    #my_turtle.setposition(100,0)
    #my_turtle.setposition(100,100)
    #my_turtle.setposition(0,100)
    #my_turtle.setposition(0,0)

    #create a box (relative positioning)
    #my_turtle.forward(100)
    #my_turtle.left(90)
    #my_turtle.forward(100)
    #my_turtle.left(90)
    #my_turtle.forward(100)
    #my_turtle.left(90)
    #my_turtle.forward(100)

    drawA(my_turtle)

    drawX(my_turtle)

    drawW(my_turtle)

    moving_turtle(my_turtle)

    my_turtle.exitoneclick()
Exemplo n.º 33
0
def main():
    window_title = "My first Turtle Graphics Program"
    window_width = 400
    window_height = 400
    startx = 0
    starty = 0

    #set window size
    turtle.setup(window_width, window_height)

    #get reference to turtle window
    window = turtle.Screen()

    #set window title bar
    window.title(window_title)

    #get a Turtle object
    the_turtle = turtle.getturtle()

    #change the default turtle shape
    the_turtle.shape("turtle")

    #set the turtle's posistion
    the_turtle.setpos(0, 0)
Exemplo n.º 34
0
def simple():
    ts = turtle.getscreen()

    a = turtle.getturtle()

    a.forward(100)
    a.right(90)

    a.forward(100)
    a.right(90)

    a.forward(100)
    a.right(90)

    a.forward(100)
    a.right(90)

    a.color("red")
    a.penup()
    a.forward(300)
    a.pendown()
    a.forward(100)

    ts.mainloop()
Exemplo n.º 35
0
import turtle
import time
 
def main():

    age = raw_input("legnth ")
    month = raw_input("angle")
    age = float(age)
    month = float(month)
       
    draw(age,month)      
     
    return(0)
       
       
def draw(age,month):
    ts.pen()
    ts.forward(age)
    ts.left(month)	
    ts.forward(age)
    return(0)

### MAIN ####

ts = turtle.getturtle() # ts is a turtle instance its defined at top level
                        # therefore global. we only need this defined once
                        # so we define it outside the loop.
while(True):
    main()
Exemplo n.º 36
0
            koch_curve(turtle, steps - 1, length / 3)
            turtle.left(angle)

def koch_snowflake(turtle, steps, length):
    turtle.begin_poly()

    for _ in range(3):
        koch_curve(turtle, steps, length)
        turtle.right(120)

    turtle.end_poly()

    return turtle.get_poly()
# ------------------------------ зміна характеристик черепахи ---------------------
turtle.speed("fastest")
turtle.register_shape("snowflake", koch_snowflake(turtle.getturtle(), 2, 100))
turtle.reset()
turtle.penup()
turtle.shape("snowflake")

width, height = turtle.window_width() / 2, turtle.window_height() / 2
width=int(width)
height =int(height)
for _ in range(7):
    turtle.color((random(), random(), random()), (random(), random(), random()))
    turtle.goto(randrange(-width, width), randrange(-height, height))
    turtle.stamp()

# ------------------------------ зміна характеристик черепахи ---------------------
turtle.shape("triangle")
turtle.stamp()
""" 
Author: Jamey Kirk
Title: Assignment3_Turtle2
Date: 02/28/2021
Description: use turtle to draw more polygons
"""

## setup turtle
import turtle
s = turtle.getscreen()
t = turtle.getturtle()


## function defs
def angle(sides: 'int') -> 'float or int':
    """
    calculates turn angle of polygon given sides entered by user
    """
    return 360/sides

def drawShape(Turtle, sides, length: 'int'):
    """
    draws polygon based on user input of # of sides and side length
    """
    ## as a side is drawn subtract 1 from the sidesTot
    draw = True
    while draw:
        t.fd(length)
        t.lt(360/sides)
        if abs(t.pos()) < 1:
            draw = False
Exemplo n.º 38
0
def quit():
    drawing['turtle_buffer'] = turtle.getturtle().undobuffer
    transaction.commit()
    turtle.bye()
Exemplo n.º 39
0
def draw_pegs():
    turtle.bgcolor('light gray')
    for i in [A_x, B_x, C_x]:
        draw_line(i, -100, 90, stick_height, 5, 'black', turtle.getturtle())
    turtle.update()
Exemplo n.º 40
0
def layoutTiles(window, selections, tile_area, scaling):
    ''' Displays the tiles in the window starting with the top and working
        towards the bottom of the window. This function requires that the
        coordinate (0,0) be set as the top corner of the window.
    '''

    # set background color (as grout color)
    window.bgcolor(selections['grout_color'])

    # get selected tile size
    tile_size = selections['tile_size']

    # get turtle
    the_turtle = turtle.getturtle()

    # scale size of tiles for display
    scaled_length = scaling * tile_size['length']
    scaled_width = scaling * tile_size['width']

    # scale grout spacing
    tile_spacing = 6

    # create tile shape
    turtle.register_shape('tileshape',
                          ((0, 0), (0, scaled_length),
                           (scaled_width, scaled_length), (scaled_width, 0)))

    # set turtle attributes
    the_turtle.setheading(0)
    the_turtle.shape('tileshape')
    the_turtle.hideturtle()
    the_turtle.penup()

    # place first tile at upper left corner
    loc_first_tile = (-10, tile_area['height'] + 10)
    the_turtle.setposition(loc_first_tile)

    # init first tile color and counters
    first_tile_color = 'primary_color'
    skip_counter = selections['tile_skip']
    row_counter = 1

    terminate_layout = False
    while not terminate_layout:

        # check if current row of tiles before right edge of window
        if the_turtle.xcor() < tile_area['width']:

            # check if need to switch to secondary tile color
            if skip_counter == 0:
                the_turtle.color(selections['secondary_color'])
                skip_counter = selections['tile_skip']
            else:
                the_turtle.color(selections['primary_color'])
                skip_counter = skip_counter - 1

            # place current tile color at current turtle location
            the_turtle.stamp()

            # move turtle to next tile location of current row
            the_turtle.forward(scaled_length + tile_spacing)

        # check if current row of tiles at bottom edge of window
        elif the_turtle.ycor() > 0:

            the_turtle.setposition(
                loc_first_tile[0], loc_first_tile[1] -
                row_counter * scaled_width - row_counter * tile_spacing)

            row_counter = row_counter + 1
        else:
            terminate_layout = True
Exemplo n.º 41
0
import turtle

turtle.getturtle()
turtle.penup()
turtle.goto(-100, 0)
turtle.pendown()
turtle.write("F", move=False, align="left", font=("Arial", 12, "normal"))
turtle.penup()
turtle.goto(-90, 0)
turtle.pendown()
turtle.write("F", move=False, align="left", font=("Arial", 12, "normal"))
turtle.penup()
turtle.goto(-80, 0)
turtle.pendown()
turtle.write("F", move=False, align="left", font=("Arial", 12, "normal"))
turtle.penup()
turtle.goto(-70, 0)
turtle.pendown()
turtle.write("F", move=False, align="left", font=("Arial", 12, "normal"))
turtle.penup()
turtle.goto(-60, 0)
turtle.pendown()
turtle.write("F", move=False, align="left", font=("Arial", 12, "normal"))
turtle.penup()
turtle.goto(-50, 0)
turtle.pendown()
turtle.write("F", move=False, align="left", font=("Arial", 12, "normal"))
turtle.penup()
turtle.goto(-20, 0)
turtle.pendown()
turtle.write("U", move=False, align="left", font=("Arial", 12, "normal"))
Exemplo n.º 42
0
def turtleInit(worldcoordinates):
    t = turtle.getturtle()
    s = turtle.getscreen()
    #turtle.tracer(1000, 0)
    s.setworldcoordinates(worldcoordinates[0], worldcoordinates[1], worldcoordinates[2], worldcoordinates[3])
    return (t, s)
Exemplo n.º 43
0
# Нарисуйте две звезды: одну с 5 вершинами, другую — с 11. Используйте функцию, рисующую звезду с n вершинами.


def draw_star(pet, len, points):
    deg = 180 + 180 / points

    if points == 5:
        pet.pen(pencolor="red", pensize=2)

    for step in range(0, points):
        pet.forward(len)
        pet.right(deg)

    pet.pen(pencolor="black", pensize=1)


turtle.shape('turtle')
turtle.speed(0)
pet1 = turtle.getturtle()

pet2 = pet1.clone()
pet2.penup()
pet2.goto(200, 0)
pet2.pendown()

draw_star(pet1, 150, 5)
draw_star(pet2, 150, 11)

turtle.done()
Exemplo n.º 44
0
import turtle

# set window size
turtle.setup(800, 600)

# get reference to turtle window
window = turtle.Screen()
window.title('My Polygon')
the_turtle = turtle.getturtle()

turtle.register_shape('mypoligon', ((0, 0), (100, 0), (140, 40)))

the_turtle.shape('mypoligon')
the_turtle.fillcolor('purple')

for angle in range(0, 360, 10):
    the_turtle.setheading(angle)
    the_turtle.stamp()

turtle.register_shape('mypoligon', ((10, 0), (10, 0), (190, 40)))
for angle in range(0, 360, 10):
    the_turtle.setheading(angle)
    the_turtle.stamp()

the_turtle.speed(1)