詳解Python如何利用turtle繪制中國(guó)結(jié)
導(dǎo)語
春節(jié)是中國(guó)特有的傳統(tǒng)節(jié)日,中國(guó)結(jié)是中華民族特有的純粹的文化精髓,富含豐富的文化底蘊(yùn),代表著我們對(duì)未來,對(duì)美好生活的向往和憧憬。新春佳節(jié),小編祝福大家虎年吉祥!萬事如意!祝我們的祖國(guó)引領(lǐng)世界,勇立潮頭!國(guó)富民強(qiáng)!

漸漸的,漸漸的,新年很快就要到來。在快過新年時(shí),人們有一個(gè)習(xí)俗,那就是買“中國(guó)結(jié)”。
據(jù)說,中國(guó)結(jié)可以讓一家人平平安安、幸福,所以,中國(guó)結(jié)就一直為人們喜愛。
中國(guó)結(jié)制作十分精巧、巧妙,令人嘆為觀止。今天小編用代碼給大家編制拜年禮物繪制多種《中國(guó)結(jié)合集》啦~

一、中國(guó)結(jié) 01 平安喜樂
1)效果圖

2)附代碼
import turtle
turtle.screensize(600,800)
turtle.pensize(10)
turtle.pencolor("red")
turtle.seth(-45)
turtle.fd(102)
turtle.circle(-6,180)
turtle.fd(102)
turtle.circle(6,180)
turtle.fd(102)
turtle.circle(-6,180)
turtle.fd(102)
turtle.circle(6,180)
turtle.fd(102)
turtle.circle(-6,180)
turtle.fd(102)
turtle.circle(6,180)
turtle.fd(92)
turtle.circle(-6,270)
turtle.fd(92)
turtle.circle(6,180)
turtle.fd(102)
turtle.circle(-6,180)
turtle.fd(102)
turtle.circle(6,180)
turtle.fd(102)
turtle.circle(-6,180)
turtle.fd(102)
turtle.circle(6,180)
turtle.fd(102)
turtle.circle(-6,180)
turtle.fd(88)
turtle.fd(20)
turtle.seth(135)
turtle.fd(20)
turtle.seth(225)
turtle.fd(20)
turtle.seth(315)
turtle.fd(20)
turtle.seth(45)
turtle.fd(20)
turtle.seth(135)
turtle.begin_fill()
turtle.fillcolor("red")
turtle.fd(50)
turtle.seth(45)
turtle.fd(30)
turtle.seth(-45)
turtle.fd(30)
turtle.seth(225)
turtle.fd(30)
turtle.end_fill()
turtle.seth(90)
turtle.fd(40)
turtle.pensize(20)
turtle.fd(10)
turtle.pensize(5)
turtle.seth(105)
turtle.fd(30)
turtle.circle(-8,240)
turtle.circle(20,20)
turtle.fd(5)
turtle.circle(20,60)
turtle.fd(25)
turtle.penup()
turtle.setx(0)
turtle.sety(0)
turtle.goto(2,-127)
turtle.pendown()
turtle.pensize(5)
turtle.begin_fill()
turtle.fillcolor("red")
turtle.seth(0)
turtle.fd(15)
turtle.seth(-90)
turtle.fd(10)
turtle.seth(180)
turtle.fd(15)
turtle.seth(90)
turtle.fd(10)
turtle.seth(0)
turtle.fd(15)
turtle.end_fill()
turtle.pensize(2)
for x in range(6):
turtle.seth(-90)
turtle.fd(50)
turtle.penup()
turtle.seth(90)
turtle.fd(50)
turtle.seth(180)
turtle.fd(3)
turtle.pendown()
二、中國(guó)結(jié) 02 心想事成
1)效果圖

