turtle模块绘图

import turtle

#运动命令

# forward(d)  向前移动d长度

# backward(d)  向后移动d长度

# right(d)  向右转动多少度

#left(d)  向左转动多少度

# goto(x,y)  到达指定的坐标

# speed(speed)  笔画绘制的速度[0,10]

# 绘图窗口的原点(0,0)在正中间,方向是右侧

# 笔画控制命令  

# up()  画笔抬起,移动不画图

# down()  画笔落下,移动画图

# setheading()  改变画笔的朝向

# pensize()  笔画宽度

# pencolor()  笔画颜色

# reset()  恢复所有设置,清空窗口,重置turtle状态

# clear()  清空窗口,不会重置turtle

# circle(r,e)  绘制一个圆,r为半径,e为次数(分几次画出一个圆)steps=5(五边形)

turtle.begin_file()

turtle.fillcolor(colorstr)

turtle.end_fill()

其他命令

done()  程序继续执行

undo()  撤销上一步

hideturtle()   隐藏画笔

showturtle()  显示画笔

screensize()  窗口尺寸

turtle.forward(100)

turtle.right(45)

turtle.backword(300)

猜你喜欢

转载自www.cnblogs.com/cheney-lv/p/9397699.html
今日推荐