Update ColorUtilityUnstrip.cs

This commit is contained in:
Sinai 2020-10-25 21:28:58 +11:00 committed by GitHub
parent 648ac941df
commit 32684bc63e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,14 +10,11 @@ namespace Explorer.Unstrip.ColorUtility
{
public static string ToHex(this Color color)
{
var color32 = new Color32(
(byte)Mathf.Clamp(Mathf.RoundToInt(color.r * 255f), 0, 255),
(byte)Mathf.Clamp(Mathf.RoundToInt(color.g * 255f), 0, 255),
(byte)Mathf.Clamp(Mathf.RoundToInt(color.b * 255f), 0, 255),
1
);
var r = (byte)Mathf.Clamp(Mathf.RoundToInt(color.r * 255f), 0, 255);
var g = (byte)Mathf.Clamp(Mathf.RoundToInt(color.g * 255f), 0, 255);
var b = (byte)Mathf.Clamp(Mathf.RoundToInt(color.b * 255f), 0, 255);
return string.Format("{0:X2}{1:X2}{2:X2}", color32.r, color32.g, color32.b);
return $"{r:X2}{g:X2}{b:X2}";
}
}
}