简单的图形——python入门
代码:
import turtle as t
import math
def main():
t.pensize(14)
t.pu()
t.goto(-150,50)
t.pd()
t.seth(72)
t.begin_fill()
t.color("yellow")
t.circle(-150 / math.cos(18 * math.pi / 180)-10)
t.end_fill()
t.seth(-18)
t.fd(10)
t.seth(72)
t.begin_fill()
t.color("blue")
t.circle(-150 / math.cos(18 * math.pi / 180))
t.end_fill()
t.seth(0)
t.begin_fill()
t.color("red")
for i in range(5):
t.fd(300)
t.rt(144)
t.end_fill()
t.exitonclick()
if __name__ == '__main__':
main()
成果:
总结:
理解几个函数:
turtle.pu()
turtle.pd()
turtle.fd()
turtle.seth()
turtle.left() or turtle.lt()
turtle.right() or turtle.rt()
turtle.begin_fill()
turtle.end_fill()
……海龟的的方向和画板的 x/y轴正方向
海龟的初始方向- 注意的几个地方
绝对角度(seth())和相对角度(right() / left())
几个成对出现的函数
位置和大小就需要自己确定和计算啦