Component to display Colour

Hi,
I need a component that gets input such like “255,0,0” or “White” and can transform it to color display in the GH environment.

Thanks,
Clemens

Display | Color | HSL’ or RGB or fRGB or CMYK or HSV or… etc.

No I dont want to split the colors. I´d like to have a visualisation directly on the GH canvas. Like this:

Thank you! I used legend to visualize it! it worked for me.

They don’t split colors, they generate colors for use with Custom Preview.

How about posting your solution?

This may be overkill but I found a list of “web safe” colors here:

Then parsed the JSON format in Python. As noted on the page, there are duplicate color names in this list so I used only the first 16 colors and ignored the rest. There must be CSV or JSON formats with unique color names but I was too impatient to search further.


colors_2021Jan16a.gh (20.2 KB)
colors.json.txt (30.0 KB)

The Python could be ignored by internalizing the Color Name/Values data param.

The teal group uses a PVL component posted recently by @AndersDeleuran to initialize two Value List components:

  • ‘Colors’ in purple group has both names and color values.
  • ‘Color Names’ in white group has only names and does a lookup of the color value associated with the color name passed to the ‘M’ input of MIndex (Member Index).

Here is the Python code:

import json

json_colors = json.loads(JSON)

colors_A = []
for aColor in json_colors:
    rgb_A = []
    for rgb in aColor['rgb']:
        rgb_A.append(str(aColor['rgb'][rgb]))
    colors_A.append(aColor["name"]+'|'+','.join(rgb_A))

colors = colors_A

Created a CNLU (Color Name Lookup) cluster that returns RGB color value for color name.

colors_2021Jan16b
colors_2021Jan16b2
colors_2021Jan16b.gh (9.5 KB)

Legend component
image