Rain simulationΒΆ

Inspired by https://matplotlib.org/3.2.1/gallery/animation/rain.html

[1]:
import numpy as np
import ahlive as ah

overlays = []
# have 8 unique rain occurrences
for j in np.arange(8):
    arrays = []
    # at least 4 drops to 16 drops per occurrence
    for i in range(np.random.randint(4, 16)):
        # randomize location of raindrop splat
        x = np.repeat(np.random.rand(1), 10)
        y = np.repeat(np.random.rand(1), 10)
        # make the raindrop splat expand in size
        s = np.linspace(0, np.square(np.random.rand(1) * 100), 10)
        # make the raindrop splat disappear
        a = np.linspace(np.random.rand(1), 0, 10)
        array = ah.Array(
            x, y, s=s, alpha=a, frames=3, style='bare',
            facecolor='none', edgecolor='black',
            scheduler='processes', workers=2
        )
        arrays.append(array)
    # group the raindrops into one occurrence
    overlay = ah.overlay(arrays)
    overlays.append(overlay)
# animate the occurrences one after another
ah.cascade(overlays).render()
/mnt/c/Users/Solactus/GOOGLE~1/Bash/ahlive/ahlive/data.py:428: UserWarning: More than 10 items in legend; setting legend=False; set legend=True to show legend.
  warnings.warn(
[########################################] | 100% Completed |  3min  6.5s
[1]: