Drawing heart💖 using Python🐍
Published in
2 min readFeb 14, 2021
In this article, we will write few lines of code in python to draw heart and write text within it. To draw a heart, we will be using one of the python library known as ‘Turtle’.
Following are the functions which is being used for drawing:
- Turtle: Used to create turtle object
- bgcolor: Used to set background color.
- delay: Set or return the drawing delay in milliseconds. The longer the drawing delay, the slower the animation.
- color: Changes the color of the turtle’s pen.
- begin_fill:Remember the starting point for a filled polygon.
- end_fill:Close the polygon and fill with the current fill color.
- forward: Moves the turtle forward by the specified amount.
- left: Turns the turtle counter clockwise.
- right:Turns the turtle clockwise.
- setpos: Move pen to an absolute position.
- up: Picks up the turtles tail so that it doesn’t draw when it moves.
- down: Puts down the turtles tail so that it draws when it moves.
- write: Write text at the current turtle position with the given font.
- exitonclick: Shut the turtle graphics window on mouse click.
Code:
import turtle as t
pen = t.Turtle()
t.bgcolor('#9966cc')
t.delay(8)
pen.color('#ffe4e1')
pen.begin_fill()
pen.left(40)…