-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
77 lines (60 loc) · 1.87 KB
/
main.py
File metadata and controls
77 lines (60 loc) · 1.87 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import random
from PIL import Image, ImageDraw
from Data.Shapes import Circle, Ellipse, Rectangle, Point
def check_int(value) -> int | bool:
try:
value = int(value)
except ValueError:
print('Введите число!')
return False
return value
def input_int() -> int:
option = ""
is_processed = False
while is_processed is False:
option = input(">> ")
option = check_int(option)
if option is not False:
is_processed = True
return option
def random_color() -> str:
r = random.randint(1, 5)
match r:
case 1:
return '#B5FBDD'
case 2:
return '#FBE7B5'
case 3:
return '#F85C50'
case 4:
return '#FE634E'
case 5:
return '#BDCCFF'
def main():
im = Image.new('RGB', (1366, 768), '#FFDFDC')
draw = ImageDraw.Draw(im)
print("Введите кол-во фигур")
n = input_int()
shapes = []
random.seed()
for i in range(n):
r = random.randint(1, 3)
match r:
case 1:
item = Circle(random_color(),
Point(random.randint(1, 700), random.randint(1, 1300)),
random.randint(50, 500))
case 2:
item = Ellipse(random_color(),
Point(random.randint(1, 700), random.randint(1, 1300)),
random.randint(50, 500), random.randint(50, 500))
case _:
item = Rectangle(random_color(),
Point(random.randint(1, 700), random.randint(1, 1300)),
random.randint(50, 500))
shapes.append(item)
for item in shapes:
item.draw(draw)
im.show()
# im.save('drawed-shapes.jpg', quality=95)
main()