Selaa lähdekoodia

修改文本颜色,使剪贴板匹配的文件节点文件名也变红

zhong (钟鹏群) 1 kuukausi sitten
vanhempi
commit
d64f66333f
1 muutettua tiedostoa jossa 7 lisäystä ja 4 poistoa
  1. 7 4
      src/ball-demo.py

+ 7 - 4
src/ball-demo.py

@@ -237,7 +237,7 @@ def build_directory_tree(root_path, max_depth=3, max_children_per_node=30):
                 # 半径随深度减小
                 # radius = 0.75 * (0.75 ** depth)  # 深度越大,半径越小,基础半径减半
                 if depth == 1:
-                    radius = 2
+                    radius = 1.5
                 else:
                     radius = 0.75 * (0.75 ** depth)  # 深度越大,半径越小,基础半径减半
                 
@@ -273,10 +273,10 @@ root_path = "E:\\agricultural_research_platform"
 
 tree_nodes, tree_edges, node_positions, tree_children = build_directory_tree(root_path)
 
-def draw_text(x, y, z, text):
+def draw_text(x, y, z, text, color=(1.0, 1.0, 1.0)):
     """在3D空间中绘制文本"""
     glDisable(GL_LIGHTING)
-    glColor3f(1.0, 1.0, 1.0)  # 白色文本
+    glColor3f(*color)  # 使用指定的颜色
     
     # 保存当前矩阵
     glPushMatrix()
@@ -480,7 +480,10 @@ while running:
         glPopMatrix()
         
         # 绘制文件名
-        draw_text(x, y + current_radius + 0.05, z, name)
+        if i in blinking_nodes:  # 闪烁节点使用红色文本
+            draw_text(x, y + current_radius + 0.05, z, name, color=(1.0, 0.0, 0.0))  # 红色文本
+        else:
+            draw_text(x, y + current_radius + 0.05, z, name)  # 默认白色文本
     
     # 交换缓冲区
     pygame.display.flip()