-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpointilism.py
More file actions
58 lines (38 loc) · 1.54 KB
/
Copy pathpointilism.py
File metadata and controls
58 lines (38 loc) · 1.54 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
53
54
55
56
57
58
import pygame
import sys
import random
def main():
RED = (255,0,0)
GREEN = (0,255,0)
BLUE = (0,0,255)
# importing the image
image_name = sys.argv[1]
src_image = pygame.image.load(image_name)
(w,h) = src_image.get_size()
surface = pygame.display.set_mode((w,h))
for y in range(h):
for x in range(w):
# Iterate through each pixel to get the color (rgb) value
(r, g, b, _) = src_image.get_at((x,y))
num_red, num_green, num_blue = r // 50, g // 50, b // 50
# Initialize the color values as lists
# Sstore the RGB value relating to number of cicles for each corresponding color
red_color,green_color, blue_color = [],[],[]
for r in range(num_red):
red_color += [RED]
for g in range(num_green):
green_color += [GREEN]
for b in range(num_blue):
blue_color += [BLUE]
# Divides each color evenly, doesn't create any overlap of one color
colors = red_color + green_color + blue_color
random.shuffle(colors)
for c in colors:
pygame.draw.circle(surface,c,(random.randint((x)-6,(x)), random.randint((y)-6, (y))), 1)
pygame.display.update()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
if __name__ == "__main__":
main()