Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Convert hex strings into colors
ResourceFunction["HexToColor"][hex] converts a string hex into an equivalent color. | |
ResourceFunction["HexToColor"][hex,form] converts a string hex into a color specified by form. |
| "#RRGGBBAA" | eight-digit hexadecimal |
| "#RRGGBB" | six-digit hexadecimal |
| "#RGB" | three-digit hexadecimal form |
| "#RRGG" | no blue channel |
| "#RR" | only red channel |
| "RGB" | "RGBA" | RGBColor value with optional alpha |
| "Real" | List of real channel values in the interval [0,1] |
| "Integer" | List of integer channel values in the set {0,…,255} |
Convert hex strings into colors:
| In[1]:= |
| Out[1]= |
Convert hex strings with alpha:
| In[2]:= |
| Out[2]= |
Convert hex strings directly to integer lists:
| In[3]:= |
| Out[3]= |
Create a basic RGB color table:
| In[4]:= | ![]() |
| Out[4]= | ![]() |
HexToColor is effectively the inverse of the resource function ColorToHex:
| In[5]:= | ![]() |
| Out[5]= |
The system symbol RGBColor works for some cases out of the box:
| In[6]:= |
| In[7]:= |
| Out[7]= |
However, HexToColor offers many additional conveniences, as well as support for alpha:
| In[8]:= |
| Out[8]= |
This work is licensed under a Creative Commons Attribution 4.0 International License