前言
马上就要中秋节了,在外漂泊的各位小伙伴也没有时间能赶回家陪陪家人,但是出门在外,月饼还是要吃的呀,给掘金的每个小伙伴送上给种口味样式的月饼,白又白已经帮你端上餐桌了,各位大大请品尝!!!! 
效果展示
 
工具使用
开发工具:pycharm 开发环境:python3.7, Windows10 使用工具包:turtle
学习思路解析
现在脑海里有月饼的基本形状 先准备画出月饼的花边,向日葵的波浪形 可以把这个图形分解成圆弧形状的,也圆心进行偏移  找到圆心,循环画出所有的形状,绘制出一个正圆 
def huabian():
goto(0,0)
turtle.color("orange")
for _ in range(20):
turtle.right(18)
turtle.begin_fill()
turtle.forward(220)
turtle.circle(40,180)
turtle.goto(0,0)
turtle.right(180)
turtle.end_fill()
在给每个月饼添加上装饰的圆圈画圆的话相对简单 确定起点画圆圈就行 
def yuan():
turtle.color("#8fdb75")
goto(0,-200)
turtle.begin_fill()
turtle.circle(200)
turtle.end_fill()
颜色搭配稍稍有点奇怪,大家见谅,有画向日葵的即视感  在给月饼添加上内部的装饰,添加上小花边,看起来更有食欲哈!!  图形也是单一的图像进行循环拼接
def huabian():
goto(0,0)
turtle.color("orange")
for _ in range(20):
turtle.right(18)
turtle.begin_fill()
turtle.forward(220)
turtle.circle(40,180)
turtle.goto(0,0)
turtle.right(180)
turtle.end_fill()
最后添加上我们喜欢的口味,蛋黄啊,喜欢草莓的你还可以加上草莓,要是不爱吃甜的你还可以加上红烧肉,红烧排骨,糖醋鲤鱼口味的,白又白就比较喜欢榴莲口味的给它加上 

简易源码分享
import turtle
def goto(x,y):
turtle.penup()
turtle.goto(x,y)
turtle.pendown()
def yuan():
turtle.color("#8fdb75")
goto(0,-200)
turtle.begin_fill()
turtle.circle(200)
turtle.end_fill()
def huabian():
goto(0,0)
turtle.color("orange")
for _ in range(20):
turtle.right(18)
turtle.begin_fill()
turtle.forward(220)
turtle.circle(40,180)
turtle.goto(0,0)
turtle.right(180)
turtle.end_fill()
def neitu():
turtle.color("#D1C185")
goto(0,-25)
for _ in range(12):
turtle.begin_fill()
turtle.circle(150,60)
turtle.left(90)
turtle.circle(150,60)
turtle.end_fill()
def wirte():
goto(-40,-20)
turtle.color("orange")
turtle.write('\n\n清馨\n榴莲',font=('Time',30,'bold'))
turtle.done()
if __name__ == '__main__':
turtle.speed(20)
huabian()
yuan()
neitu()
wirte()
turtle.done()
更多好玩的代码↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 
|