NamedPalette

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

Constructors

NamedPalette

#
Create a new empty palette.
public NamedPalette()

NamedPalette

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

NamedPalette

#
Deserialization constructor.
public NamedPalette(
reader
)

Fields

OpenColorPaletteName

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

StandardCorePaletteName

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

StandardFullPaletteName

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

X11PaletteName

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

Properties

Colours

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

Count

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

EmptyPalette

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

KnownPaletteNames

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

OpenColorPalette

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

StandardCorePalette

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

StandardFullPalette

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

X11Palette

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

Methods

Add

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

AddToRhinoDocument

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

CanReplace

#
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.
public bool CanReplace(
oldName,
Name to replace.
newName
New name.
)
True if replacement is possible.

Compose

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

ContainsName

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

Describe

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

Describe

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

FilterImportance

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

Find

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

Find

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

Find

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

FindFuzzy

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

FindIdentical

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

FindSimilar

#
Find all similar colours (but not any identical colours).
public NamedColour[] FindSimilar(
Color
colour,
Base colour.
maxDeviation,
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
Maximum number of results to return.
)
All similar colours, sorted from most similar to least similar.

ImpliedPalette

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

Merge

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

Merge

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

ReadFromFile

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

ReadFromStrings

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

Remove

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

Replace

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

Replace

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

Store

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

ToString

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

WriteToFile

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

WriteToStrings

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