diff --git a/SDFMapCreator/Program.cs b/SDFMapCreator/Program.cs index e7f4b72..c79fda3 100644 --- a/SDFMapCreator/Program.cs +++ b/SDFMapCreator/Program.cs @@ -59,12 +59,15 @@ public class Program { private const bool outputMasks = true; private const bool outputSDFs = true; private const bool outputGradients = true; + static readonly ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = MAX_THREADS }; static List Images = new(); static List Masks = new(); static List SDFs = new(); static List Gradients = new(); - static readonly ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = MAX_THREADS }; + static void ConsoleUpdateLine(string s) { + Console.Write("\r"+s); + } static void LoadImage(string imgPath) { var image = new MagickImage(imgPath); @@ -210,7 +213,7 @@ public class Program { lock(maskData.Edges) maskData.Edges.Add(new(x, y)); iterCount++; if (iterCount % (width * height / 100) == 0) { - Console.WriteLine($"Progress: {iterCount/(float)(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(); @@ -276,7 +279,7 @@ public class Program { if (minDist > AbsMax) AbsMax = minDist; iterCount++; if (iterCount % (width * height / 100) == 0) { - Console.WriteLine($"Progress: {iterCount/(float)(width*height):P} | {iterCount/(sw.Elapsed.TotalSeconds):N0} pixels/s"); + ConsoleUpdateLine($"Progress: {iterCount/(width*height):P}% | {iterCount/(sw.Elapsed.TotalSeconds):N0} pixels/s"); } }); @@ -362,4 +365,4 @@ public class Program { static T Remap(T value, T min, T max, T newMin, T newMax) where T : INumber, ISubtractionOperators, IMultiplyOperators, IAdditionOperators => (value - min) / (max - min) * (newMax - newMin) + newMin; -} \ No newline at end of file +}