您好,登錄后才能下訂單哦!
這篇文章主要介紹“怎么用Python turtle繪制中國結”,在日常操作中,相信很多人在怎么用Python turtle繪制中國結問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”怎么用Python turtle繪制中國結”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!
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()
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("幸福中國結",font=("Arial",40,"normal")) def main(): init() jiexin() jiexiaoban() waiyuan() shengzi() hanzi() t.hideturtle()
辭慕爾爾,煙火年年,前程似錦,順遂康安。
到此,關于“怎么用Python turtle繪制中國結”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注億速云網站,小編會繼續努力為大家帶來更多實用的文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。