
1、用函数说明画笔的起始位置和下次落笔位置。
2、定义具体的坐标轴。定义颜色、弧度度数、弧度数、图形大小。
3、定义月饼上写的字。
4、开始用上面定义的函数画月饼。
实例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import turtle
turtle.pensize(2)
def goto(x, y):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
def rad():
goto(0, 0)
turtle.color( "#DAA520" ) #色号可搜索喜欢的颜色
for _ in range(30):
turtle.left(12)
turtle.begin_fill()
turtle.forward(200)
turtle.circle(25, 180)
turtle.goto(0, 0)
turtle.left(180)
turtle.end_fill()
def wirte():
goto(-40, -40)
turtle.color( "black" )
turtle.write( "祝:\n\n各位中秋节快乐,\n吉祥如意!" , font=( "Time" ,15, "bold" ))
turtle.done()
if __name__ == '__main__' :
turtle.speed(60)
rad()
wirte()
turtle.done()
|
以上就是python使用turtle画月饼的方法,希望对大家有所帮助。更多Python学习指路:python基础教程
本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。