-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
178 lines (140 loc) · 6.35 KB
/
main.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
from cairocffi import RadialGradient
import pygame
from constants import *
from math import *
def FieldToScreen(inputCoords):
return [(-2.89*(float(inputCoords[0])))-(
8*RADIUS)+310, (-3.5*float(inputCoords[1]))-(2*RADIUS)+300]
def ScreenToField(MousePos):
return float(-((100*int(MousePos[0]))+(800*RADIUS)-31000)/289), float(-(
(2*(int(MousePos[1])+(2*RADIUS)-300))/7))
pygame.init()
clock = pygame.time.Clock()
base_font = pygame.font.Font(None, 32)
font = pygame.font.Font('freesansbold.ttf', 20)
text = font.render(outputText, True, green, blue)
textStepsList=[]
textFGCS = font.render('', True, green)
textFGC = font.render(greenOutputText, True, blue, green)
textRect = text.get_rect()
greenTextRect = text.get_rect()
greenS = text.get_rect()
textRect.center = (X-(1.81*NEWX), Y-(.025*NEWY))
greenTextRect.center = (X-(1.81*NEWX), Y-(.025*NEWY)-20)
greenS.center=X,Y
input_rect = pygame.Rect(X/2-(X-(1.81*NEWX)), Y-(20*11.3), 200, 32)
color_active = pygame.Color('lightskyblue3')
color_passive = pygame.Color('chartreuse4')
color = color_passive
active = False
display_surface = pygame.display.set_mode((X, Y))
pygame.display.set_caption('RR Auto Maker')
image = pygame.image.load(r'C:\Users\maudi\Downloads\Dashboard.png')
pre_mouse = 0
pty, ptx = 0, 0
circlept = 0
toggle = False
coordsText=font.render('Click a point to get position', True, blue, green)
green2OutputText, green3OutputText, green4OutputText, green5OutputText = greenOutputText, greenOutputText, greenOutputText, greenOutputText
points = [False, False, False, False, False]
outputTL = [green5OutputText,green4OutputText,green3OutputText, green2OutputText, greenOutputText]
active=False
yactive = False
while True:
rBMS = (pygame.mouse.get_pos()[0]+(RADIUS*e)), pygame.mouse.get_pos()[1]+(RADIUS*e)
display_surface.fill('#212020')
pygame.draw.circle(display_surface, blue,
pygame.mouse.get_pos(), RADIUS*4, width=2)
headingLine = pygame.draw.line(
display_surface, blue, pygame.mouse.get_pos(), rBMS, width=4)
headingLine
# print(rBMS[1])
display_surface.blit(image, (0, 0))
circlept
mousex, mousey = -((100*pygame.mouse.get_pos()[1])+(800*RADIUS)-31000)/289, -(
(2*(pygame.mouse.get_pos()[0]+(2*RADIUS)-300))/7)
outputText = 'X: '+str(mousex)+' Y: '+str(mousey)
text = font.render(outputText, True, green, blue)
if yactive:
yellowCircle = pygame.draw.circle(display_surface, yellow, [
pty, ptx], RADIUS*4, width=2)
for coord in coords:
screenCoord = FieldToScreen(coord)
pygame.draw.circle(display_surface, green, screenCoord, RADIUS*4, width=2)
greenS.center=screenCoord[0]+(RADIUS*pi), screenCoord[1]-RADIUS
coordText = (f'X: {ScreenToField(screenCoord)[0]}'+f' Y: {ScreenToField(screenCoord)[1]}')
textFGCS = font.render(str(stepList[step-2]), True, blue)
coordsText = font.render(coordText, True, blue, green)
print(stepList)
pre_mouse = pygame.mouse.get_pos()
pygame.draw.rect(display_surface, color, input_rect)
text_surface = base_font.render(user_text, True, (255, 255, 255))
display_surface.blit(text_surface, (input_rect.x+5, input_rect.y+5))
display_surface.blit(text, textRect)
display_surface.blit(textFGCS, greenS)
display_surface.blit(coordsText, greenTextRect)
input_rect.w = max(100, text_surface.get_width()+10)
pygame.display.flip()
clock.tick(60)
for event in pygame.event.get():
if active == False:
if event.type == pygame.MOUSEBUTTONDOWN:
stepList.append(step)
coords.append(ScreenToField(pygame.mouse.get_pos()))
step+=1
if event.type == pygame.KEYDOWN:
if len(coords)>=1:
if event.key == pygame.K_DELETE:
coordText = "Click a point to get position"
textFGCS = font.render('', True, blue)
stepList.clear()
textStepsList.clear()
step=1
coords = []
coordsText = font.render(coordText, True, blue, green)
if event.type == pygame.MOUSEBUTTONDOWN:
if input_rect.collidepoint(event.pos):
active = True
else:
active = False
if active:
color = color_active
else:
color = color_passive
pygame.draw.rect(display_surface, color, input_rect)
text_surface = base_font.render(user_text, True, (255, 255, 255))
display_surface.blit(text_surface, (input_rect.x+5, input_rect.y+5))
if event.type == pygame.KEYDOWN and event.key == pygame.K_RIGHT:
print(coords)
if event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT:
pass
if event.type == pygame.KEYUP and event.key == pygame.K_RIGHT:
pass
if event.type == pygame.KEYUP and event.key == pygame.K_LEFT:
pass
if active:
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_BACKSPACE:
user_text = user_text[:-1]
else:
user_text += event.unicode
inputCoords = user_text[6:].split(',')
print(inputCoords)
try:
if len(inputCoords) == 2 or len(inputCoords) == 3:
if inputCoords[1] != '' and inputCoords[1] != '-':
yactive = True
if len(inputCoords) == 3:
if inputCoords[2] != '' and inputCoords[2] != '-' and float(inputCoords[2]) <= 360 and float(inputCoords[2]) >= -360:
pass
ptx, pty = (-2.89*(float(inputCoords[0])))-(
8*RADIUS)+310, (-3.5*float(inputCoords[1]))-(2*RADIUS)+300
print('ptx:'+str(ptx)+' pty:'+str(pty))
else:
yactive=False
except:
pass
if event.type == pygame.QUIT:
pygame.quit()
quit()
pygame.display.update()