Python中的turtle.resizemode()函数

Python中的turtle.resizemode()函数

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

turtle.resizemode()

该函数用于设置调整大小模式为其中一个值。”auto”, “user”, “noresize”。如果没有给出参数,则返回当前的 resizemode。 resizemode(“user”) 是通过调用 shapesize 的参数来调用的。

语法: turtle.resizemode(rmode=None)

参数:

rmode(可选):“auto”、”user”、”noresize “中的一个字串。

不同的调整大小模式有以下影响。

  • “auto “使Turtle的外观与pensize的值相适应。
  • “user “根据拉伸因子和轮廓宽度(outlinewidth)的值来调整Turtle的外观,这些值是由shapesize()设置的。
  • “noresize “没有对Turtle的外观进行调整。

下面是上述方法的实现和一些例子。

例子1 :

# importing package
import turtle
  
# check default value
print(turtle.resizemode())

输出 :

noresize

例子2 :

# importing package
import turtle
  
# print default value
print(turtle.resizemode())
  
# change mode to auto and check
turtle.resizemode(rmode="auto")
print(turtle.resizemode())
  
# change mode to user and check
turtle.resizemode(rmode="user")
print(turtle.resizemode())

输出 :

noresize
auto
user

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程

Python Turtle