from random import random, seed
from icons import Tree

seed(999) # same random numbers every time

# background
Rectangle(color=['#999', '#cde'])
Circle(x=50, y=80, width=500, height=70 ,color=['#abb', '#375', '#072'])

# trees!
treecolors = [
    ['#454', '#030'],
    ['#464', '#230'],
    ['#564', '#040'],
]
for i in range(30):
    tree = Tree(color=treecolors[int(random() * len(treecolors))])
    tree.x = (62 * i - 10*random()) % 100
    tree.y = 45 + 1.7 * i
    distance = 40 + i
    tree.width = 10 * distance / 70
    tree.height = 14 * distance / 70

# rain
drips = []
for i in range(40):
    drip = Rectangle(width=0.3, height=30, color=['#aab', '#ccd', '#aab'])
    drip.x = 1.25+2.5*i
    drip.y = -15 + 130 * random()
    drips.append(drip)

# in order to loop nicely, we need to have many shorter animations
for i in range(26):
    # short part of the animation
    with animation(duration = 0.15):
        for drip in drips:
            drip.y += 10
    # loop nicely; add an extremely short animation to bring drops to the top
    with animation(duration = 0.000000000000000001):
        for drip in drips:
            if drip.y >= 115:
                drip.x = (drip.x + 50) % 100 # flip x position to add variation
                drip.y -= 130

Rainy landscape

by snild

Created 3 months, 3 weeks ago.