📜  Python中的 turtle.get_shapepoly()函数

📅  最后修改于: 2022-05-13 01:54:29.928000             🧑  作者: Mango

Python中的 turtle.get_shapepoly()函数

turtle 模块以面向对象和面向过程的方式提供海龟图形原语。因为它使用 Tkinter 作为底层图形,所以它需要安装一个支持 Tk 的Python版本。

turtle.get_shapepoly()

此方法用于将当前形状多边形作为坐标对的元组返回。它不需要任何论据。

句法:

turtle.get_shapepoly()

以下是上述方法的实现以及一些示例:

示例 1:

Python3
# import package
import turtle
  
# get default shape
print(turtle.shape())
  
# get default shapeploy
print(turtle.get_shapepoly())
  
# set some size
turtle.turtlesize(5, 5, 2)
  
# get default shapeploy
print(turtle.get_shapepoly())


Python3
# import package
import turtle
  
# get all shapes
shp=turtle.getshapes()
print(shp)
  
# loop for getting shapepoly
# of all the shapes
for i in range(len(shp)):
    turtle.shape(shp[i])
    print(turtle.get_shapepoly())


输出 :

classic
((0, 0), (-5, -9), (0, -7), (5, -9))
((0.0, 0.0), (-25.0, -45.0), (0.0, -35.0), (25.0, -45.0))

示例 2:

Python3

# import package
import turtle
  
# get all shapes
shp=turtle.getshapes()
print(shp)
  
# loop for getting shapepoly
# of all the shapes
for i in range(len(shp)):
    turtle.shape(shp[i])
    print(turtle.get_shapepoly())

输出 :