手機相冊圣誕樹怎么畫以及蘋果手機畫圣誕樹教程


本站AI自動判斷提供您所需要的app下載:點我下載安裝,你懂的APP

圣誕樹,是指用燈燭和裝飾品把樅樹或洋松裝點起來的常青樹。作為是圣誕節(jié)重要的組成元素之一,近代圣誕樹起源于德國,后來逐步在世界范圍內流行起來,成為圣誕節(jié)慶祝中最有名的傳統(tǒng)之一。

今天是平安夜,明天就是圣誕節(jié),這兩天應該是蘋果最暢銷的日子 ...

提到圣誕節(jié),就不得不提圣誕樹,本文我們用 Python 來畫一棵圣誕樹,先睹為快。

下面展開來看一下主要代碼實現(xiàn)。

圣誕樹主要代碼實現(xiàn)如下:

# 畫第一層 seth(-120) for i in range(10): fd(12) right(2) penup() goto(0, 150) seth(-60) pendown() for i in range(10): fd(12) left(2) seth(-150) penup() fd(10) pendown() for i in range(5): fd(10) right(15) seth(-150) penup() fd(8) pendown() for i in range(5): fd(10) right(15) seth(-155) penup() fd(5) pendown() for i in range(5): fd(7) right(15) # 畫第二層 penup() goto(-55, 34) pendown() seth(-120) for i in range(10): fd(8) right(5) penup() goto(50, 35) seth(-60) pendown() for i in range(10): fd(8) left(5) seth(-120) penup() fd(10) seth(-145) pendown() for i in range(5): fd(10) right(15) penup() fd(10) seth(-145) pendown() for i in range(5): fd(12) right(15) penup() fd(8) seth(-145) pendown() for i in range(5): fd(10) right(15) penup() seth(-155) fd(8) pendown() for i in range(5): fd(11) right(15) ......

五角星主要代碼實現(xiàn)如下:

pensize(2) pencolor("yellow") penup() goto(x, y) pendown() begin_fill() fillcolor("yellow") for i in range(5): left(72) fd(size) right(144) fd(size) end_fill()

帽子主要代碼實現(xiàn)如下:

penup() goto(-30, -120) pencolor("white") pendown() fillcolor("white") begin_fill() fd(30) circle(4, 180) fd(30) circle(4, 180) end_fill() penup() goto(-25, -115) seth(75) pendown() fillcolor("red") begin_fill() for i in range(5): fd(6) right(20) seth(-10) for i in range(5): fd(8) right(15) seth(145) for i in range(5): fd(5) left(2) seth(90) for i in range(5): fd(1) left(2) seth(-90) for i in range(4): fd(4) right(6) seth(161) fd(30) end_fill() pensize(1) pencolor("white")

襪子主要代碼實現(xiàn)如下:

penup() goto(-20, 80) pencolor("white") pendown() begin_fill() fillcolor("white") fd(25) circle(4, 180) fd(25) circle(4, 180) end_fill() penup() goto(-15, 80) pendown() begin_fill() fillcolor("red") seth(-120) fd(20) seth(150) fd(5) circle(7, 180) fd(15) circle(5, 90) fd(30) seth(160) fd(18) end_fill() penup() seth(0) goto(70, -240)

蝴蝶結主要代碼實現(xiàn)如下:

penup() pencolor("#f799e6") goto(x, y) seth(80) pendown() pensize(2) circle(5) seth(10) fd(15) seth(120) fd(20) seth(240) fd(20) seth(180) fd(20) seth(-60) fd(20) seth(50) fd(20) seth(-40) fd(30) seth(-130) fd(5) seth(135) fd(30) seth(-60) fd(30) seth(-150) fd(6) seth(110) fd(30)

雪落效果主要代碼實現(xiàn)如下:

screen.delay(0) t = Turtle(visible = False,shape='circle') t.pencolor("white") t.fillcolor("white") t.penup() t.setheading(-90) t.goto(r.randint(-width/2,width/2),height/2) stars = [] for i in range(200): star = t.clone() s =r.random() / 3 star.shapesize(s,s) star.speed(int(s*10)) star.setx(r.randint(-width/2,width/2)) star.sety(height/2 + r.randint(1,height)) star.showturtle() stars.append(star) while True: for star in stars: star.sety(star.ycor() - 8 * star.speed()) if star.ycor()<-height/2: star.hideturtle() star.setx(r.randint(-width/2,width/2)) star.sety(height/2 + r.randint(1,height)) star.showturtle()

以上就是圣誕樹的主要Python代碼實現(xiàn)部分,當然我們還可以為其添加背景音樂,這里就不細說了,感興趣的可以參考:圣誕樹添加背景音樂。

完整代碼已經打包整理好了,有需要的可以私信“666” 直接獲取。