python 的 turtle 库(一),pythonturtle,TurtleScre
python 的 turtle 库(一),pythonturtle,TurtleScre
TurtleScreen类 绘图窗口定义为绘图龟的操场
函数Screen() 返回一个TurtleScreen子类的单例对象
RawTurtle(别名:RawPen) 在TurtleScreen上绘制的Turtle对象
一、移动并绘制:
1、forward()|
fd()
turtle.
forward(distance)
turtle.
fd(distance) 参数:distance - 一个数字(整数或浮点数)
2、turtle.
back(distance)
turtle.
bk(distance)
turtle.
backward(distance) 后退若干
3、turtle.
right(angle)
turtle.
rt(angle) 右转角度 turtle.heading() 显示当前朝向
4、turtle.
left(angle)
turtle.
lt(angle) 左转角度
5、turtle.
goto(x,y=None)
turtle.
setpos(x,y=None)
turtle.
setposition(x,y=None) 绝对移动位置
6、turtle.
setx(x)
turtle.
sety(y) 绝对移动位置,只不过将 x,y 分开进行移动
7、turtle.
setheading(to_angle)
turtle.
seth(to_angle) 设置朝向
8、turtle.
home() 将龟移动到原点 , 坐标(0,0) , 并将其标题设置为其起始方向
9、turtle.
circle(radius<半径>,extent=None<角度,范围>,steps=None<边数>) 如果半径为正,则逆时针绘制弧线,否则沿顺时针方向绘制弧线
10、turtle.
dot(size=None,*color) 给出size必须>1 用颜色画出一个直径大小的圆点
11、turtle.
stamp()
turtle.
clearstamp(stampid) 在当前乌龟位置上将海龟形状的副本印到画布上,可以通过调用clearstamp(stamp_id)将其删除
12、turtle.
clearstamps(n=None) 删除所有或第一张/最后一张海龟的邮票。如果n为None,则删除所有的邮票,如果n> 0删除前n个邮票,否则如果n <0删除后n个邮票
13、turtle.
undo() 撤销上一步
turtle.
speed(speed=None) 画笔速度
14、turtle.
position()
turtle.
pos() 返回(x,y)位置
15、turtle.
distance(x,y=None) 以龟步单位返回从乌龟到(x,y),给定向量或给定的其他乌龟的距离
16、turtle.
radians() 将角度测量单位设置为弧度。相当于度(2 * math.pi)
17、turtle.
pendown()
turtle.
pd()
turtle.
down() 落笔
18、turtle.
penup()
turtle.
pu()
turtle.
up() 起笔
19、turtle.
pensize(width=None)
turtle.
width(width=None) 笔宽
20、turtle.
pen(pen=None,**pendict) 小画布
21、turtle.
pencolor(*args) 画笔颜色
turtle.
fillcolor(*args) 填充色
turtle.
color(*args) 同时设置画笔,填充颜色,可使用0~3种颜色
22、turtle.
begin_fill()
turtle.
end_fill() 开始结束填充
23、turtle.
reset() 从屏幕上删除乌龟的图纸,重新将乌龟居中并将变量设置为默认值
24、turtle.
clear() 从屏幕上删除乌龟的图纸。不要移动乌龟。乌龟的状态和位置以及其他乌龟的图纸不受影响
25、turtle.
write(arg,move=False,align="left",font=("Arial",8,"normal")) 写文本 - arg的字符串表示 - 根据对齐(“左”,“中”或“右”)和给定字体在当前海龟位置,如果移动为真,笔将移动到文本的右下角。默认情况下,移动为False, font 是一个三元组(fontname<字体名>,fontsize<字体大小>,fonttype<字体类型>)
26、turtle.
hideturtle()
turtle.
ht() 隐藏乌龟
turtle.
showturtle()
turtle.
st() 乌龟可见
27、turtle.
shape(name=None) 将龟形状设置为具有给定名称的形状
28、turtle.
tilt(angle) 从当前倾斜角度旋转海龟形状,但不要改变海龟的朝向(移动方向)
29、turtle.
settiltangle(angle) 无论当前的倾斜角度如何,旋转龟形指向角度指定的方向。不要改变乌龟的朝向(移动方向)
python 的 turtle 库(一)
相关内容
- Python:你应该知道这些,Python:,1. Python的
- Python第三方模块tesserocr安装,pythontesserocr,介绍在爬虫过
- python如何获取多个excel单元格的值,pythonexcel,一. 获取多
- Python基本知识 os.path.join与split() 函数,pythonos.path.join
- 那些坑爹的python面试题,坑爹python,Python基础:说
- Python replace()方法,pythonreplace方法,描述Python r
- python爬虫笔记之re.IGNORECASE,, re.IGNO
- 怎么做到Python file重复写入之前的内容不被后写入的覆
- 用Python实现阿里钉钉机器人读取数据库内容自动发群通
- 关于基于python27使用 from pylab import * 报错问题,python2
评论关闭