made screen change colors

This commit is contained in:
Nicholas Dyer 2023-02-19 14:19:43 -05:00
parent 5f38b4d555
commit cff537373e
3 changed files with 38 additions and 0 deletions

1
colors/__init__.py Normal file
View File

@ -0,0 +1 @@
__version__ = '0.0.1'

5
colors/__main__.py Normal file
View File

@ -0,0 +1,5 @@
import colors.main
if __name__ == '__main__':
colors.main.main()
exit()

32
colors/main.py Normal file
View File

@ -0,0 +1,32 @@
import pygame
def rainbow_spectrum(position):
relative_pos = position % 1530
red = max(0, min(255, 510 - relative_pos), min(255, relative_pos - 1020))
green = max(0, min(255, relative_pos, 1020 - relative_pos))
blue = max(0, min(255, relative_pos - 510, 1530 - relative_pos))
return red, green, blue
def main():
pygame.init()
clock = pygame.time.Clock()
window = pygame.display.set_mode((720, 720))
rainbow_pos = 0
running = True
while running:
clock.tick(60)
for keyboard_event in pygame.event.get():
if keyboard_event.type == pygame.QUIT:
running = False
rainbow_pos %= 1530
window.fill(rainbow_spectrum(rainbow_pos))
rainbow_pos += 4
pygame.display.flip()
pygame.quit()