From f04a0144780885dc5cd62a76e7108ad432065312 Mon Sep 17 00:00:00 2001 From: Toby Lane Date: Wed, 3 Jul 2024 22:55:11 +0200 Subject: [PATCH] added color difference to named nodes + fixed node name readability --- src/editor.py | 10 +++++++--- src/graph/graph.py | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/editor.py b/src/editor.py index a5abe91..0b2a6ea 100644 --- a/src/editor.py +++ b/src/editor.py @@ -345,7 +345,8 @@ class Editor: def render_nodes(self) -> None: for node in self.graph.nodes: blitpos = self.world_to_screen(node.x, node.z) - pygame.draw.circle(self.win, (255, 0, 0), (blitpos[0], blitpos[1]), self.node_radius) + color = (255, 0, 0) if node.name == "" else (255, 0, 255) + pygame.draw.circle(self.win, color, (blitpos[0], blitpos[1]), self.node_radius) for node_index in self.selected_nodes: node = self.graph.nodes[node_index] blitpos = self.world_to_screen(node.x, node.z) @@ -354,9 +355,12 @@ class Editor: def render_hover_node(self, node_index): if node_index != -1: node = self.graph.nodes[node_index] - txt = self.loading_font.render(node.name, True, (0, 0, 0)) + txt = self.loading_font.render(node.name, True, (255, 255, 255)) node_pos = self.world_to_screen(node.x, node.z) - self.win.blit(txt, [node_pos[0] - txt.get_width(), node_pos[1] - txt.get_height()]) + xpos = node_pos[0] - txt.get_width() - self.node_radius * (2 ** -0.5) + ypos = node_pos[1] - txt.get_height() - self.node_radius * (2 ** -0.5) + pygame.draw.rect(self.win, (0, 0, 0), pygame.Rect(xpos, ypos, txt.get_width(), txt.get_height())) + self.win.blit(txt, [xpos, ypos]) pygame.draw.circle(self.win, (0, 0, 0), (node_pos[0], node_pos[1]), self.node_radius, self.line_size) def render_hover_edge(self, edge_index): diff --git a/src/graph/graph.py b/src/graph/graph.py index 0d9dc8a..8b66b50 100644 --- a/src/graph/graph.py +++ b/src/graph/graph.py @@ -18,9 +18,9 @@ class Graph: TYPE_COLORS: list[tuple[int, int, int]] = [ (255, 0, 0), - (127, 0, 0), + (255, 0, 255), (0, 255, 0), - (0, 127, 0), + (255, 255, ), (0, 0, 255) ]