-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenerator.py
45 lines (35 loc) · 1.19 KB
/
Generator.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
37
38
39
40
41
42
43
44
45
import pygame
from random import randint
#initializing the window on which the images are created
pygame.init()
window = pygame.display.set_mode((300,300))
#function for checking intersection
def isIntersecting(x,y):
for coordinate in coordinates:
if x-15 < coordinate[0]+15 and x+15 > coordinate[0]-15:
if y-15 < coordinate[1]+15 and y+15 > coordinate[1]-15:
return True
return False
image_count = int(input("How many images do you want?"))
while image_count > 0:
window.fill((255,255,255))
#initialize the random number of circs
no = randint(2,10)
#list of coordinates for each circs
coordinates=[[0,0]]
for i in range(no):
#make sure coordinates don't intersect with any circ before
x=randint(30, 270)
y=randint(30, 270)
while (isIntersecting(x,y)):
x=randint(30, 270)
y=randint(30, 270)
pygame.draw.circle(window, (0,0,255), (x, y), 15, 0)
coordinates.append([x,y])
pygame.display.update()
print()
print(no)
print(coordinates[1][1])
pygame.image.save(window, str(no)+"circs_"+str(image_count)+"imagenumber.jpeg")
#input()
image_count-=1