Table of Contents

Method TryParseHex

Namespace
Gamelogic.Colors
Assembly
Gamelogic.Colors.dll

TryParseHex(string, out Color)

Tries to parse a Color from a hexadecimal string.

public static bool TryParseHex(string hex, out Color color)

Parameters

hex string

The hexadecimal string to parse.

color Color

The color if the parsing was successful, black otherwise.

Returns

bool

Whether the parsing was successful.

Remarks

The string may start with an optional # character.

If the string is 3 or 4 characters long, the characters are each repeated to form a 6 or 8 character string.

If the string has 6 characters, the first two characters are the red component, the next two are the green component, and the last two are the blue component.

If the string has 8 characters, the last two characters are the alpha component.