Class SCP_Utils
Static utility class acting on Palettes
, offering methods related to
data persistence and exchange.
Inherited Members
Namespace: BinaryCharm.SemanticColorPalette.Utils
Assembly: cs.temp.dll.dll
Syntax
public static class SCP_Utils
Methods
ExtractColorDefs(SCP_Palette)
Extracts the color definitions data from a @SCP_Palette, as a dictionary of string -> Color pairs.
Declaration
public static Dictionary<string, Color> ExtractColorDefs(SCP_Palette rPalette)
Parameters
Type | Name | Description |
---|---|---|
SCP_Palette | rPalette | The input @SCP_Palette |
Returns
Type | Description |
---|---|
Dictionary<String, Color> | A dictionary of the palette color definitions |
LoadPalette(String)
Loads a @SCP_Palette from a JSON file previously saved with @BinaryCharm.SemanticColorPalette.Utils.SCP_Utils.SavePalette
Declaration
public static SCP_Palette LoadPalette(string sFilePath)
Parameters
Type | Name | Description |
---|---|---|
String | sFilePath | The path of the JSON file to load. |
Returns
Type | Description |
---|---|
SCP_Palette | The @SCP_Palette represented by the JSON file. |
SavePalette(SCP_Palette, String)
Saves rPalette
to a JSON file at path
sFilePath
, overwriting if it already exists.
Declaration
public static void SavePalette(SCP_Palette rPalette, string sFilePath)
Parameters
Type | Name | Description |
---|---|---|
SCP_Palette | rPalette | A @SCP_Palette to save. |
String | sFilePath | The destination path for the file to be written. |
UpdateColorDefs(SCP_Palette, Dictionary<String, Color>)
Utility method that overwrites the color definitions of a @SCP_Palette by the definitions passed in input as a string -> Color dictionary.
Declaration
public static void UpdateColorDefs(SCP_Palette rPalette, Dictionary<string, Color> rColorDefs)
Parameters
Type | Name | Description |
---|---|---|
SCP_Palette | rPalette | The input @SCP_Palette |
Dictionary<String, Color> | rColorDefs |
Remarks
The method only overwrites the color definitions for
which rPalette
has a matching identifier.
So, the overwrite can be partial, which can be useful if you want to
"patch" only some colors, or if you are overwriting a palette with
external data saved in the past (before new definitions were added
to the palette). In casse of a partial overwrite, throws an
exception - if a partial update is expected/desired, catch it.