Poligoni stellati – Fill

Utilizza il codice per disegnare poligoni stellati a ruota e aggiunge il riempimento automatico

import turtle

WIDTH   = 500
HEIGHT  = 500

NUM     = 3             # --> Quante stelle? <--
PUNTE   = 7             # --> Quante punte? <--

TITOLO  = "Punte: " + str(PUNTE) + " Poligoni: " + str(NUM)
ANGOLO1 = 360/NUM
ANGOLO2 = 2*360/PUNTE
DIM     = 2.5*WIDTH/PUNTE

def stella():
    for i in range(PUNTE):
        turtle.forward(DIM)
        turtle.right(ANGOLO2)

turtle.setup(WIDTH, HEIGHT)

turtle.bgcolor('pink')
turtle.pencolor('red')
turtle.pensize(2)
turtle.shape('turtle')
turtle.speed(10)
turtle.title(TITOLO)

turtle.begin_fill()
for i in range(NUM):
    stella()
    turtle.right(ANGOLO1)
turtle.end_fill()

Lascia un commento