Class Utils.Color
- Namespace
- RichHudFramework
- Assembly
- RichHudClient.dll
Utilities for parsing and formatting Color values from/to strings. Supports common formats such as "255,255,255", " 100, 50, 0 ", or "128,64,32,255".
public static class Utils.Color
- Inheritance
-
Utils.Color
Methods
CanParseColor(string)
Determines whether the given string can be successfully parsed as a color (3–4 byte components).
public static bool CanParseColor(string colorData)
Parameters
colorDatastringThe string to test.
Returns
- bool
True if the string contains 3 or 4 valid byte values; otherwise false.
GetColorString(Color, bool)
Converts a Color to a simple comma-separated string.
public static string GetColorString(Color color, bool includeAlpha = true)
Parameters
Returns
- string
A string like "255,255,255" or "255,255,255,128".
ParseColor(string, bool)
Parses a string into a Color. Throws on invalid input.
public static Color ParseColor(string colorData, bool ignoreAlpha = false)
Parameters
colorDatastringString containing 3–4 numeric components separated by commas.
ignoreAlphaboolIf true and only 3 components are provided, the alpha is defaulted to 255.
Returns
- Color
The parsed color.
Exceptions
- Exception
Thrown when the string is malformed or contains invalid values.
TryParseColor(string, out Color, bool)
Attempts to parse a string into a Color. Returns true on success.
public static bool TryParseColor(string colorData, out Color value, bool ignoreAlpha = false)
Parameters
colorDatastringString containing 3–4 numeric components.
valueColorReceives the parsed color on success; white on failure.
ignoreAlphaboolIf true and only 3 components are provided, the alpha is defaulted to 255.
Returns
- bool
True if parsing succeeded.