一、前言
2022年圣诞节到来啦,很高兴这次我们又能一起度过~,圣诞节源自古罗马人迎接新年的农神节,与基督教本无关系。在基督教盛行罗马帝国后,教廷将这种民俗节日纳入基督教体系,同时以庆祝耶稣的降生。但在圣诞节这天不是耶稣的生辰,因为《圣经》未记载耶稣具体出生时间,同样没提到过有此种节日,是基督教吸收了古罗马神话的结果。圣诞节是西方传统节日,也是许多西方国家一年中最重要的节日。每年这一天,欢快的圣诞歌在大街小巷飘扬,商场里流光溢彩,琳琅满目,到处弥漫着温馨欢乐的气息。孩子们在甜美的梦乡中,盼望着圣诞老人从天而降,带来梦寐以求的礼物。圣诞节作为西方的春节,那肯定是有很多的传统特色,各种各样的风俗传统中,最重要的就是圣诞树了,也是最有特色的,提起圣诞节那就必须提到圣诞树了,圣诞树作为圣诞节的传统,形式也更加应该多种多样起来,那么就来一个代码圣诞树吧!!
二、效果展示
三、编码实现
第一步
背景主体
# 1seth(-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)# 2penup()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)# 3penup()goto(-100, -40)seth(-120)pendown()for i in range(10):fd(6)right(3)penup()goto(80, -39)seth(-50)pendown()for i in range(10):fd(6)left(3)seth(-155)penup()fd(10)pendown()for i in range(5):fd(8)right(10)penup()fd(8)seth(-145)pendown()for i in range(7):fd(8)right(10)penup()fd(8)seth(-145)pendown()for i in range(7):fd(7)right(10)penup()fd(8)seth(-145)pendown()for i in range(7):fd(7)right(10)penup()fd(8)seth(-140)pendown()for i in range(7):fd(6)right(10) # 4penup()goto(-120, -95)seth(-130)pendown()for i in range(7):fd(10)right(5)penup()goto(100, -95)seth(-50)pendown()for i in range(7):fd(10)left(5)penup()seth(-120)fd(10)seth(-155)pendown()for i in range(6):fd(8)right(10)penup()seth(-160)fd(10)seth(-155)pendown()for i in range(6):fd(8)right(10)penup()seth(-160)fd(10)seth(-155)pendown()for i in range(6):fd(8)right(10)penup()seth(-160)fd(10)seth(-160)pendown()for i in range(6):fd(8)right(10)penup()seth(-160)fd(10)seth(-160)pendown()for i in range(6):fd(8)right(10)penup()seth(-160)fd(10)seth(-165)pendown()for i in range(5):fd(10)right(11)# 5penup()goto(-70, -165)seth(-85)pendown()for i in range(3):fd(5)left(3)penup()goto(70, -165)seth(-95)pendown()for i in range(3):fd(5)right(3)seth(-170)penup()fd(10)pendown()pendown()for i in range(10):fd(12)right(2)# 6penup()goto(70, -165)pendown()seth(-90)pensize(8)pencolor("#00cc00")circle(-20, 90) penup()goto(30, -185)pendown()seth(-180)pensize(8)pencolor("#00cc00")fd(40) penup()goto(-5, -170)pendown()seth(-180)pensize(8)pencolor("#00cc00")fd(35)def guest(x, y, z):penup()goto(x, y)seth(-z)pendown()for angel in range(5):fd(10)right(10)def guet(x, y, z):penup()goto(x, y)seth(-z)pendown()for angel in range(5):fd(10)left(10)def qu(x, y, z):penup()goto(x, y)seth(-z)pendown()for angel in range(5):fd(6)right(10)seth(-150)fd(20)
第二步
各种各样的小装饰品,在圣诞树加上各种各样自己喜欢的装饰品,让圣诞树变得更加华丽起来!!!首先:
树枝:
guest(-70, -150, 160)guest(100, -150, 160)guet(110, -110, 50)guest(160, -140, 150)qu(80, -120, 180)guest(70, -85, 165)guest(-40, -85, 165)guet(90, -50, 50)guest(130, -80, 150)pencolor("#00cc00")qu(-40, -60, 180)pencolor('#00cc00')qu(80, -30, 180)pencolor("#00cc00")qu(40, 10, 180)pencolor("#00cc00")guest(-60, 30, 120)guest(-20, -20, 150)guet(45, 40, 60)guest(-30, 40, 170)guest(-30, 110, 115)guet(40, 90, 60)guest(80, 50, 160)pencolor("red")def hdj(x, y):penup()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)def uit(x, y):penup()goto(x, y)pendown()pensize(2)circle(5)seth(-10)fd(15)seth(90)fd(15)seth(200)fd(15)seth(160)fd(15)seth(-90)fd(15)seth(10)fd(15)seth(-60)fd(20)seth(-180)fd(5)seth(110)fd(20)seth(-90)fd(20)seth(-180)fd(6)seth(70)fd(15)hideturtle()def yut(x, y, z):penup()goto(x, y)pendown()seth(z)for po in range(5):fd(4)left(36)def ytu(x, y, z):penup()goto(x, y)pendown()seth(z)for kk in range(5):fd(4)left(36)
大小蝴蝶结:
# 小蝴蝶结seth(0)uit(40, -160)hdj(-80, -120)yut(-67, -115, 120)yut(-86, -123, 150)hdj(40, -50)yut(52, -45, 130)yut(34, -55, 160)seth(0)pencolor("pink")uit(-20, -60)ytu(-4, -60, 100)ytu(-20, -60, 120)hdj(-30, 20)yut(-15, 25, 130)yut(-40, 20, 180)uit(30, 70)ytu(45, 70, 100)ytu(30, 70, 120) # 大蝴蝶结pencolor("yellow")pensize(5)penup()seth(0)goto(0, 150)pendown()circle(10)seth(-15)fd(40)seth(90)fd(40)seth(200)fd(40)seth(160)fd(40)seth(-90)fd(40)seth(15)fd(40)seth(-70)pencolor("yellow")pensize(4)fd(40)seth(-180)fd(10)seth(100)fd(40)seth(-100)fd(40)seth(-180)fd(10)seth(70)fd(40)penup()seth(0)goto(0, 130)pencolor("yellow")pendown()def iou(x, y, z):penup()goto(x, y)pencolor("yellow")pendown()seth(z)for po in range(10):fd(4)left(18)seth(0)iou(35, 145, 100)iou(-7, 145, 110)pencolor("red")pensize(7)penup()goto(-35, 135)pendown()
圣诞节怎么能没有圣诞帽呢
seth(-20)pensize(2)penup()goto(-30, -120)pencolor("white")pendown()fillcolor("red")fd(30)circle(4, 180)fd(30)circle(4, 180)penup()goto(-25, -115)seth(75)pendown()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")def koc(x, y, size):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()
当然也可以加点其他的
# 星星seth(-15)koc(-120, -70, 10)seth(10)koc(100, -20, 10)seth(-10)koc(10, 40, 10)seth(30)koc(-80, 60, 10)koc(100, -150, 10)koc(-140, -150, 10)koc(20, 120, 10) # 袜子seth(-20)pensize(2)penup()goto(-20, 80)pencolor("white")pendown()fillcolor("red")fd(25)circle(4, 180)fd(25)circle(4, 180)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(100, -230)pendown()
最后完整代码呈上:
import turtle as tfrom turtle import *import random as rimport time t.title("Merry Christmas")screensize(bg='black')#背景颜色setup(700, 700, startx=None, starty=None)speed("fastest")pencolor("#008500")pensize(10)penup()hideturtle()goto(0, 150)showturtle()pendown()shape(name="classic")# 1seth(-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)# 2penup()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)# 3penup()goto(-100, -40)seth(-120)pendown()for i in range(10):fd(6)right(3)penup()goto(80, -39)seth(-50)pendown()for i in range(10):fd(6)left(3)seth(-155)penup()fd(10)pendown()for i in range(5):fd(8)right(10)penup()fd(8)seth(-145)pendown()for i in range(7):fd(8)right(10)penup()fd(8)seth(-145)pendown()for i in range(7):fd(7)right(10)penup()fd(8)seth(-145)pendown()for i in range(7):fd(7)right(10)penup()fd(8)seth(-140)pendown()for i in range(7):fd(6)right(10) # 4penup()goto(-120, -95)seth(-130)pendown()for i in range(7):fd(10)right(5)penup()goto(100, -95)seth(-50)pendown()for i in range(7):fd(10)left(5)penup()seth(-120)fd(10)seth(-155)pendown()for i in range(6):fd(8)right(10)penup()seth(-160)fd(10)seth(-155)pendown()for i in range(6):fd(8)right(10)penup()seth(-160)fd(10)seth(-155)pendown()for i in range(6):fd(8)right(10)penup()seth(-160)fd(10)seth(-160)pendown()for i in range(6):fd(8)right(10)penup()seth(-160)fd(10)seth(-160)pendown()for i in range(6):fd(8)right(10)penup()seth(-160)fd(10)seth(-165)pendown()for i in range(5):fd(10)right(11)# 5penup()goto(-70, -165)seth(-85)pendown()for i in range(3):fd(5)left(3)penup()goto(70, -165)seth(-95)pendown()for i in range(3):fd(5)right(3)seth(-170)penup()fd(10)pendown()pendown()for i in range(10):fd(12)right(2)# 6penup()goto(70, -165)pendown()seth(-90)pensize(8)pencolor("#00cc00")circle(-20, 90) penup()goto(30, -185)pendown()seth(-180)pensize(8)pencolor("#00cc00")fd(40) penup()goto(-5, -170)pendown()seth(-180)pensize(8)pencolor("#00cc00")fd(35)def guest(x, y, z):penup()goto(x, y)seth(-z)pendown()for angel in range(5):fd(10)right(10)def guet(x, y, z):penup()goto(x, y)seth(-z)pendown()for angel in range(5):fd(10)left(10)def qu(x, y, z):penup()goto(x, y)seth(-z)pendown()for angel in range(5):fd(6)right(10)seth(-150)fd(20)# 树枝guest(-70, -150, 160)guest(100, -150, 160)guet(110, -110, 50)guest(160, -140, 150)qu(80, -120, 180)guest(70, -85, 165)guest(-40, -85, 165)guet(90, -50, 50)guest(130, -80, 150)pencolor("#00cc00")qu(-40, -60, 180)pencolor('#00cc00')qu(80, -30, 180)pencolor("#00cc00")qu(40, 10, 180)pencolor("#00cc00")guest(-60, 30, 120)guest(-20, -20, 150)guet(45, 40, 60)guest(-30, 40, 170)guest(-30, 110, 115)guet(40, 90, 60)guest(80, 50, 160)pencolor("red")def hdj(x, y):penup()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)def uit(x, y):penup()goto(x, y)pendown()pensize(2)circle(5)seth(-10)fd(15)seth(90)fd(15)seth(200)fd(15)seth(160)fd(15)seth(-90)fd(15)seth(10)fd(15)seth(-60)fd(20)seth(-180)fd(5)seth(110)fd(20)seth(-90)fd(20)seth(-180)fd(6)seth(70)fd(15)hideturtle()def yut(x, y, z):penup()goto(x, y)pendown()seth(z)for po in range(5):fd(4)left(36)def ytu(x, y, z):penup()goto(x, y)pendown()seth(z)for kk in range(5):fd(4)left(36)# 小蝴蝶结seth(0)uit(40, -160)hdj(-80, -120)yut(-67, -115, 120)yut(-86, -123, 150)hdj(40, -50)yut(52, -45, 130)yut(34, -55, 160)seth(0)pencolor("pink")uit(-20, -60)ytu(-4, -60, 100)ytu(-20, -60, 120)hdj(-30, 20)yut(-15, 25, 130)yut(-40, 20, 180)uit(30, 70)ytu(45, 70, 100)ytu(30, 70, 120) # 大蝴蝶结pencolor("yellow")pensize(5)penup()seth(0)goto(0, 150)pendown()circle(10)seth(-15)fd(40)seth(90)fd(40)seth(200)fd(40)seth(160)fd(40)seth(-90)fd(40)seth(15)fd(40)seth(-70)pencolor("yellow")pensize(4)fd(40)seth(-180)fd(10)seth(100)fd(40)seth(-100)fd(40)seth(-180)fd(10)seth(70)fd(40)penup()seth(0)goto(0, 130)pencolor("yellow")pendown()def iou(x, y, z):penup()goto(x, y)pencolor("yellow")pendown()seth(z)for po in range(10):fd(4)left(18)seth(0)iou(35, 145, 100)iou(-7, 145, 110)pencolor("red")pensize(7)penup()goto(-35, 135)pendown() # 圣诞帽seth(-20)pensize(2)penup()goto(-30, -120)pencolor("white")pendown()fillcolor("red")fd(30)circle(4, 180)fd(30)circle(4, 180)penup()goto(-25, -115)seth(75)pendown()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")def koc(x, y, size):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()# 星星seth(-15)koc(-120, -70, 10)seth(10)koc(100, -20, 10)seth(-10)koc(10, 40, 10)seth(30)koc(-80, 60, 10)koc(100, -150, 10)koc(-140, -150, 10)koc(20, 120, 10) # 袜子seth(-20)pensize(2)penup()goto(-20, 80)pencolor("white")pendown()fillcolor("red")fd(25)circle(4, 180)fd(25)circle(4, 180)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(100, -230)pendown() pencolor("yellow")write("Merry Christmas To You", align="center", font=("Comic Sans MS", 24, "bold")) def drawsnow():t.ht()# 隐藏笔头t.pensize(2)for i in range(70):t.pencolor("white")t.pu()# 提笔t.setx(r.randint(-350, 350))t.sety(r.randint(-80, 350))t.pd()# 落笔dens = 6# 雪花瓣数设为6snowsize = r.randint(1, 10)for j in range(dens):t.fd(int(snowsize))t.backward(int(snowsize))t.right(int(360 / dens))# 转动角度 drawsnow()done()
感谢大家支持,求个赞吧!!!
大家也可以自行将你喜欢的东西加在圣诞树上!!
圣诞节了已经来了 ,那么春节还会远吗?
圣诞节的由来(基督教纪念耶稣诞生的重要节日。亦称耶稣圣诞节、主降生节,天主教亦称耶稣圣诞瞻礼。耶稣诞生的日期,《圣经》并无记载。公元336年罗马教会开始在12月25日过此节。12月25日原是罗马帝国规定的太阳神诞辰。有人认为选择这天庆祝圣诞,是因为基督教徒认为耶稣就是正义、永恒的太阳。5世纪中叶以后,圣诞节作为重要节日,成了教会的传统,并在东西派教会中逐渐传开。因所用历法不同等原因,各教派会举行庆祝的具体日期和活动形式也有差别。圣诞节习俗传播到亚洲主要是在十九世纪中叶,日本、韩国等都受到了圣诞文化的影响。现在西方在圣诞节常互赠礼物,举行欢宴,并以圣诞老人、圣诞树等增添节日气氛,已成为普遍习俗。圣诞节也成为西方世界以及其他很多地区的公共假日。)