圣诞节大白祝福程序
我想和你一起去程序中度假,让我们感受工科生的浪漫哦。
最好的爱情大概就是这样,你陪我走过一无所有,我陪你走到岁月尽头。
程序代码如下
import turtle as m
import time
# 初始化画布
m.setup(width=800, height=600)
time.sleep(1)
m.hideturtle()
m.penup()
m.goto(-300,220)
color=['yellow','red','blue']
words1 = '当 '
words2 = ['送','给','小','朋','友'] #可以修改送的人的名字
for i in range(3):
m.pencolor(color[i])
m.write(words1, font=("华文彩云", 4*i+14, "bold"))
m.fd(20+3*i)
time.sleep(0.1)
m.fd(8)
m.write("!", font=("华文彩云", 23, "bold"))
m.fd(20)
for word in words2:
m.pencolor(color[1])
m.write(word, font=("华文彩云", 26, "bold"))
m.fd(35)
time.sleep(0.4)
m.write(":", font=("华文彩云", 23, "bold"))
m.fd(35)
#大白的头
m.goto(-100,150)
m.rt(90)
m.color("black")
m.pensize(1)
m.pd()
size = 0.6
a = 0.8*size
for i in range(120):
if 0<=i<30 or 60<=i<90:
a = a+0.2*size
m.left(3) # 向左转3度
m.fd(a) # 向前走a的步长
else:
a = a-0.2*size
m.left(3)
m.fd(a)
m.penup()
#眼睛
m.goto(-70,150)
m.dot(14)
time.sleep(0.1)
m.goto(-24,150)
m.dot(14)
m.rt(60)
m.pd()
m.speed(0)
m.circle(-50,50)
#身体
m.penup()
m.goto(-89.85,131.47)
m.left(65)
m.pd()
m.circle(250,60)
m.penup()
m.goto(-2.64,133.09)
m.left(30)
m.pd()
m.circle(-250,60)
m.rt(20)
m.circle(-134,110)
#腿
m.penup()
m.left(135)
m.goto(-120,-145)
m.pd()
m.circle(120,45)
m.left(15)
m.circle(42,80)
m.left(50)
m.fd(70)
m.penup()
m.back(70)
m.pd()
m.rt(130)
m.circle(42,80)
m.left(15)
m.circle(115,48)
m.penup()
#胳膊
m.goto(-125,89)
m.pd()
m.left(112)
m.circle(250,50)
m.circle(50,45)
m.circle(20,80)
m.circle(50,45)
m.circle(180,16)
m.penup()
m.goto(31,90)
m.pd()
m.rt(126)
m.circle(-250,50)
m.circle(-50,45)
m.circle(-20,80)
m.circle(-50,45)
m.circle(-180,14)
#手
m.penup()
m.goto(-208,-90)
m.pd()
m.left(150)
m.rt(180)
m.circle(-30,20)
m.penup()
m.goto(-208,-90)
m.rt(160)
m.pd()
m.circle(30,40)
m.circle(5,120)
m.circle(40,40)
#画玫瑰
m.penup()
m.goto(-270,60)
m.pd()
m.rt(60)
size=0.35
# 花蕊
m.fillcolor("#EE0000")
m.begin_fill()
m.circle(10*size, 180)
m.circle(25*size, 110)
m.left(50)
m.circle(60*size, 45)
m.circle(20*size, 170)
m.rt(24)
m.fd(30*size)
m.left(10)
m.circle(30*size, 110)
m.fd(20*size)
m.left(40)
m.circle(90*size, 70)
m.circle(30*size, 150)
m.rt(30)
m.fd(15*size)
m.circle(80*size, 90)
m.left(15)
m.fd(45*size)
m.rt(165)
m.fd(20*size)
m.left(155)
m.circle(150*size, 80)
m.left(50)
m.circle(150*size, 90)
m.end_fill()
# 花瓣1
m.left(150)
m.circle(-90*size, 70)
m.left(20)
m.circle(75*size, 105)
m.setheading(80)
m.circle(80*size, 98)
m.circle(-90*size, 40)
# 花瓣2
m.left(180)
m.circle(90*size, 40)
m.circle(-80*size, 98)
m.setheading(-63.5)
# 叶子1
m.fd(30*size)
m.left(90)
m.fd(25*size)
m.left(45)
m.fillcolor("#00CD00")
m.begin_fill()
m.circle(-80*size, 90)
m.rt(90)
m.circle(-80*size, 90)
m.end_fill()
m.rt(135)
m.fd(60*size)
m.left(180)
m.penup()
m.fd(85*size)
m.pd()
m.left(90)
m.fd(80*size)
# 叶子2
m.rt(90)
m.rt(45)
m.fillcolor("#00CD00")
m.begin_fill()
m.circle(80*size, 90)
m.left(90)
m.circle(80*size, 90)
m.end_fill()
m.left(135)
m.fd(60*size)
m.left(180)
m.fd(60*size)
m.rt(90)
m.circle(-1000*size,8.6)
m.penup()
m.goto(-200,-110)
m.pd()
m.circle(-1000*size,10)
#圣诞快乐
words3 = ['圣 ','诞 ','快 ','乐 ','呦 ','!'] #可以修改祝福语
m.penup()
m.color("#FF6A6A")
m.goto(30,220)
m.setheading(0)
for word in words3:
m.write(word, font=("华文彩云", 30, "bold"))
m.fd(35)
time.sleep(0.4)
m.done()
喜欢的话,可以关注一下哦!