]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Limits the minimum base skin color brightness for species with Hue coloration (#23605)
authordeathride58 <deathride58@users.noreply.github.com>
Sat, 6 Jan 2024 09:40:29 +0000 (04:40 -0500)
committerGitHub <noreply@github.com>
Sat, 6 Jan 2024 09:40:29 +0000 (20:40 +1100)
adds a minimum skin tone for hue skin colors

Content.Shared/Humanoid/SkinColor.cs

index 89c78b7ea008834063ce4f311ea27e7955517fc1..960f910a323318fb1d5566976bf120cedca023a9 100644 (file)
@@ -5,6 +5,8 @@ public static class SkinColor
     public const float MaxTintedHuesSaturation = 0.1f;
     public const float MinTintedHuesLightness = 0.85f;
 
+    public const float MinHuesLightness = 0.175f;
+
     public static Color ValidHumanSkinTone => Color.FromHsv(new Vector4(0.07f, 0.2f, 1f, 1f));
 
     /// <summary>
@@ -138,13 +140,35 @@ public static class SkinColor
         return Color.ToHsl(color).Y <= MaxTintedHuesSaturation && Color.ToHsl(color).Z >= MinTintedHuesLightness;
     }
 
+    /// <summary>
+    ///     This takes in a color, and returns a color guaranteed to be above MinHuesLightness
+    /// </summary>
+    /// <param name="color"></param>
+    /// <returns>Either the color as-is if it's above MinHuesLightness, or the color with luminosity increased above MinHuesLightness</returns> 
+    public static Color MakeHueValid(Color color)
+    {
+        var manipulatedColor = Color.ToHsv(color);
+        manipulatedColor.Z = Math.Max(manipulatedColor.Z, MinHuesLightness);
+        return Color.FromHsv(manipulatedColor);
+    }
+
+    /// <summary>
+    ///     Verify if this color is above a minimum luminosity
+    /// </summary>
+    /// <param name="color"></param>
+    /// <returns>True if valid, false if not</returns>
+    public static bool VerifyHues(Color color)
+    {
+        return Color.ToHsv(color).Z >= MinHuesLightness;
+    }
+
     public static bool VerifySkinColor(HumanoidSkinColor type, Color color)
     {
         return type switch
         {
             HumanoidSkinColor.HumanToned => VerifyHumanSkinTone(color),
             HumanoidSkinColor.TintedHues => VerifyTintedHues(color),
-            HumanoidSkinColor.Hues => true,
+            HumanoidSkinColor.Hues => VerifyHues(color),
             _ => false,
         };
     }
@@ -155,6 +179,7 @@ public static class SkinColor
         {
             HumanoidSkinColor.HumanToned => ValidHumanSkinTone,
             HumanoidSkinColor.TintedHues => ValidTintedHuesSkinTone(color),
+            HumanoidSkinColor.Hues => MakeHueValid(color),
             _ => color
         };
     }