made screen change colors
This commit is contained in:
parent
5f38b4d555
commit
cff537373e
1
colors/__init__.py
Normal file
1
colors/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
__version__ = '0.0.1'
|
5
colors/__main__.py
Normal file
5
colors/__main__.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
import colors.main
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
colors.main.main()
|
||||||
|
exit()
|
32
colors/main.py
Normal file
32
colors/main.py
Normal 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()
|
Loading…
Reference in New Issue
Block a user