-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathretangle_maker.py
executable file
·90 lines (45 loc) · 1.71 KB
/
retangle_maker.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
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
78
79
80
81
82
83
84
85
86
87
88
89
90
from random import*
from pygame import*
screen = display.set_mode((1000,900))
running = True
r=1
while running:
for e in event.get():
if e.type == QUIT:
running = False
if e.type == MOUSEBUTTONDOWN:
pic = screen.copy()
if e.button == 1:
startx,starty = e.pos #related to shape tools
if e.button == 3:
startx,starty = e.pos
if e.button == 4: #makes radius bigger
r += 1
if e.button == 5: #makes radius smaller
r -= 1
#---------------------------------------
green = (0,255,0)
mx,my = mouse.get_pos()
mb = mouse.get_pressed()
if r < 0:
r = 1
if mb[0] == 1 :
#screen.blit(pic,(0,0))
ellipse_border = Rect(startx,starty,mx-startx,my-starty)
ellipse_border.normalize()
surf = Surface(ellipse_border.size).convert()
surf.set_colorkey((255,255,254)) #sets suface color
trans = Rect(r,r,(mx-startx)-(2*r),(my-starty)-(2*r))
trans.normalize()
if ellipse_border.height > r *2 and ellipse_border.width > r *2:
draw.ellipse(surf,green,ellipse_border)
draw.ellipse(surf,(255,255,254,0),trans)
screen.blit(surf,(mx,my))
else:
draw.ellipse(surf,green,ellipse_border)
if mb[1] == 1:
screen.fill((255,255,255))
omx, omy = mx,my
#---------------------------------------
display.flip()
quit()