Compare commits

...

2 Commits

Author SHA1 Message Date
Samuele Lorefice
84a49bb2a8 Merge remote-tracking branch 'origin/master' 2025-03-28 18:49:23 +01:00
Samuele Lorefice
01a92b2099 Improved logging 2025-03-28 18:46:38 +01:00

View File

@@ -59,12 +59,15 @@ public class Program {
private const bool outputMasks = true; private const bool outputMasks = true;
private const bool outputSDFs = true; private const bool outputSDFs = true;
private const bool outputGradients = true; private const bool outputGradients = true;
static readonly ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = MAX_THREADS };
static List<ImageData> Images = new(); static List<ImageData> Images = new();
static List<MaskData> Masks = new(); static List<MaskData> Masks = new();
static List<SDFData> SDFs = new(); static List<SDFData> SDFs = new();
static List<float3[,]> Gradients = new(); static List<float3[,]> Gradients = new();
static readonly ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = MAX_THREADS }; static void ConsoleUpdateLine(string s) {
Console.Write("\r"+s);
}
static void LoadImage(string imgPath) { static void LoadImage(string imgPath) {
var image = new MagickImage(imgPath); var image = new MagickImage(imgPath);
@@ -182,7 +185,7 @@ public class Program {
lock(maskData.Edges) maskData.Edges.Add(new(x, y)); lock(maskData.Edges) maskData.Edges.Add(new(x, y));
iterCount++; iterCount++;
if (iterCount % (width * height / 100) == 0) { 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(); sw.Stop();
@@ -241,7 +244,7 @@ public class Program {
if (minDist > AbsMax) AbsMax = minDist; if (minDist > AbsMax) AbsMax = minDist;
iterCount++; iterCount++;
if (iterCount % (width * height / 100) == 0) { 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");
} }
}); });
@@ -326,4 +329,4 @@ public class Program {
static T Remap<T>(T value, T min, T max, T newMin, T newMax) static T Remap<T>(T value, T min, T max, T newMin, T newMax)
where T : INumber<T>, ISubtractionOperators<T, T, T>, IMultiplyOperators<T, T, T>, IAdditionOperators<T, T, T> where T : INumber<T>, ISubtractionOperators<T, T, T>, IMultiplyOperators<T, T, T>, IAdditionOperators<T, T, T>
=> (value - min) / (max - min) * (newMax - newMin) + newMin; => (value - min) / (max - min) * (newMax - newMin) + newMin;
} }