Detailed Description

Used to map colour name to colour value. Note that this can be deleted - make sure you add a compile flag of "NoColourMap" if you choose to remove it to minimise size.

Static Public Member Functions

static Color ToSpecialColour (string randomString)
 Converts any random string into a colour. This is a strange part of the specs that rarely gets used now, but it makes for some interesting colours ("grass" is green!). For example, body bgcolor uses this. More...
 
static Color GetColourByName (string name, out bool success)
 Maps colour name, e.g. aqua, to colour. Must be lowercase. More...
 
static Color GetColour (string valueText)
 Gets a colour from either hex or a named colour. More...
 
static Color GetHexColour (string valueText)
 Gets a colour from a hex HTML string. More...
 
static void GetHexColour (string valueText, out float r, out float g, out float b, out float a)
 Gets a colour from a hex HTML string. More...
 
static void GetHexColour (string valueText, out int r, out int g, out int b, out int a)
 Gets a colour from a hex HTML string. More...
 

Static Private Member Functions

static int LoadHexFromPart (string randomString, int startOffset, int length)
 Loads a hex value from the given 'any' string. Non-hex chars are treated as 0. (Normally, non-hex chars invalidate the whole thing). More...
 
static int DoubleNibble (int nibble)
 Duplicates the given nibble (4 bit number) and places the result alongside in the same byte. E.g. c in hex becomes cc. More...
 

Static Private Attributes

static Dictionary< string, Color > Map
 A map from colour name to hex value. More...
 
static string[] Colours
 

Member Function Documentation

static int Css.ColourMap.DoubleNibble ( int  nibble)
inlinestaticprivate

Duplicates the given nibble (4 bit number) and places the result alongside in the same byte. E.g. c in hex becomes cc.

Parameters
nibbleThe nibble to duplicate.
static Color Css.ColourMap.GetColour ( string  valueText)
inlinestatic

Gets a colour from either hex or a named colour.

static Color Css.ColourMap.GetColourByName ( string  name,
out bool  success 
)
inlinestatic

Maps colour name, e.g. aqua, to colour. Must be lowercase.

Returns
An uppercase hex string or null if not found.
static Color Css.ColourMap.GetHexColour ( string  valueText)
inlinestatic

Gets a colour from a hex HTML string.

static void Css.ColourMap.GetHexColour ( string  valueText,
out float  r,
out float  g,
out float  b,
out float  a 
)
inlinestatic

Gets a colour from a hex HTML string.

static void Css.ColourMap.GetHexColour ( string  valueText,
out int  r,
out int  g,
out int  b,
out int  a 
)
inlinestatic

Gets a colour from a hex HTML string.

static int Css.ColourMap.LoadHexFromPart ( string  randomString,
int  startOffset,
int  length 
)
inlinestaticprivate

Loads a hex value from the given 'any' string. Non-hex chars are treated as 0. (Normally, non-hex chars invalidate the whole thing).

static Color Css.ColourMap.ToSpecialColour ( string  randomString)
inlinestatic

Converts any random string into a colour. This is a strange part of the specs that rarely gets used now, but it makes for some interesting colours ("grass" is green!). For example, body bgcolor uses this.

Member Data Documentation

string [] Css.ColourMap.Colours
staticprivate
Dictionary<string,Color> Css.ColourMap.Map
staticprivate

A map from colour name to hex value.