python入门外传turtle模块绘图

导入turtle库 import turtle

(1)运动命令
forword(d) 向前移动d长度
backward(d) 向后移动d长度 绘图窗口的原点(0,0)在正中间,默认海龟的方向是向右
right(d) 向右转动多少度
left(d) 向左转动多少度
goto(x,y) 移动到坐标位(x,y)的位置
speed(speed) 笔画绘制的速度[0,10]

(2)笔画控制命令
up() 笔画抬起,移动的时候不会绘图
dowm() 笔画落下,移动会绘图
setheading(d) 改变海龟的朝向
pensize() 笔画的宽度
pencolor() 笔画的颜色
reset() 恢复所有设置,清空窗口,重置turtle
clear() 清空窗口,不重置turtle
circle(r,steps=e) 绘制一个圆形,r为半径,e为边形

颜色填充 begin_fill()
fillcolor(colorstr)
end_fill()

undo() 撤销上一次命令
hideturtle() 隐藏海龟
showturtle() 显示海龟
screensize(x,y)

(3)其他命令
done() 程序继续执行

猜你喜欢

转载自blog.csdn.net/qq_35076836/article/details/82563498
今日推荐