前言
馬上就要中秋節了,在外漂泊的各位小伙伴也沒有時間能趕回家陪陪家人,但是出門在外,月餅還是要吃的呀,給掘金的每個小伙伴送上給種口味樣式的月餅,白又白已經幫你端上餐桌了,各位大大請品嘗!!!!

效果展示


工具使用
開發工具: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()
更多好玩的代碼↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
關注公眾號:白又白學Python
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/301762.html
標籤:python
