From 9bddcfaa7ed68920ac1f2f3494523d7b9e970621 Mon Sep 17 00:00:00 2001 From: Felix Pankratz Date: Tue, 22 Jul 2025 23:51:28 +0200 Subject: [PATCH] color arches based on latency --- kglobe.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/kglobe.py b/kglobe.py index 8015225..cd56d34 100644 --- a/kglobe.py +++ b/kglobe.py @@ -110,7 +110,7 @@ def traceroute(target: str): # exclude common local network addreses continue hop = database.get_all(ip) - hop.latency = latency + hop.latency = float(latency) hops.append(hop) return hops @@ -163,7 +163,7 @@ async def main(): ) for point in points_3d: - city_marker = pv.Sphere(center=point, radius=0.02) + city_marker = pv.Sphere(center=point, radius=0.01) plotter.add_mesh(city_marker, color="blue") labels = [ f'{_.country_short}: {_.latency}ms' for _ in locations] @@ -174,7 +174,16 @@ async def main(): for i in range(len(points_3d[:-1])): arch = generate_arch(points_3d[i], points_3d[i + 1], height_factor=0.2) line = pv.lines_from_points(arch, close=False) - plotter.add_mesh(line, color="red", line_width=2) + diff = locations[i+1].latency - locations[i].latency + if diff < 20: + color="green" + elif diff < 0.5: + color = "yellow" + elif diff < 0.7: + color = "orange" + else: + color = "red" + plotter.add_mesh(line, color=color, line_width=2) kitty.hide_cursor() try: