Codes.
import turtle. Before starting a program, you must import some libraries which you are going to work with. Here, we have imported a turtle because we are going to work with it in drawing the heart.
turtle.pensize. Here we want our turtle to draw using a pen of a certain size. You can use a pen of any size
turtle. speed. This is how paster our turtle will be moving. You can use the speed of from one and above.
Turtle. color. Turtle color means the color of the pen. Any color can be used meaning you can use black, red, yellow, etc.
turtle.begin_fill. Tells the turtle after drawing the heart, to begin filling the area inside the heart.
turtle. fill color. This instructs the turtle on which color to fill with. Again, you can use any color but since the color of the heart is red, you can use red although, you are not limited.
turtle.left(150). This tells the turtle in which direction to go and at what angle.
turtle.forward(180). This means after 150, the turtle should move forward for another 180 degrees this drawing a circle of -90 to 180 which half of the heart.
turtle. setheading 60. After making half a heart, the turtle should make an angle of 60 degrees and make a corcle of -90 to 180 degrees.
turtle.end_fill. commands the turtle to stop both drawing and filling.
turtle. mainloop means the end of the program.
No comments:
Post a Comment