Viktor bhd
Viktor bhd

Reputation: 31

Python turtle color not filling in properly

I'm a beginner in programming and I'm trying to draw Totoro from the ghibli movie but the body won't fill properly.

Here is the drawing I'm trying to do, with this colors , but this is what I got. This is my code:

from turtle import *
"""corps"""
import turtle

def corps():

    speed("fast")
    color('black'),width(2)
    begin_fill()
    up()
    #right side down
    goto(0,-200)
    down()
    right(90)
    forward(4)
    circle(5,90)
    forward(70)
    circle(130,90)
    forward(140)
    circle(50,20)
    up()
    #left side down
    right(-160)
    goto(0,-200)
    down()
    forward(4)
    circle(-5,90)
    forward(70)
    circle(-130,90)
    forward(140)
    circle(-50,20)
    up()
    #right side up
    right(70)
    goto(205,-79)
    down()
    forward(5)
    circle(20,70)
    circle(100,10)
    circle(500,10)
    circle(200,30)
    circle(3800,3)
    right(33)
    forward(30)
    circle(100,23)
    circle(5,115)
    circle(200,15)
    right(63)
    forward(70)
    up()
    #left side up
    goto(-205,-79)
    down()
    forward(5)
    circle(-20,70)
    circle(-100,10)
    circle(-500,10)
    circle(-200,30)
    circle(-3800,3)
    right(-33)
    forward(30)
    circle(-100,23)
    circle(-5,115)
    circle(-200,15)
    right(-63)
    forward(65)
    turtle.fillcolor('#66615D')
    end_fill()
    up()
    #belly
    begin_fill()
    turtle.fillcolor('#A99E82')
    goto(0,-200)
    down()
    circle(200)
    end_fill()

corps()
done()

This must be ugly, but I'm just starting to learn how to code.

I don't know if there is an efficient way to draw pictures with turtle use like maths or whatever, but I did it a little randomly.

Upvotes: 2

Views: 2144

Answers (1)

cdlane
cdlane

Reputation: 41872

@RogerAsbey is correct on this point (+1):

If you could do the outline in one continuous line it would fill evenly.

So let's rework the code to do so. You can still think about it in discreet parts, but just make sure one flows to the next instead of jumping around:

from turtle import *

speed("fastest")
width(2)

color('#36302A', '#545049')

begin_fill()

up()
goto(0, -200)
right(90)
down()

# right side lower
forward(4)
circle(5, 90)
forward(70)
circle(130, 90)
forward(140)
circle(50, 20)
circle(50, -20)
backward(140)
right(90)

# right side upper
forward(5)
circle(20, 70)
circle(100, 10)
circle(500, 10)
circle(200, 30)
circle(3800, 3)
right(33)
forward(30)
circle(100, 23)
circle(5, 115)
circle(200, 15)
right(63)

forward(130)

# left side upper
right(63)
circle(200, 15)
circle(5, 115)
circle(100, 23)
forward(30)
right(33)
circle(3800, 3)
circle(200, 30)
circle(500, 10)
circle(100, 10)
circle(20, 70)
forward(5)

# left side lower
right(90)
backward(140)
circle(50, -20)
circle(50, 20)
forward(140)
circle(130, 90)
forward(70)
circle(5, 90)
forward(4)

goto(0, -200)
right(90)

end_fill()

# belly
fillcolor('#A99881')

begin_fill()
circle(200)
end_fill()

hideturtle()

done()

enter image description here

Upvotes: 3

Related Questions