[Python] I need another way to fill a shape other than begin_fill() and end_fill()

Discussão em 'Python' iniciado por Stack, Julho 30, 2025.

  1. Stack

    Stack Membro Participativo

    I want to know if Python Turtle has a fill option other than begin_fill() and end_fill(), because my project is to draw Spongebob. Spongebob's body has fractions of ovals on its borders, so I developed a code to draw the ovals, but now I can't fill bob's body. photo of the output I tried using begin_fill() and end_fill(), but it gave me an unusual pattern that didn't fill the shape.
    here is the code i used to creat the arcs, it also uses math library

    def arc(a, b, angleS=None,angleE=None,pen=None):
    if pen == None:
    pen=turtle.Turtle()
    startx=pen.pos()[0]
    starty=pen.pos()[1]
    try:
    new_angleS = math.radians(angleS) * 0.875 * (180 / math.pi)
    new_angleE = math.radians(angleE) * 0.875 * (180 / math.pi)
    except:
    new_angleS = 0
    new_angleE = 315
    for i in range(int(new_angleS),int(new_angleE)+1):
    if i == int(new_angleS):
    pen.up()
    else:
    pen.down()
    pen.setposition(startx+a*math.cos(i/50), starty+b*math.sin(i/50))


    [​IMG]

    Continue reading...

Compartilhe esta Página