Drawing heart💖 using Python🐍

Keerti Prajapati
Analytics Vidhya
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:

  1. Turtle: Used to create turtle object
  2. bgcolor: Used to set background color.
  3. delay: Set or return the drawing delay in milliseconds. The longer the drawing delay, the slower the animation.
  4. color: Changes the color of the turtle’s pen.
  5. begin_fill:Remember the starting point for a filled polygon.
  6. end_fill:Close the polygon and fill with the current fill color.
  7. forward: Moves the turtle forward by the specified amount.
  8. left: Turns the turtle counter clockwise.
  9. right:Turns the turtle clockwise.
  10. setpos: Move pen to an absolute position.
  11. up: Picks up the turtles tail so that it doesn’t draw when it moves.
  12. down: Puts down the turtles tail so that it draws when it moves.
  13. write: Write text at the current turtle position with the given font.
  14. 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)…

--

--