aboutsummaryrefslogtreecommitdiff
path: root/src/Costasdev.Busurbano.Backend/Helpers
diff options
context:
space:
mode:
authorAriel Costas Guerrero <ariel@costas.dev>2025-12-29 00:41:52 +0100
committerAriel Costas Guerrero <ariel@costas.dev>2025-12-29 00:41:52 +0100
commita304c24b32c0327436bbd8c2853e60668e161b42 (patch)
tree08f65c05daca134cf4d2e4f779bd15d98fd66370 /src/Costasdev.Busurbano.Backend/Helpers
parent120a3c6bddd0fb8d9fa05df4763596956554c025 (diff)
Rename a lot of stuff, add Santiago real time
Diffstat (limited to 'src/Costasdev.Busurbano.Backend/Helpers')
-rw-r--r--src/Costasdev.Busurbano.Backend/Helpers/ContrastHelper.cs48
-rw-r--r--src/Costasdev.Busurbano.Backend/Helpers/SortingHelper.cs35
2 files changed, 0 insertions, 83 deletions
diff --git a/src/Costasdev.Busurbano.Backend/Helpers/ContrastHelper.cs b/src/Costasdev.Busurbano.Backend/Helpers/ContrastHelper.cs
deleted file mode 100644
index f9fd5f2..0000000
--- a/src/Costasdev.Busurbano.Backend/Helpers/ContrastHelper.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-namespace Costasdev.Busurbano.Backend.Helpers;
-
-using System;
-using System.Globalization;
-
-public static class ContrastHelper
-{
- public static string GetBestTextColour(string backgroundHex)
- {
- // Strip #
- backgroundHex = backgroundHex.TrimStart('#');
-
- if (backgroundHex.Length != 6)
- throw new ArgumentException("Hex colour must be 6 characters (RRGGBB)");
-
- // Parse RGB
- int r = int.Parse(backgroundHex.Substring(0, 2), NumberStyles.HexNumber);
- int g = int.Parse(backgroundHex.Substring(2, 2), NumberStyles.HexNumber);
- int b = int.Parse(backgroundHex.Substring(4, 2), NumberStyles.HexNumber);
-
- // Convert to relative luminance
- double luminance = GetRelativeLuminance(r, g, b);
-
- // Contrast ratios
- double contrastWithWhite = (1.0 + 0.05) / (luminance + 0.05);
- double contrastWithBlack = (luminance + 0.05) / 0.05;
-
- if (contrastWithWhite >= 2.5)
- {
- return "#FFFFFF";
- }
-
- return "#000000";
- }
-
- private static double GetRelativeLuminance(int r, int g, int b)
- {
- double rs = r / 255.0;
- double gs = g / 255.0;
- double bs = b / 255.0;
-
- rs = rs <= 0.03928 ? rs / 12.92 : Math.Pow((rs + 0.055) / 1.055, 2.4);
- gs = gs <= 0.03928 ? gs / 12.92 : Math.Pow((gs + 0.055) / 1.055, 2.4);
- bs = bs <= 0.03928 ? bs / 12.92 : Math.Pow((bs + 0.055) / 1.055, 2.4);
-
- return 0.2126 * rs + 0.7152 * gs + 0.0722 * bs;
- }
-}
diff --git a/src/Costasdev.Busurbano.Backend/Helpers/SortingHelper.cs b/src/Costasdev.Busurbano.Backend/Helpers/SortingHelper.cs
deleted file mode 100644
index 472a56f..0000000
--- a/src/Costasdev.Busurbano.Backend/Helpers/SortingHelper.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-namespace Costasdev.Busurbano.Backend.Helpers;
-
-public class SortingHelper
-{
- public static int SortRouteShortNames(string? a, string? b)
- {
- if (a == null && b == null) return 0;
- if (a == null) return 1;
- if (b == null) return -1;
-
- var aDigits = new string(a.Where(char.IsDigit).ToArray());
- var bDigits = new string(b.Where(char.IsDigit).ToArray());
-
- bool aHasDigits = int.TryParse(aDigits, out int aNumber);
- bool bHasDigits = int.TryParse(bDigits, out int bNumber);
-
- if (aHasDigits != bHasDigits)
- {
- // Non-numeric routes (like "A" or "-") go to the beginning
- return aHasDigits ? 1 : -1;
- }
-
- if (aHasDigits && bHasDigits)
- {
- if (aNumber != bNumber)
- {
- return aNumber.CompareTo(bNumber);
- }
- }
-
- // If both are non-numeric, or numeric parts are equal, use alphabetical
- return string.Compare(a, b, StringComparison.OrdinalIgnoreCase);
- }
-
-}