用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - python代码库

圣诞贺卡制作

2020-12-21 作者: 德辉爱编程举报

[python]代码库

import turtle as T
import random
import time
	

t = T.Turtle()

w = T.Screen()
t.hideturtle()  
t.getscreen().tracer(5, 0)
w.screensize(bg='maroon')
t.left(90)
t.up()
t.forward(280)
t.down()
t.pensize(3)


n=100
t.color("orange","yellow")
t.begin_fill()
t.left(126)

for i in range(5):
	t.forward(n/5)
	t.right(144)
	t.forward(n/5)
	t.left(71)
t.end_fill()
t.left(60)
t.pensize(8)
t.forward(60)
t.right(20)
t.right(116)
t.pensize(6)


t.color('dark green')
n=130

for i in range(6):
	time.sleep(0.5)
	a=1+i/2
	t.begin_fill()
	t.left(90)
	t.forward(n*a*0.707)
	t.left(135)
	t.forward(n*a)
	t.left(135)
	t.forward(n*a*0.707)
	t.end_fill()
	t.up()
	t.left(90)
	t.forward(n*a*0.707/3)
	t.left(135)
	t.forward(n*a/6)
	t.left(135)
	t.down()


t.up()
t.right(135)
t.forward(30)
t.right(90)
t.forward(157)
t.down()
t.color('saddlebrown')
t.begin_fill()
t.forward(80)
t.right(90)
t.forward(45)
t.right(90)
t.forward(80)
t.right(90)
t.forward(45)
t.end_fill()

t.up()
t.backward(45)
t.right(90)
t.backward(470)
t.down()


def light(l,t):
	t.pensize(3)
	colors = ["magenta","darkorange","red","blue"]
	for i in range(l):
		time.sleep(0.2)
		b = 70+16*i
		a = b/2*random.randint(-100,100)/100
		t.up()
		t.forward(b)
		t.left(90)
		t.forward(a)
		t.down()
		t.color("lightyellow",colors[i%4])
		t.begin_fill()
		t.circle(10)
		t.end_fill()
		t.up()
		t.backward(a)
		t.right(90)
		t.backward(b)
		t.down()
	t.pensize(1)


def snow(m,t):
    for i in range(m):
        a = 400 - 800 * random.random()
        b = 600 - 800 * random.random()
        t.up()
        t.forward(b)
        t.left(90)
        t.forward(a)
        t.down()
        t.color('white')
        t.begin_fill()
        t.circle(1)
        t.end_fill()
        t.up()
        t.backward(a)
        t.right(90)
        t.backward(b)

light(24,t)
snow(600, t)


t.goto(-200,200)
my_word = ("Merry Christmas")
t.write(my_word,font=("Edwardian Script ITC",40,"bold"))
time.sleep(0.3)
t.goto(-100,50)
my_word = ("and")
t.write(my_word,font=("Edwardian Script ITC",50,"bold"))
time.sleep(0.3)
t.goto(-150,-100)
my_word = ("Happy New Year")
t.write(my_word,font=("Edwardian Script ITC",40,"bold"))

time.sleep(0.3)
t.clear()
w.screensize(bg='black')
t.goto(-200,0)
my_word = ("Prudued by: tudehui")
t.write(my_word,font=("Edwardian Script ITC",45,"bold"))
t.goto(0,-100)
my_word = ("Dec. 24th, 2020")
t.write(my_word,font=("Edwardian Script ITC",20,"bold"))

time.sleep(5)


网友评论    (发表评论)


发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...