added new method to convert byte array to lower case hex-string

added unit test

update ToHex(byte[]) to support mono

added punctuations to unit test summary and parameter description

Replaced with Convert.ToHexString(), public ToHex() + use from Color.ToString()

Adjusted back to a simpler mono compatible version only, with lowered allocation
This commit is contained in:
Rudy Alex Kohn
2023-09-17 21:39:56 +02:00
committed by Gustas
parent b25146265d
commit 7769764b0b
3 changed files with 69 additions and 6 deletions

View File

@@ -224,9 +224,9 @@ namespace OpenRA.Primitives
public override string ToString()
{
if (A == 255)
return R.ToStringInvariant("X2") + G.ToStringInvariant("X2") + B.ToStringInvariant("X2");
return CryptoUtil.ToHex(stackalloc byte[3] { R, G, B });
return R.ToStringInvariant("X2") + G.ToStringInvariant("X2") + B.ToStringInvariant("X2") + A.ToStringInvariant("X2");
return CryptoUtil.ToHex(stackalloc byte[4] { R, G, B, A });
}
public static Color Transparent => FromArgb(0x00FFFFFF);