在1966年,Seymour Papert和Wally Feurzig发明了一种专门给儿童学习编程的语言——LOGO语言,它的特色就是通过编程指挥一个小海龟(turtle)在屏幕上绘图。
海龟绘图(Turtle Graphics)后来被移植到各种高级语言中,Python内置了turtle库,基本上100%复制了原始的Turtle Graphics的所有功能。
收录的海龟作图的基本函数
urtleScreen类 绘图窗口定义为绘图龟的操场
函数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, <