rhyton.color¶
Module for color operations.
- class Color[source]¶
Bases:
objectClass for basic color operations.
- static HEXtoRGB(hexColor)[source]¶
Converts a hex color string to rgb.
- Parameters
hexColor (sting) – The hex color
- Returns
The rgb color
- Return type
tuple
- class ColorRange(count, min=0, max=100)[source]¶
Bases:
objectClass for working with color ranges.
- class ColorScheme[source]¶
Bases:
objectClass for handling relationships between labels and colors.
- static apply(guids, schemeName)[source]¶
Applies a rhyton color scheme to given objects. Updates the color scheme with new keys and colors.
- Parameters
guids (str) – A list of Rhino objects ids
schemeName (string) – The name of the color scheme
- Returns
Same return as
rhyton.document.ElementUserText.getValues()but with key “color” added.- Return type
dict
- static applyGradient(guids, schemeName, gradient)[source]¶
Applies a rhyton color gradient to given objects.
- Parameters
guids (str) – A list of guids.
schemeName (str) – The name of the color scheme.
gradient (list) – Two RGB colors: [start, end]
- delete(schemeName)[source]¶
Deletes a color scheme from the rhyton DocumenConfigStorage.
- Parameters
scheme (dict) – A color scheme
- static fromJSON(path)[source]¶
Reads a color scheme from json.
- Parameters
path (string) – The json file
- Returns
The color scheme
- Return type
dict
- generate(keys, excludeColors=None, gradient=False)[source]¶
Generates a new color scheme.
A color scheme has the following layout:
{ <schemeName>: {"key1": <hexcolor>} }
- Parameters
schemeName (string) – The name of the color scheme
keys (string) – A set of keys
excludeColors (string, optional) – A list of colors to exclude
gradient (int, optional) – A tuple with start and end color
- Returns
A color scheme
- Return type
dict
- getColors(count, excludeColors=[])[source]¶
Gets a given amount of colors.
- Parameters
count (int) – The number of colors to get
excludeColors (string, optional) – List of colors to exclude. Defaults to None.
- Returns
A list of colors
- Return type
string
- save(schemeName, keyValues)[source]¶
Saves a single color scheme to the rhyton DocumentConfigStorage.
Color schemes are stored as follows:
{ <extensionName>.colorSchemes: { <schemeName1>: {"key1": "value1"}, <schemeName2>: {"key1": "value1"} } }
- Parameters
schemeName (str) – The name of the color scheme
keyValues (dict) – The keys and colors associated with the name