-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitmapEditor.py
More file actions
52 lines (38 loc) · 1.32 KB
/
Copy pathbitmapEditor.py
File metadata and controls
52 lines (38 loc) · 1.32 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import pygame
width = 800
height = 800
imageDisplay = pygame.display.set_mode((width, height))
pygame.display.set_caption("Binary Image")
clock = pygame.time.Clock()
pygame.init()
black = (0,0,0)
white = (255,255,255)
imageDisplay.fill(white)
def mainLoop():
count = 0 #pixel counter
size = 10
while(True):
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_0:
for i in range(size):
imageDisplay.set_at((count%width, count//height), black)
count+=1
elif event.key == pygame.K_1:
for i in range(size):
imageDisplay.set_at((count%width, count//height), white)
count+=1
keys = pygame.key.get_pressed() #checking pressed keys
if keys[pygame.K_0]:
for i in range(size):
imageDisplay.set_at((count%width, count//height), black)
count+=1
if keys[pygame.K_1]:
for i in range(size):
imageDisplay.set_at((count%width, count//height), white)
count+=1
pygame.display.update()
clock.tick(30)
mainLoop()