Python Forum
Need help to finish the hat on the snowman in this Python drawing
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help to finish the hat on the snowman in this Python drawing
#1
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
Reply
#2
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to check if file path finish on .csv danlopek14q 4 1,161 Apr-04-2021, 09:50 AM
Last Post: danlopek14q
  HomeWork Python - Drawing window with text center. Voraman 8 1,286 Jan-09-2021, 06:53 PM
Last Post: Voraman
  Drawing piled triangles in Python skkurt_cobain 1 1,395 Dec-01-2018, 10:12 PM
Last Post: woooee
  Can Anyone Finish this off FeaRoNz 5 2,418 Mar-25-2017, 10:12 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020