本文实例为大家分享了python实现雨滴下落到地面效果的具体代码,供大家参考,具体内容如下
本程序在Windows 64位操作系统下,安装的是Anaconda3-4.2.0
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import animation
# New figure with white background
fig = plt.figure(figsize=(6,6), facecolor='white')
# New axis over the whole figure, no frame and a 1:1 aspect ratio
ax = fig.add_axes([0, 0, 1, 1], frameon=False, aspect=1)
# Number of ring
n = 50
size_min = 50
size_max = 50 ** 2
# Ring position
pos = np.random.uniform(0, 1, (n,2))
# Ring colors
color = np.ones((n,4)) * (0,0,0,1)
# Alpha color channel geos from 0(transparent) to 1(opaque)
color[:,3] = np.linspace(0, 1, n)
# Ring sizes
size = np.linspace(size_min, size_max, n)
# Scatt