Data update
This commit is contained in:
parent
72eb4943cb
commit
4d5544505c
2347 changed files with 62432 additions and 16731 deletions
40
Task/Colour-bars-Display/Python/colour-bars-display-2.py
Normal file
40
Task/Colour-bars-Display/Python/colour-bars-display-2.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import pygame
|
||||
import sys
|
||||
|
||||
GLOBAL_WINDOW_SIZE = (640, 480)
|
||||
COLOURS = (
|
||||
(0, 0, 0),
|
||||
(255, 0, 0),
|
||||
(0, 255, 0),
|
||||
(0, 0, 255),
|
||||
(255, 0, 255),
|
||||
(0, 255, 255),
|
||||
(255, 255, 0),
|
||||
(255, 255, 255)
|
||||
)
|
||||
|
||||
def drawColouredStripes(surface):
|
||||
stripeWidth = surface.get_width() // 8
|
||||
for i, col in enumerate(COLOURS):
|
||||
pygame.draw.rect(surface, col, pygame.Rect(i*stripeWidth, 0, stripeWidth, surface.get_height()))
|
||||
|
||||
pygame.init()
|
||||
|
||||
if len(sys.argv) == 3:
|
||||
newWindowSize = (int(sys.argv[1]), int(sys.argv[2]))
|
||||
screen = pygame.display.set_mode(newWindowSize)
|
||||
else:
|
||||
screen = pygame.display.set_mode(GLOBAL_WINDOW_SIZE)
|
||||
|
||||
running = True
|
||||
|
||||
while running:
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
running = False
|
||||
|
||||
drawColouredStripes(screen)
|
||||
|
||||
pygame.display.flip()
|
||||
|
||||
pygame.quit()
|
||||
Loading…
Add table
Add a link
Reference in a new issue