NamedPalette

References
public sealed class NamedPalette : IStorable
Represents a collection of uniquely named colours. Think of this as a colour dictionary.

Constructors

NamedPalette

#
public NamedPalette()
Create a new empty palette.

NamedPalette

#
public NamedPalette(IEnumerable<NamedColour> colours)
Create a new populated palette.
colours (IEnumerable<NamedColour>)Collection of colours. All names must be unique.

NamedPalette

#
public NamedPalette(IReader reader)
Deserialization constructor.
reader (IReader)

Fields

OpenColorPaletteName

#
public const string OpenColorPaletteName = "OpenColor"
Gets the official name of the OpenColorPalette.

StandardCorePaletteName

#
public const string StandardCorePaletteName = "Standard Core"
Gets the official name of the StandardCorePalette.

StandardFullPaletteName

#
public const string StandardFullPaletteName = "Standard Full"
Gets the official name of the StandardFullPalette.

X11PaletteName

#
public const string X11PaletteName = "X11/Html"
Gets the official name of the X11Palette.

Properties

Colours

#
public IEnumerable<NamedColour> Colours { get; }
Enumerate over all colours in this palette.

Count

#
public int Count { get; }
Gets the number of colours stored in this palette.

EmptyPalette

#
public static NamedPalette EmptyPalette { get; }
Create an 'empty' palette containing only Black and White.
Palette with the only colours *everyone* can agree on.

KnownPaletteNames

#
public static IEnumerable<(string name, string info)> KnownPaletteNames { get; }
Iterate over all known palette names.

OpenColorPalette

#
public static NamedPalette OpenColorPalette { get; }
Create the standard open-color palette.

StandardCorePalette

#
public static NamedPalette StandardCorePalette { get; }
Create the standard Grasshopper colour palette containing only the principal colours.

StandardFullPalette

#
public static NamedPalette StandardFullPalette { get; }
Create the standard Grasshopper colour palette, including all secondary colours.

X11Palette

#
public static NamedPalette X11Palette { get; }
Create a palette containing the standard web palette.
Colour palette based on the X11 palette.

Methods

Add

#
public NamedPalette Add(NamedColour colour)
Add a colour to this palette.
colour (NamedColour)Colour to add.
Modified palette.

AddToRhinoDocument

#
public void AddToRhinoDocument(RhinoDoc doc)
Insert this palette into a Rhino document as a set of dots.
doc (RhinoDoc)Document.
Array of guids of added objects.

CanReplace

#
public bool CanReplace(string oldName, string newName)
Resolve whether a specific name can be replaced with another without name collisions. If the oldName hasn't been defined yet, replacement is considered to be possible.
oldName (string)Name to replace.
newName (string)New name.
True if replacement is possible.

Compose

#
public LinguisticResolution Compose(string description, out Color result)
Compose a colour based on some textual description.
description (string)Description of a colour.
result (out Color)Resulting colour.
Level of confidence in the result.

ContainsName

#
public bool ContainsName(string name)
Gets whether a specific name has already been defined.
name (string)

Describe

#
public string Describe(Color colour, out string deviation)
Describe a colour as the most similar named colour.
colour (Color)Colour to describe.
deviation (out string)Description of deviation.
Colour name.

Describe

#
public string Describe(Color colour)
Describe a colour as the most similar named colour.
colour (Color)Colour to describe.
Name of most similar colour, with a tilde prefix if the named colour differs significantly.

FilterImportance

#
public NamedPalette FilterImportance(ColourImportance importance)
Create a new palette containing only the colours that match the given importance.
importance (ColourImportance)

Find

#
public NamedColour Find(Color colour, out double deviation)
Find the colour closest to the given one.
colour (Color)Colour locus.
deviation (out double)Deviation between source and target colour measured in the CIE delta-E metric.
Colour closest to the given one.

Find

#
public NamedColour Find(Color colour)
Find the colour closest to the given one.
colour (Color)Colour locus.
Colour closest to the given one.

Find

#
public NamedColour Find(string name)
Find the colour associated with the specified name.
name (string)Name of colour to search for.
Colour associated with name or null.

FindFuzzy

#
public NamedColour FindFuzzy(string text, out int distance)
Find the best match name.
text (string)Search text.
distance (out int)Damerau-Levenshtein distance of match.
Nearest colour.

FindIdentical

#
public NamedColour[] FindIdentical(Color colour)
Find all identical colours.
colour (Color)Base colour.
All identical colours, sorted from most similar to least similar.

FindSimilar

#
public NamedColour[] FindSimilar(Color colour, double maxDeviation, int maxCount)
Find all similar colours (but not any identical colours).
colour (Color)Base colour.
maxDeviation (double)Threshold for similarity. This distance is measured within a vertically aligned sinusoidal volume with black at (0,0-1) and white at (0,0,+1). Hue is mapped around the central axis and saturation and luminance together control the offset from the central axis, which is at most 0.5 around the equator. The largest possible distance between any two colours is 2.0, between black and white.
maxCount (int)Maximum number of results to return.
All similar colours, sorted from most similar to least similar.

ImpliedPalette

#
public static NamedPalette ImpliedPalette(string name)
Gets the palette implied by the name. If no matching palette can be found, null will be returned.
name (string)Name to search for.

Merge

#
public static NamedPalette Merge(MergeDelegate mergeFunction, params NamedPalette[] palettes)
Merge a collection of palettes.
mergeFunction (NamedPalette.MergeDelegate)Merge function used in case of name collisions.
palettes (params NamedPalette[])Dictionaries to merge.
Merged palette.

Merge

#
public static NamedPalette Merge(PaletteMergeBehaviour behaviour, params NamedPalette[] palettes)
Merge a collection of palettes.
behaviour (PaletteMergeBehaviour)One of the preset merge behaviours.
palettes (params NamedPalette[])Dictionaries to merge. Colliding names are omitted from later palettes.
Merged palette.

ReadFromFile

#
public static NamedPalette ReadFromFile(string file)
Read a palette from a file.
file (string)File path.
Palette.

ReadFromStrings

#
public static NamedPalette ReadFromStrings(string[] entries)
Deserialize a colour palette from an array of strings.
entries (string[])Strings to parse.
Palette.

Remove

#
public NamedPalette Remove(string name)
Remove a colour from this palette.
name (string)Name of colour to remove.
Modified palette.

Replace

#
public NamedPalette Replace(NamedColour oldColour, NamedColour newColour)
Replace a colour in this palette.
oldColour (NamedColour)Colour to remove.
newColour (NamedColour)Colour to insert.
Modified palette.

Replace

#
public NamedPalette Replace(string oldColourName, NamedColour newColour)
Replace a colour in this palette.
oldColourName (string)Name of colour to remove.
newColour (NamedColour)Colour to insert.
Modified palette.

Store

#
public void Store(IWriter writer)
This method is called whenever the instance is required to serialize itself.
writer (IWriter)Writer object to serialize with.
Store

ToString

#
public override string ToString()
Returns a string that represents the current object.
A string that represents the current object.
Object.ToString

WriteToFile

#
public static void WriteToFile(string file, NamedPalette palette)
Write a palette to a file.
file (string)File path.
palette (NamedPalette)Palette to write.

WriteToStrings

#
public static string[] WriteToStrings(NamedPalette palette)
Serialize this palette to an array of strings.
palette (NamedPalette)
Array of strings.