Table of Contents

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

colorData string

The 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

color Color

The color to format.

includeAlpha bool

If false, the alpha component is omitted.

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

colorData string

String containing 3–4 numeric components separated by commas.

ignoreAlpha bool

If 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

colorData string

String containing 3–4 numeric components.

value Color

Receives the parsed color on success; white on failure.

ignoreAlpha bool

If true and only 3 components are provided, the alpha is defaulted to 255.

Returns

bool

True if parsing succeeded.