Open In App

turtle.get_poly() function in Python

Last Updated : 28 Jul, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

he turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses Tkinter for the underlying graphics, it needs a version of Python installed with Tk support.

turtle.get_poly()

This function is used to return the lastly recorded polygon. It doesn’t require any argument.

Syntax :

turtle.get_poly()

Below is the implementation of the above method with an example :

Example: Make a polygon and use get_poly() method

In this example, we draw an ellipse and record it by using begin_poly() and end_poly() methods. By using get_poly() method we can get all coordinates of polygon and then print it. We can also use it for registering the shape.

Python3




# import package
import turtle
  
# start recording polygon
turtle.begin_poly()
  
# form an ellipse
turtle.circle(20,90
turtle.circle(10,90)
turtle.circle(20,90
turtle.circle(10,90)
  
# end recording polygon
turtle.end_poly()
  
# get poly that recorded
print(turtle.get_poly())


Output :

((0.00,0.00), (7.65,1.52), (14.14,5.86), (18.48,12.35), (20.00,20.00), (19.24,23.83), (17.07,27.07),
(13.83,29.24), (10.00,30.00), (2.35,28.48), (-4.14,24.14), (-8.48,17.65), (-10.00,10.00),
(-9.24,6.17), (-7.07,2.93), (-3.83,0.76), (0.00,0.00))


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads