Class ColorPalette
A named set of colours used for portrayal, keyed by S-100 colour token.
public sealed class ColorPalette
- Inheritance
-
ColorPalette
- Inherited Members
Remarks
Portrayal catalogues load one palette per PaletteType from their colour profile and expose the active one through ActivePalette.
Constructors
ColorPalette(string, IReadOnlyDictionary<string, string>)
Creates a palette.
public ColorPalette(string name, IReadOnlyDictionary<string, string> colors)
Parameters
namestringThe palette name.
colorsIReadOnlyDictionary<string, string>Colours keyed by colour token; the dictionary is used as-is, not copied.
Properties
Colors
Colours keyed by S-100 colour token (e.g. "DEPDW"), with values
as #RRGGBB hex strings. Token matching follows the supplied
dictionary's comparer.
public IReadOnlyDictionary<string, string> Colors { get; }
Property Value
Default
An empty palette named "Day". Every token resolves to the
Resolve(string) fallback; catalogues use it as the active
palette until a real one has been loaded.
public static ColorPalette Default { get; }
Property Value
Name
The palette name (e.g. "Day", "Dusk", "Night").
public string Name { get; }
Property Value
Methods
FromType(PaletteType)
Returns an empty placeholder palette named after type.
public static ColorPalette FromType(PaletteType type)
Parameters
typePaletteTypeThe palette type.
Returns
- ColorPalette
Default for Day (and unknown values); otherwise a new empty palette named
"Dusk"or"Night". The result carries no colours; real palettes come from a portrayal catalogue's colour profile.
Resolve(string)
Resolves a colour token to its hex colour.
public string Resolve(string token)
Parameters
tokenstringThe S-100 colour token.
Returns
- string
The token's hex colour, or
"#000000"when the palette does not define it.
TryResolve(string, out string)
Attempts to resolve a colour token to its hex colour.
public bool TryResolve(string token, out string hex)
Parameters
tokenstringThe S-100 colour token.
hexstringWhen this method returns true, the token's hex colour.