Python Forum

Full Version: Need help to finish the hat on the snowman in this Python drawing
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Looking for help, I want to make the hat a traditional top hat with a slimmer rectangle spawning at the center of the black filled fat rectangle atop the snowmans head. Any idea what code to add to make this happen?

Thanks in Advance







import turtle

t = turtle.Turtle()

def create_oval(color, radius, x, y):

t.penup()

t.fillcolor(color)

t.goto(x,y)

t.pendown()

t.begin_fill()

t.circle(radius)

t.end_fill()



#drawing body for snowman

create_oval("#ffffff", 30, 0, -40)

create_oval("#ffffff", 40, 0, -100)

create_oval("#ffffff", 60, 0, -200)



create_oval("#ffffff", 2, -10, -10) #drawing left eye for snowman

create_oval("#ffffff", 2, 10, -10) #drawing right eye for snowman

create_oval("#ffffff", 3, 0, -15) #drawing nose for snowman



# drawing buttons for snowman

create_oval("#ffffff", 2, 0, -40) #drawing left eye for snowman

create_oval("#ffffff", 2, 0, -55) #drawing right eye for snowman

create_oval("#ffffff", 2, 0, -65)



def create_line(x, y, length, angle):

t.penup()

t.goto(x, y)

t.setheading(angle)

t.pendown()

t.forward(length)

t.setheading(angle + 20)

t.forward(20)

t.penup()

t.back(20)

t.pendown()

t.setheading(angle - 20)

t.forward(20)

t.penup()

t.home()



create_line(-70, -50, 50, 160) #drawing left arm for snowman

create_line(70, -50, 50, 20) #drawing right arm for snowman





def draw_rectangle(x, y, width, height): #drawing hat for snowman

t.penup()

t.goto(x, y)

t.fillcolor("black")

t.pendown()

t.fillcolor("black")

t.begin_fill()

t.forward(width)

t.left(90)

t.forward(height)

t.left(90)

t.forward(width)

t.left(90)

t.forward(height)

t.left(90)

t.end_fill()

draw_rectangle(-35, 20, 75, 20)



def draw_rectangle(x, y, width, height):

t.penup()

t.goto(x, y)

t.fillcolor("black")

t.pendown()

t.fillcolor("black")

t.begin_fill()

t.forward(width)

t.left(90)

t.forward(height)

t.left(90)

t.forward(width)

t.left(90)

t.forward(height)

t.left(90)

t.end_fill()



draw_rectangle(-35, 50, 75, 50)



Drawing ---> https://imgur.com/6v8uSC0
Please put your code in Python code in Python code tags, you can find help here: https://python-forum.io/misc.php?action=help&hid=25