2)附代碼
import turtle as t
def goto(x,y):
t.penup()
t.goto(x,y)
t.pendown()
def init():
t.setup(800,800)
t.pensize(10)
t.pencolor("red")
t.speed(14)
def jiexin():
m,n=0,200
for i in range(11):
goto(m,n)
t.seth(-45)
t.fd(200)
m-=20/pow(2,0.5)
n-=20/pow(2,0.5)
m,n=0,200
for j in range(11):
goto(m,n)
t.seth(-135)
t.fd(200)
m+=20/pow(2,0.5)
n-=20/pow(2,0.5)
def jiexiaoban():
m=-20/pow(2,0.5)
n=200-20/pow(2,0.5)
for k in range(4):
goto(m,n)
t.seth(135)
t.fd(20)
t.circle(10,180)
t.fd(20)
m-=40/pow(2,0.5)
n-=40/pow(2,0.5)
m=20/pow(2,0.5)
n=200-20/pow(2,0.5)
for k in range(4):
goto(m,n)
t.seth(45)
t.fd(20)
t.circle(-10,180)
t.fd(20)
m+=40/pow(2,0.5)
n-=40/pow(2,0.5)
m=20/pow(2,0.5)
n=200-200*pow(2,0.5)+20/pow(2,0.5)
for k in range(4):
goto(m,n)
t.seth(-45)
t.fd(20)
t.circle(10,180)
t.fd(20)
m+=40/pow(2,0.5)
n+=40/pow(2,0.5)
m=-20/pow(2,0.5)
n=200-200*pow(2,0.5)+20/pow(2,0.5)
for k in range(4):
goto(m,n)
t.seth(-135)
t.fd(20)
t.circle(-10,180)
t.fd(20)
m-=40/pow(2,0.5)
n+=40/pow(2,0.5)
def waiyuan():
goto(90*pow(2,0.5),200-110*pow(2,0.5))
t.seth(-45)
t.circle(20,270)
goto(-90*pow(2,0.5),200-110*pow(2,0.5))
t.seth(-135)
t.circle(-20,270)
goto(80*pow(2,0.5),200-120*pow(2,0.5))
t.seth(-45)
t.circle(40,270)
goto(-80*pow(2,0.5),200-120*pow(2,0.5))
t.seth(-135)
t.circle(-40,270)
def shengzi():
goto(0,200)
t.pensize(20)
t.seth(90)
t.fd(60)
goto(0,320)
t.pensize(12)
t.seth(180)
t.circle(30,360)
goto(0,200-200*pow(2,0.5))
t.pensize(40)
t.seth(-90)
t.fd(20)
t.pensize(2)
s=-20
for i in range(11):
goto(s,200-200*pow(2,0.5))
t.seth(-90)
t.fd(200)
s+=4
def hanzi():
goto(-150,325)
t.write("幸福中國(guó)結(jié)",font=("Arial",40,"normal"))
def main():
init()
jiexin()
jiexiaoban()
waiyuan()
shengzi()
hanzi()
t.hideturtle()三、中國(guó)結(jié) 03 煙火年年
?辭慕爾爾,煙火年年,前程似錦,順?biāo)炜蛋病?/p>

總結(jié)
最后祝大家:大吉大利,平安喜樂,錦鯉附體,好事發(fā)生,發(fā)個(gè)大財(cái),心想事成!
到此這篇關(guān)于詳解Python如何利用turtle繪制中國(guó)結(jié)的文章就介紹到這了,更多相關(guān)Python turtle繪制中國(guó)結(jié)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Python使用面向?qū)ο蠓绞絼?chuàng)建線程實(shí)現(xiàn)12306售票系統(tǒng)
目前python 提供了幾種多線程實(shí)現(xiàn)方式 thread,threading,multithreading ,其中thread模塊比較底層,而threading模塊是對(duì)thread做了一些包裝,可以更加方便的被使用2015-12-12
關(guān)于python tushare Tkinter構(gòu)建的簡(jiǎn)單股票可視化查詢系統(tǒng)(Beta v0.13)
這篇文章主要介紹了python tushare Tkinter構(gòu)建的簡(jiǎn)單股票可視化查詢系統(tǒng)(Beta v0.13),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-10-10
python數(shù)據(jù)分析之單因素分析線性擬合及地理編碼
這篇文章主要介紹了python數(shù)據(jù)分析之單因素分析線性擬合及地理編碼,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下2022-06-06
詳解字典樹Trie結(jié)構(gòu)及其Python代碼實(shí)現(xiàn)
Trie多被用來查找和統(tǒng)計(jì)字符串,利用公共前綴來減少搜索時(shí)間,下面我們就來詳解字典樹Trie結(jié)構(gòu)及其Python代碼實(shí)現(xiàn)2016-06-06
python中enumerate函數(shù)遍歷元素用法分析
這篇文章主要介紹了python中enumerate函數(shù)遍歷元素用法,結(jié)合實(shí)例形式分析了enumerate函數(shù)遍歷元素的相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2016-03-03

