I have made an image of a bee using Turtle in Python. In an ideal world, I would like to know how to scale the size of the bee, while simulatenously keeping all of the dimensions in proportion. I would also like to know how I can easily change the orientation of this image.
I'm rather new to coding, so I'm still very much in a learning stage. I know there's probably a very obvious answer that I'm just not making the connection with. Any help would be hugely appreciated.
def visualise_data(rename_me_in_task_1b):
def draw_body(x, y, step):
# Body outline
penup()
pencolor('black')
fillcolor('gold')
goto(x, y)
pendown()
begin_fill()
setheading(90)
circle((step * 5), 180)
forward(step * 10)
circle((step * 5), 180)
forward(step * 10)
end_fill()
# Draw Stripe 1
fillcolor('black')
begin_fill()
setheading(180)
forward(step * 10)
setheading(270)
forward(step * 4)
setheading(0)
forward(step * 10)
setheading(90)
forward(step * 4)
end_fill()
# Goto Stripe 2
penup()
setheading(180)
forward(step * 10)
setheading(270)
forward(step * 6)
# Draw Stripe 2
setheading(0)
pendown()
begin_fill()
forward(step * 10)
setheading(270)
forward(step * 4)
setheading(180)
forward(step * 10)
setheading(90)
forward(step * 4)
end_fill()
penup()
# Draw stinger
goto((x - 50), (y - (step * 15)))
setheading(270)
pendown()
width(5)
forward(step)
penup()
width(3)
# Draw right wing
goto(x, (y * 0.66))
setheading(25)
fillcolor('gainsboro')
pendown()
begin_fill()
forward(step * 5)
circle((-step * 3.5), 180)
goto(x, (-y * 0.66))
goto(x, (y * 0.66))
end_fill()
penup()
# Draw left wing
goto(-x, (y * 0.66))
setheading(155)
pendown()
begin_fill()
forward(step * 5)
circle((step * 3.5), 180)
goto(-x, (-y * 0.66))
end_fill()
def draw_head(x, y, step):
# Head outline
width(3)
pencolor('black')
fillcolor('gold')
penup()
goto((x - 50), (y * 1.5))
pendown()
begin_fill()
setheading(0)
circle((step * 6), 360)
end_fill()
penup()
# Eyes
goto((x * 0.5), (y * (step * 0.275)))
pendown()
fillcolor('white')
begin_fill()
circle(step, 360)
penup()
goto((-x * 0.5), (y * (step * 0.275)))
pendown()
circle(step, 360)
end_fill()
penup()
# Pupils
goto((-x * 0.5), (y * (step * 0.29)))
pendown()
fillcolor('black')
begin_fill()
circle((step * 0.3), 360)
penup()
forward(step * 5)
pendown()
circle((step * 0.3), 360)
end_fill()
penup()
# Mouth
setheading(270)
forward(step * 3)
pendown()
setheading(270)
circle((-step * 2.5), 180)
penup()
# Antennae
goto((-x * 0.3), (y * (step * 0.36)))
setheading(100)
pendown()
forward(step * 4)
setheading(220)
forward(step * 2)
penup()
goto((x * 0.3), (y * (step * 0.36)))
setheading(80)
pendown()
forward(step * 4)
setheading(320)
forward(step * 2)
penup()
speed(0)
width(3)
title('The Australian Honey Bees-nest/Business')
def draw_main_body(x, y, step):
draw_body(x, y, step)
draw_head(x, y, step)
write("Australia's Honey production is abundant!", move=True, align='left',
font=("Arial", 8, "bold"))
draw_main_body(50, 50, 10)
hideturtle()
done()
mainloop()
Along with @ggorlen's usual excellent advice (+1), you have to also avoid commands like
setheading()in favor ofleft()and/orright(). You also need to think about applying your scaling to things like pen width. You may also need to "undraw" (with pen up) some things to get your turtle back to a known location to continue drawing other items.As an example, below is a rework of your
draw_head()function that scales and rotates: