python turtle教程3
的有关信息介绍如下:
turtle是初入python的一个很好好玩的库,并且十分适合用来教导孩子如何编程,基于TK,所以运行该库时保证python已内置tk。
本教程是该系列的第三部分,请确保已学会第一部分和第二部分。
获取画笔的状态,前面已接触到了一些基本的position和heading,这里会简单回顾下。
获取画笔位置 position()
turtle.position()
返回箭头方向与直线的角度 towards
turtle.towards(x,y)
如下图例子。注意两者都是矢量,(1,0)和(0,-1)
返回x坐标 xcor() cor是coordinate 的缩写
turtle.xcor()
返回y坐标ycor() cor是coordinate 的缩写
turtle.ycor()
返回当前箭头角度 heading()
turtle.heading(),默认为360度角度制
离某点的直线距离 distance(x,y)
turtle.distance(x,y)返回当前点位置与(x,y)的欧几里和距离
turtle.distance(x,y)和turtle.distance((x,y))两种参数传递方式都可
改变角度范围 degrees()
turtle.degrees(angle)
将360制转为angle制
从角度转为弧度制 radians()
turtle.radians()



