-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
point.py
35 lines (26 loc) · 1.14 KB
/
point.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
import pygame
pygame.font.init()
textColor = (0, 0, 0)
# textFont = pg.font.Font("freesansbold.ttf", size)
textFont = pygame.font.SysFont("Arial", 20)
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
self.radius = 1
self.alpha = 150
def Draw(self, manager, showIndex=False, highlight=False, point_index=0):
surface = pygame.Surface((self.radius *2, self.radius*2), pygame.SRCALPHA, 32)
if highlight:
r, g, b = manager.White
pygame.draw.circle(surface, (r, g, b, 255), (self.radius, self.radius), self.radius)
pygame.draw.circle(surface, (r, g, b, 255), (self.radius, self.radius), self.radius, 1)
manager.screen.blit(surface, (int(self.x-self.radius), int(self.y-self.radius)))
if showIndex:
textSurface = textFont.render(str(point_index), True, textColor)
textRectangle = textSurface.get_rect(center=(self.x, self.y))
manager.screen.blit(textSurface, textRectangle)
def GetTuple(self):
return (self.x, self.y)
def __repr__(self):
return f"({self.x}, {self.y})"