From 01a92b209984ccadaf24fa7461ef42bd8f25dfff Mon Sep 17 00:00:00 2001 From: Samuele Lorefice Date: Fri, 28 Mar 2025 18:46:38 +0100 Subject: [PATCH] Improved logging --- SDFMapCreator/Program.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/SDFMapCreator/Program.cs b/SDFMapCreator/Program.cs index 8a43e28..07a2374 100644 --- a/SDFMapCreator/Program.cs +++ b/SDFMapCreator/Program.cs @@ -48,6 +48,8 @@ public static class ArrayExt { } } + + public class Program { private const float MAX = 65535f; private const float MIN = 0f; @@ -59,6 +61,10 @@ public class Program { static List SDFs = new(); static List Gradients = new(); + static void ConsoleUpdateLine(string s) { + Console.Write("\r"+s); + } + static void LoadImage(string imgPath) { var image = new MagickImage(imgPath); float3[,] pixels; @@ -179,7 +185,7 @@ public class Program { lock(maskData.Edges) maskData.Edges.Add(new(x, y)); iterCount++; if (iterCount % (width * height / 100) == 0) { - Console.WriteLine($"Progress: {iterCount/(width*height):P}% | {iterCount/(sw.Elapsed.TotalSeconds):N0} pixels/s"); + ConsoleUpdateLine($"Progress: {iterCount/(width*height):P}% | {iterCount/(sw.Elapsed.TotalSeconds):N0} pixels/s"); } }); sw.Stop(); @@ -238,7 +244,7 @@ public class Program { if (minDist > AbsMax) AbsMax = minDist; iterCount++; if (iterCount % (width * height / 100) == 0) { - Console.WriteLine($"Progress: {iterCount/(width*height):P}% | {iterCount/(sw.Elapsed.TotalSeconds):N0} pixels/s"); + ConsoleUpdateLine($"Progress: {iterCount/(width*height):P}% | {iterCount/(sw.Elapsed.TotalSeconds):N0} pixels/s"); } });