gpt4 book ai didi

python - Python turtle 模块中 turtle 的默认值

转载 作者:行者123 更新时间:2023-11-30 22:09:56 27 4
gpt4 key购买 nike

出于教学目的,我需要一个图形默认值列表。这是我现在所拥有的:

background  white
canvas 950W by 800H
dot 5 (pixels)
fill color black
heading 0 (East)
home (0,0) (screen center)
pen color black
shape classic (arrow)
speed 3 (of turtle)
width 1 (of line)

还有更多默认值吗?谢谢

最佳答案

turtle.pen() 方法(经常与 turtle.Pen() 方法混淆)允许您查询和设置许多属性,最初显示它们的属性默认值:

>>> turtle.pen()
{'shown': True, 'pendown': True, 'pencolor': 'black', 'fillcolor': 'black', 'pensize': 1,
'speed': 3, 'resizemode': 'noresize', 'stretchfactor': (1.0, 1.0),
'shearfactor': 0.0, 'outline': 1, 'tilt': 0.0}
>>>

其中“显示”是“可见”的替代术语。其他默认值:

mode: 'standard'  # default for turtle.mode()
colormode: 1.0 # default for turtle.colormode()
angle units: degrees # change with turtle.radians()

前两个可能是屏幕默认值,但最后一个是根据每只 turtle 设置的。我认为这是不正确的:

canvas      950W by 800H

默认的 turtle 屏幕尺寸是屏幕宽度的 50% 和屏幕高度的 75%。屏幕设置例程将接受分数和像素:

turtle.Screen().setup(0.25, 0.25)

关于python - Python turtle 模块中 turtle 的默认值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51792139/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com