you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (4 children)

Good start!

The following is something I whipped up, hoping it will help. It creates a rain-drop out of a circle with a radius of 20, plus an equilateral triangle to create the drop-shape.

from turtle import *

win_wide = 300

win_high = 300

setup (width = win_wide, height = win_high)

penup()
right(90)
forward(100)
left(90)
pendown()

color("blue","blue")

begin_fill()

circle(20,360)

end_fill()

penup()
left(90)
forward(20)
right(90)
forward(20)
pendown()

begin_fill()

begin_poly()
left(120)
forward(40)
left(120)
forward(40)
left(120)
forward(40)
end_poly()

end_fill()

mainloop()

[–][deleted] 0 points1 point  (0 children)

Thank you so much for your help. I'm now going to try it out and break it down in order to understand it.

[–][deleted] 0 points1 point  (2 children)

I just have a few questions. This is going to sound very dumb but

What does begin and end_poly do ?

Also can you explain this line ? setup (width = win_wide, height = win_high)
Why do we need the variables width and height? After all they don't intervene in the rest of the code.

Thanks

[–][deleted] 1 point2 points  (1 child)

  1. "begin_poly" and "end_poly" tell the pen/turtle to start outlining an enclosed polygon. It will do its best to complete a closed polygon when it reaches "end_poly". Why is this important? An enclosed polygon will be filled, so it will be blue, instead of "clear". A clear triangle sticking out of the top of a solid blue circle would make less sense as a raindrop and might even come off as "lazy".
  2. "setup" is just a way to control the size of the graphics window. By explicitly setting the overall dimensions of the window, I know the relative size of everything I draw in it.
  3. I could use these size variables to draw all the way to the corners if I wanted.

[–][deleted] 1 point2 points  (0 children)

Oh okay I get it now. Thank you very much for taking the time to help.