-
Notifications
You must be signed in to change notification settings - Fork 0
/
sky.py
32 lines (26 loc) · 1.04 KB
/
sky.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import math
class Sky:
def __init__(self, display, width, height):
self.display = display
self.width = width
self.height = height
def check_colour(self, colour):
if colour > 255:
return 255
else:
return colour
def get_RGB(self, time, layer, display):
red = self.check_colour(int((math.cos(math.radians(time)) * 60) * 2) + layer )
green = self.check_colour(int((math.sin(math.radians(time)) * 50) * 2) + layer)
blue = self.check_colour(int((math.tan(math.radians(time)) * 50) * 2) + layer)
self.display.set_pen(red, green, blue)
def paint_the_sky(self, time, day):
if day == False:
self.display.set_pen(0, 0, 0)
self.display.clear()
else:
layer = 0
for sky_layer in range(12):
self.get_RGB(int(time * 7.5), layer, self.display)
self.display.rectangle(0, layer, self.width, int(self.height/12))
layer += int(self.height/12)