ZahirJS commited on
Commit
d5fc08e
·
verified ·
1 Parent(s): 9c442bc

Update binary_tree_generator.py

Browse files
Files changed (1) hide show
  1. binary_tree_generator.py +7 -3
binary_tree_generator.py CHANGED
@@ -83,13 +83,17 @@ def generate_binary_tree_diagram(json_input: str, output_format: str) -> str:
83
  # Calculate color opacity based on depth
84
  max_depth = 5 # Assume maximum depth for color calculation
85
  if current_depth >= max_depth:
86
- opacity = '80' # Minimum opacity
87
  else:
88
  opacity_value = int(255 * (1.0 - (current_depth * 0.6 / max_depth)))
89
- opacity = format(opacity_value, '02x')
90
 
 
91
  node_color = f"{base_color}{opacity}"
92
- font_color = 'white' if current_depth < 3 else 'black'
 
 
 
 
93
 
94
  # Add the current node
95
  dot.node(
 
83
  # Calculate color opacity based on depth
84
  max_depth = 5 # Assume maximum depth for color calculation
85
  if current_depth >= max_depth:
86
+ opacity_value = 128 # Minimum opacity (50%)
87
  else:
88
  opacity_value = int(255 * (1.0 - (current_depth * 0.6 / max_depth)))
 
89
 
90
+ opacity = format(opacity_value, '02x')
91
  node_color = f"{base_color}{opacity}"
92
+
93
+ # Determine font color based on background brightness
94
+ # If opacity_value is high (dark background), use white text
95
+ # If opacity_value is low (light background), use black text
96
+ font_color = 'white' if opacity_value > 180 else 'black'
97
 
98
  # Add the current node
99
  dot.node(