-
Notifications
You must be signed in to change notification settings - Fork 0
/
light.py
36 lines (28 loc) · 912 Bytes
/
light.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
32
33
34
35
36
#!/usr/bin/env python
# Copyright (c) 2019 Jeppe Pihl
# All Rights Reserved
#
# Distributed under the "BSD License". See the accompanying LICENSE file.
import pygame
class Light(object):
def __init__(self):
pygame.init()
info = pygame.display.Info()
size = (info.current_w, info.current_h)
self.screen = pygame.display.set_mode(size, pygame.FULLSCREEN)
self.screen.fill((0, 0, 0))
def run(self):
while True:
event = pygame.event.poll()
if event.type == pygame.QUIT or \
event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
break
pygame.display.flip()
pygame.quit()
def toggle(self):
on = self.screen.get_at((0, 0)).r == 255
if on:
color = (0, 0, 0)
else:
color = (255, 255, 255)
self.screen.fill(color)