大家好,小编来为大家解答以下问题,编程流星雨特效怎么弄,python流星雨特效代码,今天让我们一起来看看吧!
import turtle as t
import random as r
import math
t.speed(990000*99999)
t.bgcolor('black')
t.colormode(255)
t.pensize(50)
for i in range(0,255):
t.color(i,i,i)
t.up()
t.goto(-400,250-2.5*i)
t.down()
t.forward(1000)
t.penup()
t.goto(450, -1030)
t.seth(90)
t.color('#816745')
t.begin_fill()
t.circle(800,200)
t.end_fill()
t.color('white')
t.pensize(5)
t.penup()
t.goto(-160, -250)
t.seth(110)
t.pendown()
t.forward(80)
t.seth(30)
t.circle(40, 300)
t.seth(-110)
t.forward(80)
t.penup()
t.color('black')
t.goto(-190, -145)
t.seth(110)
t.forward(25)
t.penup()
t.goto(-200, -160)
t.seth(30)
t.pensize(8)
t.color('pink')
t.pendown()
t.forward(10)
t.penup()
t.goto(-200, -210)
t.pendown()
t.pensize(1)
t.color('red','red')
t.begin_fill()
t.seth(45)
t.forward(10)
t.circle(5, 180)
t.right(90)
t.circle(5, 180)
t.forward(4)
t.end_fill()
for i in range(0,255):
t.pensize(2) # 流星的大小
t.penup() # 提笔
x = r.randint(-330,340) #流星的横坐标
y = r.randint(50,320) #流星的纵坐标
t.goto(x, y) # 随机位置
t.pendown() # 落笔
red = r.randint(100,255)
white = r.randint(100,255)
green = r.randint(100,255)
t.color(red, white, green)
t.penup()
t.goto(x,y)
t.pendown()
t.goto(x-50, y-30)
t.color('white')
t.penup()
t.goto(60, -110)
t.pendown()
t.write("As you wish,dui",font=('MV Boli',30,'bold'))
#t.hideturtle()
import random
from numpy.random import rand, randint
from matplotlib.collections import LineCollection
import tkinter as tk
import numpy as np
import matplotlib.pyplot as plt
# colors=['red','blue','yellow','black','orange']
# t=turtle.screensize(600,375,'white')
# class starssss:
# def __init__(self):
# self.r = range.randint(50,100)
# self.t = range.randint(1,3)
# self.x = range.randint(-2000,1000) #流星的横坐标
# self.y = range.randint(0,500) #流星的纵坐标
# self.speed = range.randint(5,10) #流星移动速度
# self.color = range.choice(colors) #流星的颜色
# self.outline = 1 #流星的大小
#
#
# def star(self): # 画流星函数
# t.pensize(self.outline) # 流星的大小
# t.penup() # 提笔
# t.goto(self.x, self.y) # 随机位置
# t.pendown() # 落笔
# t.color(self.color)
# t.begin_fill()
# t.fillcolor(self.color)
# t.setheading(-30)
# t.right(self.t)
# t.forward(self.r)
# t.left(self.t)
# t.circle(self.r * math.sin(math.radians(self.t)), 180)
# t.left(self.t)
# t.forward(self.r)
# t.end_fill()
#
# def move(self): #流星移动函数
# if self.y >= -500: #当流星还在画布中时
# self.y -= self.speed #设置上下移动速度
# self.x += 2*self.speed #设置左右移动速度
# else:
# self.r = range.randint(50,100)
# self.t = range.randint(1,3)
# self.x = range.randint(-2000,1000)
# self.y = 500
# self.speed = range.randint(5,10)
# self.color = range.choice(colors)
# self.outline = 1
# if __name__ == '__main__':
# starssss.move()
# from numpy.random import rand, randint
# from matplotlib.collections import LineCollection
#
# import numpy as np
# import matplotlib.pyplot as plt
#
# N, L = 200, 1000 # 流星个数和线段数
# ts = np.array([
# np.linspace(0, rand(), L) for _ in range(N)]).T
# x0, y0 = rand(2 * N).reshape(2, 1, N)
# x0 *= 5
# xs, ys = x0 + ts, y0 + ts # 绘图线条1
#
# points = np.array([xs, ys]).T.reshape(N, L, -1, 2)
#
# ax = plt.subplot()
# for i in range(N):
# segs = np.concatenate([points[i][:-1], points[i][1:]], axis=1)
# lc = LineCollection(segs, cmap='viridis')
# lc.set_array(ts[:, i])
# lc.set_linewidth(ts[::-1, i])
# ax.add_collection(lc)
#
# ax.set_xlim(0, 6)
# ax.set_ylim(-2, 3)
# ax.set_axis_off() # 取消坐标轴
# plt.show()