diff --git a/apps/shipweatherclock/shipweatherclock.star b/apps/shipweatherclock/shipweatherclock.star index 9c700d6f7..756de3b24 100644 --- a/apps/shipweatherclock/shipweatherclock.star +++ b/apps/shipweatherclock/shipweatherclock.star @@ -5,15 +5,14 @@ Description: Clock with ship on the ocean scene that changes with weather. Author: Peter Uth """ +load("encoding/base64.star", "base64") +load("encoding/json.star", "json") +load("http.star", "http") load("render.star", "render") load("schema.star", "schema") load("time.star", "time") -load("encoding/base64.star", "base64") -load("cache.star", "cache") -load("http.star", "http") -load("encoding/json.star", "json") -TTL_SECONDS = 20 * 60 # 20 minutes API pull interval +TTL_SECONDS = 20 * 60 # 20 minutes API pull interval DEFAULT_LOCATION = { "lat": "47.60", "lng": "-122.33", @@ -39,7 +38,6 @@ SNOW_DAY = base64.decode("iVBORw0KGgoAAAANSUhEUgAAAEAAAAAgCAYAAACinX6EAAABhGlDQ1 SNOW_NIGHT = base64.decode("iVBORw0KGgoAAAANSUhEUgAAAEAAAAAgCAYAAACinX6EAAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AcxV9bpaIVh1YQcchQO9lFRRxrFYpQIdQKrTqYXPoFTRqSFBdHwbXg4Mdi1cHFWVcHV0EQ/ABxdnBSdJES/5cUWsR4cNyPd/ced+8Af7PKVLMnAaiaZWRSSSGXXxWCrxhAAGEMIyYxU58TxTQ8x9c9fHy9i/Ms73N/jkGlYDLAJxAnmG5YxBvEM5uWznmfOMLKkkJ8Tjxh0AWJH7kuu/zGueSwn2dGjGxmnjhCLJS6WO5iVjZU4mniqKJqlO/Puaxw3uKsVuusfU/+wlBBW1nmOs0xpLCIJYgQIKOOCqqwEKdVI8VEhvaTHv5Rxy+SSyZXBYwcC6hBheT4wf/gd7dmcWrSTQolgd4X2/4YB4K7QKth29/Htt06AQLPwJXW8deawOwn6Y2OFj0ChraBi+uOJu8BlzvAyJMuGZIjBWj6i0Xg/Yy+KQ+Eb4H+Nbe39j5OH4AsdZW+AQ4OgViJstc93t3X3du/Z9r9/QCDd3KtmFmoAgAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+gLAxQtH+Wr8QYAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAZklEQVRo3u3XwQ3AIAxDUfYfJiu2IyB6IHX0fEfY3yESazWqqp5xd90MRZ1Nahr0fKCENDB7w2khRkyjJ0WWoxDX/CYFifBqg4POKIGuxUGm/xbqi58R33ICMITiyTlNGXmgqLudF2iScE5Btz32AAAAAElFTkSuQmCC") LIGHTNING = base64.decode("iVBORw0KGgoAAAANSUhEUgAAAEAAAAAgCAYAAACinX6EAAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AcxV9TpaIVByuIOASpThZBRRxrFYpQIdQKrTqYXPoFTRqSFhdHwbXg4Mdi1cHFWVcHV0EQ/ABxdnBSdJES/5cUWsR4cNyPd/ced+8AoV5imtURBTS9YibjMTGdWRUDr+iBHwOYwIjMLGNOkhLwHF/38PH1LsKzvM/9OXrVrMUAn0gcZYZZId4gntmsGJz3iUOsIKvE58TjJl2Q+JHristvnPMOCzwzZKaS88QhYjHfxkobs4KpEU8Th1VNp3wh7bLKeYuzVqqy5j35C4NZfWWZ6zSHEcciliBBhIIqiiihggitOikWkrQf8/APOX6JXAq5imDkWEAZGmTHD/4Hv7u1clOTblIwBnS+2PbHKBDYBRo12/4+tu3GCeB/Bq70lr9cB2Y/Sa+1tPAR0LcNXFy3NGUPuNwBBp8M2ZQdyU9TyOWA9zP6pgzQfwt0r7m9Nfdx+gCkqKvEDXBwCIzlKXvd491d7b39e6bZ3w+/a3LFYPmf5QAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+gLAxcHNCQ6ejcAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAdklEQVRo3u2YsRHAIAwDbfbfWWlSpEiRJuC7f20g+YWBqsFKkqJql/lVSvTR5q2A6MPNW4FJ08dW4GkcF8KbYUwIuYXcCF96vyOEdcp8d/eEQYxeg1NC8tD7+7aHDwD/DjAE/wPUMQokgE6BBNApwBNgBZRi6wJ5G3elOccUgAAAAABJRU5ErkJggg==") - def main(config): # get coordinates and current time location = config.get("location") @@ -65,21 +63,21 @@ def main(config): unit_temp = "F" # wind thresholds for wave animations - wind_medium_threshold_mps = 3 * 0.44704 # [mph] to [m/s] - wind_heavy_threshold_mps = 10 * 0.44704 # [mph] to [m/s] - + wind_medium_threshold_mps = 3 * 0.44704 # [mph] to [m/s] + wind_heavy_threshold_mps = 10 * 0.44704 # [mph] to [m/s] + # pull weather data from API or cache weather_url = "https://api.open-meteo.com/v1/forecast?latitude=" + str(lat) + "&longitude=" + str(lng) + "¤t=temperature_2m,weather_code,cloud_cover,wind_speed_10m&daily=temperature_2m_max,temperature_2m_min,sunrise,sunset" - res = http.get(url=weather_url, ttl_seconds=TTL_SECONDS) + res = http.get(url = weather_url, ttl_seconds = TTL_SECONDS) if res.status_code != 200: fail("request to %s failed with status code: %d - %s" % (weather_url, res.status_code, res.body())) - + # DEVELOPMENT: check if result was served from API pull or cache if res.headers.get("Tidbyt-Cache-Status") == "HIT": print("Displaying cached data.") else: print("Calling Open Meteo API.") - + # get data values of interest from pulled data sunrise = res.json()["daily"]["sunrise"][0] sunset = res.json()["daily"]["sunset"][0] @@ -88,20 +86,19 @@ def main(config): high_temp_C = res.json()["daily"]["temperature_2m_max"][0] windspeed_kmph = res.json()["current"]["wind_speed_10m"] weather_code = res.json()["current"]["weather_code"] - + # convert times to unix and windspeed to m/s sunrise = time.parse_time(sunrise + ":00Z") sunrise_unix = sunrise.unix sunset = time.parse_time(sunset + ":00Z") sunset_unix = sunset.unix windspeed_mps = windspeed_kmph * 1000 / 60 / 60 - + # convert temperature units - if unit_temp == "C": - low_temp = low_temp_C - now_temp = now_temp_C - high_temp = high_temp_C - elif unit_temp == "F": + low_temp = low_temp_C + now_temp = now_temp_C + high_temp = high_temp_C + if unit_temp == "F": low_temp = low_temp_C * 9 / 5 + 32 now_temp = now_temp_C * 9 / 5 + 32 high_temp = high_temp_C * 9 / 5 + 32 @@ -140,36 +137,37 @@ def main(config): # determine weather conditions weather_table = [ # code, clouds, rain, snow, lightning, # description - [ 0, 0, 0, 0, 0], # Clear sky - [ 1, 1, 0, 0, 0], # Mainly clear - [ 2, 2, 0, 0, 0], # Partly cloudy - [ 3, 3, 0, 0, 0], # Overcast - [ 45, 3, 0, 0, 0], # Fog - [ 48, 3, 0, 0, 0], # Depositing rime fog - [ 51, 3, 1, 0, 0], # Drizzle: light - [ 53, 3, 1, 0, 0], # Drizzle: moderate - [ 55, 3, 2, 0, 0], # Drizzle: dense - [ 56, 3, 1, 0, 0], # Freezing drizzle: light - [ 57, 3, 2, 0, 0], # Freezing drizzle: dense - [ 61, 3, 1, 0, 0], # Rain: slight - [ 63, 3, 2, 0, 0], # Rain: moderate - [ 65, 3, 2, 0, 0], # Rain: heavy - [ 66, 3, 1, 0, 0], # Freezing rain: light - [ 67, 3, 2, 0, 0], # Freezing rain: heavy - [ 71, 3, 0, 1, 0], # Snow fall: slight - [ 73, 3, 0, 1, 0], # Snow fall: moderate - [ 75, 3, 0, 1, 0], # Snow fall: heavy - [ 77, 3, 0, 1, 0], # Snow grains - [ 80, 3, 1, 0, 0], # Rain showers: slight - [ 81, 3, 2, 0, 0], # Rain showers: moderate - [ 82, 3, 2, 0, 0], # Rain showers: violent - [ 85, 3, 0, 1, 0], # Snow showers: slight - [ 86, 3, 0, 1, 0], # Snow showers: heavy - [ 95, 3, 2, 0, 1], # Thunderstorm: Slight or moderate - [ 96, 3, 1, 0, 1], # Thunderstorm with slight hail - [ 99, 3, 2, 0, 1], # Thunderstorm with heavy hail + [0, 0, 0, 0, 0], # Clear sky + [1, 1, 0, 0, 0], # Mainly clear + [2, 2, 0, 0, 0], # Partly cloudy + [3, 3, 0, 0, 0], # Overcast + [45, 3, 0, 0, 0], # Fog + [48, 3, 0, 0, 0], # Depositing rime fog + [51, 3, 1, 0, 0], # Drizzle: light + [53, 3, 1, 0, 0], # Drizzle: moderate + [55, 3, 2, 0, 0], # Drizzle: dense + [56, 3, 1, 0, 0], # Freezing drizzle: light + [57, 3, 2, 0, 0], # Freezing drizzle: dense + [61, 3, 1, 0, 0], # Rain: slight + [63, 3, 2, 0, 0], # Rain: moderate + [65, 3, 2, 0, 0], # Rain: heavy + [66, 3, 1, 0, 0], # Freezing rain: light + [67, 3, 2, 0, 0], # Freezing rain: heavy + [71, 3, 0, 1, 0], # Snow fall: slight + [73, 3, 0, 1, 0], # Snow fall: moderate + [75, 3, 0, 1, 0], # Snow fall: heavy + [77, 3, 0, 1, 0], # Snow grains + [80, 3, 1, 0, 0], # Rain showers: slight + [81, 3, 2, 0, 0], # Rain showers: moderate + [82, 3, 2, 0, 0], # Rain showers: violent + [85, 3, 0, 1, 0], # Snow showers: slight + [86, 3, 0, 1, 0], # Snow showers: heavy + [95, 3, 2, 0, 1], # Thunderstorm: Slight or moderate + [96, 3, 1, 0, 1], # Thunderstorm with slight hail + [99, 3, 2, 0, 1], # Thunderstorm with heavy hail ] + w = [0, 0, 0, 0, 0] for w in weather_table: if w[0] == weather_code: break @@ -177,13 +175,13 @@ def main(config): rain_scale = w[2] snow_scale = w[3] lightning_scale = w[4] - + # animation timing t_end = 15 - t_delay_ms = int(5000/24) # 24 is slowest for seemless repeat + t_delay_ms = int(5000 / 24) # 24 is slowest for seemless repeat t_delay = t_delay_ms / 1000 - pps = 1 / t_delay # pixels per second - offset = int(t_end * pps) # offset number of pixels for seemless repeat + pps = 1 / t_delay # pixels per second + offset = int(t_end * pps) # offset number of pixels for seemless repeat # individual render components sky = draw_sky(day, day_ratio, sun_height, cloud_scale) @@ -214,25 +212,38 @@ def main(config): rain_light = draw_rain_light(day, rain_scale) snow = draw_snow(day, snow_scale) lightning = draw_lightning(lightning_scale) - + # top-level render - return render.Root(delay = t_delay_ms, child = render.Stack(children=[ - sky, - stars, - sun, - moon, - ship, - snow, - rain_heavy, rain_light, - lightning, - ocean, - wave1, wave2, wave3, wave4, - stream1_1, stream1_2, stream2_1, stream2_2, - stream3_1, stream3_2, stream4_1, stream4_2, - clouds_heavy, clouds_light, - text_time, - text_low_temp, text_high_temp, - text_now_temp])) + return render.Root(delay = t_delay_ms, child = render.Stack(children = [ + sky, + stars, + sun, + moon, + ship, + snow, + rain_heavy, + rain_light, + lightning, + ocean, + wave1, + wave2, + wave3, + wave4, + stream1_1, + stream1_2, + stream2_1, + stream2_2, + stream3_1, + stream3_2, + stream4_1, + stream4_2, + clouds_heavy, + clouds_light, + text_time, + text_low_temp, + text_high_temp, + text_now_temp, + ])) def get_schema(): return schema.Schema( @@ -266,11 +277,13 @@ def draw_sun(sun_height, cloud_scale): sun_color = "#ffffc5" else: sun_color = "#FFFF00" - sun = render.Column(children=[ - render.Box(height=sun_height), - render.Row(children=[ - render.Box(width=22), - render.Circle(color=sun_color, diameter=8)])]) + sun = render.Column(children = [ + render.Box(height = sun_height), + render.Row(children = [ + render.Box(width = 22), + render.Circle(color = sun_color, diameter = 8), + ]), + ]) return sun def draw_moon(moon_height, cloud_scale): @@ -278,38 +291,40 @@ def draw_moon(moon_height, cloud_scale): img = MOON_CLOUDS else: img = MOON - moon = render.Column(children=[ - render.Box(height=moon_height), - render.Row(children=[ - render.Box(width=22), - render.Image(src=img)])]) + moon = render.Column(children = [ + render.Box(height = moon_height), + render.Row(children = [ + render.Box(width = 22), + render.Image(src = img), + ]), + ]) return moon def draw_sky(day, day_ratio, sun_height, cloud_scale): if day: if cloud_scale > 2: - sky = render.Box(width=64, height=32, color="#aaaaaa") - else: - if sun_height > 20: - if day_ratio < 0.5: - sky = render.Column(children=[ - render.Box(width=64, height=5, color="#87CEEB"), - render.Box(width=64, height=8, color="#FFFF8c"), - render.Box(width=64, height=6, color="#ff724c"), - render.Box(width=64, height=4, color="#AA336A")]) - else: - sky = render.Column(children=[ - render.Box(width=64, height=5, color="#87CEEB"), - render.Box(width=64, height=8, color="#FFFF00"), - render.Box(width=64, height=6, color="#FFA500"), - render.Box(width=64, height=4, color="#ff0000")]) + sky = render.Box(width = 64, height = 32, color = "#aaaaaa") + elif sun_height > 20: + if day_ratio < 0.5: + sky = render.Column(children = [ + render.Box(width = 64, height = 5, color = "#87CEEB"), + render.Box(width = 64, height = 8, color = "#FFFF8c"), + render.Box(width = 64, height = 6, color = "#ff724c"), + render.Box(width = 64, height = 4, color = "#AA336A"), + ]) else: - sky = render.Box(width=64, height=32, color="#87CEEB") - else: - if cloud_scale > 2: - sky = render.Box(width=64, height=32, color="#202020") + sky = render.Column(children = [ + render.Box(width = 64, height = 5, color = "#87CEEB"), + render.Box(width = 64, height = 8, color = "#FFFF00"), + render.Box(width = 64, height = 6, color = "#FFA500"), + render.Box(width = 64, height = 4, color = "#ff0000"), + ]) else: - sky = render.Box(width=64, height=32, color="#000000") + sky = render.Box(width = 64, height = 32, color = "#87CEEB") + elif cloud_scale > 2: + sky = render.Box(width = 64, height = 32, color = "#202020") + else: + sky = render.Box(width = 64, height = 32, color = "#000000") return sky def draw_ship(day, wind): @@ -322,25 +337,30 @@ def draw_ship(day, wind): else: ship = SHIP_NIGHT if wind == 2: - ship = render.Column(children=[ - render.Animation(children=[ - render.Box(height=height1), - render.Box(height=height1), - render.Box(height=height2), - render.Box(height=height2), - render.Box(height=height3), - render.Box(height=height3), - render.Box(height=height2), - render.Box(height=height2)]), - render.Row(children=[ - render.Box(width=left_space), - render.Image(src=ship)])]) + ship = render.Column(children = [ + render.Animation(children = [ + render.Box(height = height1), + render.Box(height = height1), + render.Box(height = height2), + render.Box(height = height2), + render.Box(height = height3), + render.Box(height = height3), + render.Box(height = height2), + render.Box(height = height2), + ]), + render.Row(children = [ + render.Box(width = left_space), + render.Image(src = ship), + ]), + ]) else: - ship = render.Column(children=[ - render.Box(height=height3), - render.Row(children=[ - render.Box(width=left_space), - render.Image(src=ship)])]) + ship = render.Column(children = [ + render.Box(height = height3), + render.Row(children = [ + render.Box(width = left_space), + render.Image(src = ship), + ]), + ]) return ship def draw_ocean(day): @@ -348,13 +368,14 @@ def draw_ocean(day): ocean_color = "#0000FF" else: ocean_color = "#131862" - ocean = render.Column(children=[ - render.Box(width=64, height=23), - render.Box(width=64, height=9, color=ocean_color)]) + ocean = render.Column(children = [ + render.Box(width = 64, height = 23), + render.Box(width = 64, height = 9, color = ocean_color), + ]) return ocean def draw_wave(day, wind, w1, w2, w3, h1, h2, seq): - if day: + if day: ocean_color = "#0000FF" else: ocean_color = "#131862" @@ -366,48 +387,59 @@ def draw_wave(day, wind, w1, w2, w3, h1, h2, seq): colors.append(ocean_color) if wind == 2: if w1 == 0: - wave = render.Column(children=[ - render.Box(width=w2, height=h2), - render.Animation(children=[ - render.Box(width=w3, height=1, color=colors[0]), - render.Box(width=w3, height=1, color=colors[1]), - render.Box(width=w3, height=1, color=colors[2]), - render.Box(width=w3, height=1, color=colors[3]), - render.Box(width=w3, height=1, color=colors[4]), - render.Box(width=w3, height=1, color=colors[5]), - render.Box(width=w3, height=1, color=colors[6]), - render.Box(width=w3, height=1, color=colors[7])])]) + wave = render.Column(children = [ + render.Box(width = w2, height = h2), + render.Animation(children = [ + render.Box(width = w3, height = 1, color = colors[0]), + render.Box(width = w3, height = 1, color = colors[1]), + render.Box(width = w3, height = 1, color = colors[2]), + render.Box(width = w3, height = 1, color = colors[3]), + render.Box(width = w3, height = 1, color = colors[4]), + render.Box(width = w3, height = 1, color = colors[5]), + render.Box(width = w3, height = 1, color = colors[6]), + render.Box(width = w3, height = 1, color = colors[7]), + ]), + ]) else: - wave = render.Row(children=[ - render.Box(width=w1, height=h1), - render.Column(children=[ - render.Box(width=w2, height=h2), - render.Animation(children=[ - render.Box(width=w3, height=1, color=colors[0]), - render.Box(width=w3, height=1, color=colors[1]), - render.Box(width=w3, height=1, color=colors[2]), - render.Box(width=w3, height=1, color=colors[3]), - render.Box(width=w3, height=1, color=colors[4]), - render.Box(width=w3, height=1, color=colors[5]), - render.Box(width=w3, height=1, color=colors[6]), - render.Box(width=w3, height=1, color=colors[7])])])]) + wave = render.Row(children = [ + render.Box(width = w1, height = h1), + render.Column(children = [ + render.Box(width = w2, height = h2), + render.Animation(children = [ + render.Box(width = w3, height = 1, color = colors[0]), + render.Box(width = w3, height = 1, color = colors[1]), + render.Box(width = w3, height = 1, color = colors[2]), + render.Box(width = w3, height = 1, color = colors[3]), + render.Box(width = w3, height = 1, color = colors[4]), + render.Box(width = w3, height = 1, color = colors[5]), + render.Box(width = w3, height = 1, color = colors[6]), + render.Box(width = w3, height = 1, color = colors[7]), + ]), + ]), + ]) else: wave = render.Box() return wave def draw_stream(day, wind, start_width, start_height, width, offset): - if day: + if day: stream_color = "#00008B" else: stream_color = "#00094b" if wind > 0: - stream = render.Column(children=[ - render.Box(height=start_height), - render.Marquee(width=64, offset_start=offset, offset_end=0, - child=render.Row(children=[ - render.Box(width=start_width,height=1), - render.Box(width=width, height=1, color=stream_color), - render.Box(width=65-start_width-width, height=1)]))]) + stream = render.Column(children = [ + render.Box(height = start_height), + render.Marquee( + width = 64, + offset_start = offset, + offset_end = 0, + child = render.Row(children = [ + render.Box(width = start_width, height = 1), + render.Box(width = width, height = 1, color = stream_color), + render.Box(width = 65 - start_width - width, height = 1), + ]), + ), + ]) else: stream = render.Box() return stream @@ -418,11 +450,12 @@ def print_time(day, now, clock_format): else: text_color = "#ffffff" text = render.WrappedText( - align="right", - width=64, - color=text_color, - content = now.format(clock_format), - font = "CG-pixel-3x5-mono") + align = "right", + width = 64, + color = text_color, + content = now.format(clock_format), + font = "CG-pixel-3x5-mono", + ) return text def print_temp(day, temperature, x, y): @@ -430,21 +463,23 @@ def print_temp(day, temperature, x, y): text_color = "#000000" else: text_color = "#ffffff" - text = render.Column(children=[ - render.Box(height=y), - render.WrappedText( - align="right", - width=x, - color=text_color, - content = temperature, - font = "CG-pixel-3x5-mono")]) + text = render.Column(children = [ + render.Box(height = y), + render.WrappedText( + align = "right", + width = x, + color = text_color, + content = temperature, + font = "CG-pixel-3x5-mono", + ), + ]) return text def draw_stars(day, cloud_scale): if day or cloud_scale > 2: star = render.Box() else: - star = render.Image(src=STARS) + star = render.Image(src = STARS) return star def draw_clouds(day, cloud_scale, threshold, img_day, img_night): @@ -453,7 +488,7 @@ def draw_clouds(day, cloud_scale, threshold, img_day, img_night): else: img = img_night if cloud_scale > threshold: - clouds = render.Image(src=img) + clouds = render.Image(src = img) else: clouds = render.Box() return clouds @@ -464,17 +499,19 @@ def draw_rain_light(day, rain_scale): else: img = RAIN_LIGHT_NIGHT if rain_scale > 0: - rain = render.Column(children=[ - render.Animation(children=[ - render.Box(height=1), - render.Box(height=1), - render.Box(height=1), - render.Box(height=1), - render.Box(height=5), - render.Box(height=5), - render.Box(height=5), - render.Box(height=5)]), - render.Image(src=img)]) + rain = render.Column(children = [ + render.Animation(children = [ + render.Box(height = 1), + render.Box(height = 1), + render.Box(height = 1), + render.Box(height = 1), + render.Box(height = 5), + render.Box(height = 5), + render.Box(height = 5), + render.Box(height = 5), + ]), + render.Image(src = img), + ]) else: rain = render.Box() return rain @@ -485,13 +522,15 @@ def draw_rain_heavy(day, rain_scale): else: img = RAIN_HEAVY_NIGHT if rain_scale > 1: - rain = render.Column(children=[ - render.Animation(children=[ - render.Box(height=1), - render.Box(height=1), - render.Box(height=5), - render.Box(height=5)]), - render.Image(src=img)]) + rain = render.Column(children = [ + render.Animation(children = [ + render.Box(height = 1), + render.Box(height = 1), + render.Box(height = 5), + render.Box(height = 5), + ]), + render.Image(src = img), + ]) else: rain = render.Box() return rain @@ -502,28 +541,31 @@ def draw_snow(day, snow_scale): else: img = SNOW_NIGHT if snow_scale > 0: - snow = render.Column(children=[ - render.Animation(children=[ - render.Box(height=1), - render.Box(height=1), - render.Box(height=1), - render.Box(height=1), - render.Box(height=5), - render.Box(height=5), - render.Box(height=5), - render.Box(height=5)]), - render.Image(src=img)]) + snow = render.Column(children = [ + render.Animation(children = [ + render.Box(height = 1), + render.Box(height = 1), + render.Box(height = 1), + render.Box(height = 1), + render.Box(height = 5), + render.Box(height = 5), + render.Box(height = 5), + render.Box(height = 5), + ]), + render.Image(src = img), + ]) else: snow = render.Box() return snow def draw_lightning(lightning_scale): if lightning_scale > 0: - lightning = render.Animation(children=[ + lightning = render.Animation(children = [ + render.Box(), render.Box(), + render.Image(src = LIGHTNING), + render.Image(src = LIGHTNING), render.Box(), - render.Image(src=LIGHTNING), - render.Image(src=LIGHTNING), render.Box(), render.Box(), render.Box(), @@ -535,7 +577,7 @@ def draw_lightning(lightning_scale): render.Box(), render.Box(), render.Box(), - render.Box()]) + ]) else: lightning = render.Box() return lightning