Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Find the color name closest to a given color
ResourceFunction["NearestColorName"][color] returns the name of color based on the similarity to the built-in Wolfram Language color symbols. |
Find the nearest built-in color for an RGB color:
In[1]:= |
Out[1]= |
Get the nearest color name for several colors:
In[2]:= |
Out[2]= |
Use random colors:
In[3]:= |
Out[3]= |
By default, the "ColorMap" option contains the rules for all the named colors of the Wolfram Language:
In[4]:= |
Out[4]= |
Use the "ColorMap" option to get the nearest color names only for the primary colors:
In[5]:= |
Out[5]= |
In[6]:= |
Out[6]= |
It also is possible to expand the list of color rules, increasing the accuracy of the function. Define many gray values:
In[7]:= |
Out[7]= |
Expand the color rules to add every gray color:
In[8]:= |
Using the default rules, random gray colors give several different results:
In[9]:= |
In[10]:= |
Out[10]= |
Including the expanded rules gives more uniform results:
In[11]:= |
Out[11]= |
Get the nearest color name in Portuguese for red, green and blue colors:
In[12]:= |
Out[12]= |
Get the nearest color name in Spanish for some random colors:
In[13]:= |
Out[13]= |
Some colors do not have translations in all languages. The following code returns the available translations for a color:
In[14]:= |
Out[13]= |
Create a table of results:
In[15]:= |
Out[6]= |
This work is licensed under a Creative Commons Attribution 4.0 International License