首页 > 分享 > 一个程序教你花式示爱 2——99颗闪耀的真爱钻石

一个程序教你花式示爱 2——99颗闪耀的真爱钻石

希望大家使用这个程序时回复一句:愿南宫大大赐予我幸福(滑稽)。和我一样的恩爱狗,我会赐予你们幸福,单身狗的话我会赐予你一个女朋友(当然是虚拟的,滑稽)。当然咯,函数生成的图片我才不会给你们看呢,这是我和我女票的。

PS:程序如果运行出错,多半属于没有及时更新matplotlib函数库,请使用如下语句在cmd控制台安装:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -U matplotlib

import numpy as np

import matplotlib.pyplot as plt

from matplotlib.animation import FuncAnimation

import random

def outline_point():

ox=[]

oy=[]

random_cache=[]

random_num=[]

rox=[]

roy=[]

c1=0

c2=0

for i in range(-100,101,1):

x1=i

y1=0.1*(6*abs(x1)+(36*x1**2-4*5*(5*x1**2-32000))**0.5)

if abs(x1-c1)>=4 or abs(y1-c2)>=5:

ox.append(x1)

oy.append(y1)

c1=x1

c2=y1

for i in range(100,-101,-1):

x2=i

y2=0.1*(6*abs(x2)-(36*x2**2-4*5*(5*x2**2-32000))**0.5)

if abs(x2-c1)>=4 or abs(y2-c2)>=5:

ox.append(x2)

oy.append(y2)

c1=x2

c2=y2

for i in range(0,len(ox)):

random_cache.append(i)

random_num=random.sample(random_cache,99)

for i in random_num:

rox.append(ox[i])

roy.append(oy[i])

return rox,roy

def hswl(ii):

xdata, ydata = [], []

for i in range(0,183,5):

xi=(182-i)/100

xdata.append(0.01*i-1.82)

yi=(xi**(2/3))+(0.9*(3.3-xi**2)**0.5)*np.cos(ii*(np.pi)*xi)

if type(yi)=='complex':

yi=np.around(abs(yi),decimals=4)

yi=np.around(yi, decimals=3)

ydata.append(yi)

for i in range(0,182,5):

xi=i/100

xdata.append(xi)

yi=(xi**(2/3))+(0.9*(3.3-xi**2)**0.5)*np.cos(ii*(np.pi)*xi)

if type(yi)=='complex':

yi=np.around(abs(yi),decimals=4)

yi=np.around(yi, decimals=3)

ydata.append(yi)

return xdata,ydata

def mobile_hswl(xdata,ydata,i_rox,i_roy):

subhswl_x=np.array(xdata)+i_rox

subhswl_y=np.array(ydata)+i_roy

return subhswl_x,subhswl_y

def init():

ax.set_xlim(-110,111)

ax.set_ylim(-110,111)

return ln,

def update(ii):

subhswl_x=np.array([])

subhswl_y=np.array([])

while 1:

global number

i_rox,i_roy=rox[number],roy[number]

xdata,ydata=hswl(ii)

n_subhswl_x,n_subhswl_y=mobile_hswl(xdata,ydata,i_rox,i_roy)

subhswl_x=np.append(subhswl_x,n_subhswl_x)

subhswl_y=np.append(subhswl_y,n_subhswl_y)

number=number+1

if number>=99:

break

number=0

ln.set_data(subhswl_x,subhswl_y)

return ln,

fig, ax = plt.subplots()

ln, = ax.plot([], [], '-',color='red', lw=0.1)

number=0

rox,roy=outline_point()

ani = FuncAnimation(fig, update, np.linspace(0, 13.14, 100),init_func=init, interval=100)

ani.save('love.gif', writer='imagemagick', fps=10)

plt.show()

相关知识

卡地亚婚礼系列法式浪漫花园派对 以璀璨婚戒见证真爱盟约
钻石
花式咖啡厅手游
天然钻石=爱情!河南培育钻石能否打破魔咒,成为下一个风口?
基督徒应该如何表白?婚恋专家袁大同:基督徒示爱需慎重
钻石永放光彩
ZD204 钻石画春艳图花卉DIY贴钻画水晶画钻石绣客厅圆钻水钻装饰
钻石优化处理及鉴别—珠宝鉴赏—地信网论坛
花式营养又美味的双味花朵包
情人节送什么花表示爱的誓言?

网址: 一个程序教你花式示爱 2——99颗闪耀的真爱钻石 https://m.huajiangbk.com/newsview793297.html

所属分类:花卉
上一篇: 七夕表白程序,qt实现满屏玫瑰
下一篇: 七夕如何快速脱单?