def spawn_particles(destination_list, count, location, color=default_color, velocity=(0, 0), lifespan=default_lifespan, variation_velocity=default_variation_speed, variation_location=default_variation_location, variation_color=default_variation_color, fade_to_color=None, mass=default_mass, sway=default_sway, diameter=default_diameter, drag=default_drag, ): for x in range(count): particle_color = vary_color(color, variation_color) particle_velocity = util.gauss_vector(velocity, variation_velocity) particle_location = util.gauss_vector(location, variation_location) if fade_to_color is not None: fade_to_color = vary_color(fade_to_color, variation_color) particle = Particle(particle_location, particle_velocity, particle_color, diameter, drag, mass, sway, lifespan, fade_to_color=fade_to_color) destination_list.append(particle)
def update(self, actor_dict, screen, delta_time): velocity_change = util.gauss_vector((0, 0), self.sway) self.lifespan -= delta_time if self.lifespan <= 0: actor_dict.get(Particle).remove(self) super().increase_velocity(velocity_change) super().update(actor_dict, screen, delta_time)
import numpy as np import matplotlib.pyplot as plt import util import plotting_utls as pltuls T = 20 D = 5 N = 1 #Make a W variances = np.random.uniform(0.5*T/20,T/20,(N,D)) means = np.random.uniform(1,T,(N,D)) W = util.gauss_vector(T,means,variances) amp_max = 1 amplitudes = np.random.uniform(0,amp_max,(1,N,D)) c_min = 0 c_max = 1 W = amplitudes*W W = np.squeeze(np.moveaxis(W,0,2)) shifts = np.array([-1,2,4]) shift_indices = shifts + (T-1) plt.subplot2grid((len(shifts)+1,2),(0,1)) plt.imshow(W,interpolation='none') # padded_W = np.concatenate([np.zeros((D,T-1)),W,np.zeros((D,T))],axis=1) counter = 0
def vary_color(color, variation): color = util.gauss_vector(color, variation) color = [min(255, max(0, int(x))) for x in color] return color