Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thorwhalen/127092ff13fbe67c9b88757b23654ed7 to your computer and use it in GitHub Desktop.
Save thorwhalen/127092ff13fbe67c9b88757b23654ed7 to your computer and use it in GitHub Desktop.
Scraping and preparing color name and RGB code (hex and dec) mapping.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"toc": true
},
"source": [
"<h1>Table of Contents<span class=\"tocSkip\"></span></h1>\n",
"<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#Get-color-tables\" data-toc-modified-id=\"Get-color-tables-1\"><span class=\"toc-item-num\">1&nbsp;&nbsp;</span>Get color tables</a></span></li><li><span><a href=\"#Some-processing-of-these-tables\" data-toc-modified-id=\"Some-processing-of-these-tables-2\"><span class=\"toc-item-num\">2&nbsp;&nbsp;</span>Some processing of these tables</a></span><ul class=\"toc-item\"><li><span><a href=\"#Just-keep-what-we-need-(and-replace-by-easier-names)\" data-toc-modified-id=\"Just-keep-what-we-need-(and-replace-by-easier-names)-2.1\"><span class=\"toc-item-num\">2.1&nbsp;&nbsp;</span>Just keep what we need (and replace by easier names)</a></span></li><li><span><a href=\"#Make-decimal-codes-be-numerical\" data-toc-modified-id=\"Make-decimal-codes-be-numerical-2.2\"><span class=\"toc-item-num\">2.2&nbsp;&nbsp;</span>Make decimal codes be numerical</a></span></li><li><span><a href=\"#Handle-those-multiple-name-colors\" data-toc-modified-id=\"Handle-those-multiple-name-colors-2.3\"><span class=\"toc-item-num\">2.3&nbsp;&nbsp;</span>Handle those multiple name colors</a></span></li></ul></li><li><span><a href=\"#So-my-color-table-is...\" data-toc-modified-id=\"So-my-color-table-is...-3\"><span class=\"toc-item-num\">3&nbsp;&nbsp;</span>So my color table is...</a></span><ul class=\"toc-item\"><li><span><a href=\"#Replace-spaces-by-underscores\" data-toc-modified-id=\"Replace-spaces-by-underscores-3.1\"><span class=\"toc-item-num\">3.1&nbsp;&nbsp;</span>Replace spaces by underscores</a></span></li><li><span><a href=\"#Save-to-json\" data-toc-modified-id=\"Save-to-json-3.2\"><span class=\"toc-item-num\">3.2&nbsp;&nbsp;</span>Save to json</a></span></li></ul></li></ul></div>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T19:53:33.382635Z",
"start_time": "2020-08-11T19:53:33.366200Z"
}
},
"outputs": [],
"source": [
"import pandas as pd\n",
"from collections import Counter\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Get color tables"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T19:35:22.135107Z",
"start_time": "2020-08-11T19:35:21.251141Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"5"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from requests import request\n",
"import pandas as pd\n",
"\n",
"tables = pd.read_html(request('get', 'https://www.rapidtables.com/web/color/RGB_Color.html').content)\n",
"len(tables)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T19:37:07.276632Z",
"start_time": "2020-08-11T19:37:07.251653Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Color</th>\n",
" <th>Color Name</th>\n",
" <th>Hex Code#RRGGBB</th>\n",
" <th>Decimal CodeR,G,B</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>NaN</td>\n",
" <td>maroon</td>\n",
" <td>#800000</td>\n",
" <td>(128,0,0)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>NaN</td>\n",
" <td>dark red</td>\n",
" <td>#8B0000</td>\n",
" <td>(139,0,0)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>NaN</td>\n",
" <td>brown</td>\n",
" <td>#A52A2A</td>\n",
" <td>(165,42,42)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>NaN</td>\n",
" <td>firebrick</td>\n",
" <td>#B22222</td>\n",
" <td>(178,34,34)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>NaN</td>\n",
" <td>crimson</td>\n",
" <td>#DC143C</td>\n",
" <td>(220,20,60)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>134</th>\n",
" <td>NaN</td>\n",
" <td>silver</td>\n",
" <td>#C0C0C0</td>\n",
" <td>(192,192,192)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>135</th>\n",
" <td>NaN</td>\n",
" <td>light gray / light grey</td>\n",
" <td>#D3D3D3</td>\n",
" <td>(211,211,211)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>136</th>\n",
" <td>NaN</td>\n",
" <td>gainsboro</td>\n",
" <td>#DCDCDC</td>\n",
" <td>(220,220,220)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>137</th>\n",
" <td>NaN</td>\n",
" <td>white smoke</td>\n",
" <td>#F5F5F5</td>\n",
" <td>(245,245,245)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>138</th>\n",
" <td>NaN</td>\n",
" <td>white</td>\n",
" <td>#FFFFFF</td>\n",
" <td>(255,255,255)</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>139 rows × 4 columns</p>\n",
"</div>"
],
"text/plain": [
" Color Color Name Hex Code#RRGGBB Decimal CodeR,G,B\n",
"0 NaN maroon #800000 (128,0,0)\n",
"1 NaN dark red #8B0000 (139,0,0)\n",
"2 NaN brown #A52A2A (165,42,42)\n",
"3 NaN firebrick #B22222 (178,34,34)\n",
"4 NaN crimson #DC143C (220,20,60)\n",
".. ... ... ... ...\n",
"134 NaN silver #C0C0C0 (192,192,192)\n",
"135 NaN light gray / light grey #D3D3D3 (211,211,211)\n",
"136 NaN gainsboro #DCDCDC (220,220,220)\n",
"137 NaN white smoke #F5F5F5 (245,245,245)\n",
"138 NaN white #FFFFFF (255,255,255)\n",
"\n",
"[139 rows x 4 columns]"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = tables[4]\n",
"df"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Some processing of these tables"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Just keep what we need (and replace by easier names)"
]
},
{
"cell_type": "markdown",
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T19:37:13.718296Z",
"start_time": "2020-08-11T19:37:13.699394Z"
}
},
"source": [
"The `Color` column displayed some actual color in the web page, but we don't need that here (well, we don't even have it, so...). So we'll just keep the other columns, and also rename them"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We're just going to keep color name and hex code. We can get the decimal code from it."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T19:41:22.150767Z",
"start_time": "2020-08-11T19:41:22.134366Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"'Color' in df"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T19:41:54.739368Z",
"start_time": "2020-08-11T19:41:54.714329Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>color</th>\n",
" <th>hex</th>\n",
" <th>dec</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>maroon</td>\n",
" <td>#800000</td>\n",
" <td>(128,0,0)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>dark red</td>\n",
" <td>#8B0000</td>\n",
" <td>(139,0,0)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>brown</td>\n",
" <td>#A52A2A</td>\n",
" <td>(165,42,42)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>firebrick</td>\n",
" <td>#B22222</td>\n",
" <td>(178,34,34)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>crimson</td>\n",
" <td>#DC143C</td>\n",
" <td>(220,20,60)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>134</th>\n",
" <td>silver</td>\n",
" <td>#C0C0C0</td>\n",
" <td>(192,192,192)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>135</th>\n",
" <td>light gray / light grey</td>\n",
" <td>#D3D3D3</td>\n",
" <td>(211,211,211)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>136</th>\n",
" <td>gainsboro</td>\n",
" <td>#DCDCDC</td>\n",
" <td>(220,220,220)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>137</th>\n",
" <td>white smoke</td>\n",
" <td>#F5F5F5</td>\n",
" <td>(245,245,245)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>138</th>\n",
" <td>white</td>\n",
" <td>#FFFFFF</td>\n",
" <td>(255,255,255)</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>139 rows × 3 columns</p>\n",
"</div>"
],
"text/plain": [
" color hex dec\n",
"0 maroon #800000 (128,0,0)\n",
"1 dark red #8B0000 (139,0,0)\n",
"2 brown #A52A2A (165,42,42)\n",
"3 firebrick #B22222 (178,34,34)\n",
"4 crimson #DC143C (220,20,60)\n",
".. ... ... ...\n",
"134 silver #C0C0C0 (192,192,192)\n",
"135 light gray / light grey #D3D3D3 (211,211,211)\n",
"136 gainsboro #DCDCDC (220,220,220)\n",
"137 white smoke #F5F5F5 (245,245,245)\n",
"138 white #FFFFFF (255,255,255)\n",
"\n",
"[139 rows x 3 columns]"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"if 'Color' in df:\n",
" del df['Color']\n",
"df = df.rename(columns={\n",
" 'Color Name': 'color', \n",
" 'Hex Code#RRGGBB': 'hex', \n",
" 'Decimal CodeR,G,B': 'dec'})\n",
"df"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Make decimal codes be numerical"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's see if the dec values are actually tuples of numbers..."
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T19:45:04.534659Z",
"start_time": "2020-08-11T19:45:04.517371Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"'(240,128,128)'"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.dec.iloc[9]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"That's what I thought... So let's make these actual numerical triples."
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T19:45:31.611451Z",
"start_time": "2020-08-11T19:45:31.593509Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"(240, 128, 128)"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import re\n",
"p = re.compile('\\((\\d+),(\\d+),(\\d+)\\)')\n",
"tuple(int(x) for x in p.match('(240,128,128)').groups())"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T19:46:51.866855Z",
"start_time": "2020-08-11T19:46:51.842305Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>color</th>\n",
" <th>hex</th>\n",
" <th>dec</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>maroon</td>\n",
" <td>#800000</td>\n",
" <td>(128, 0, 0)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>dark red</td>\n",
" <td>#8B0000</td>\n",
" <td>(139, 0, 0)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>brown</td>\n",
" <td>#A52A2A</td>\n",
" <td>(165, 42, 42)</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" color hex dec\n",
"0 maroon #800000 (128, 0, 0)\n",
"1 dark red #8B0000 (139, 0, 0)\n",
"2 brown #A52A2A (165, 42, 42)"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"if isinstance(df.dec.iloc[0], str):\n",
" df.dec = df.dec.apply(lambda v: tuple(int(x) for x in p.match(v).groups()))\n",
"df.head(3)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T19:47:10.930297Z",
"start_time": "2020-08-11T19:47:10.913284Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"(128, 0, 0)"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.dec.iloc[0] # see that we're good now"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Handle those multiple name colors"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Some of the color names have a slash in them."
]
},
{
"cell_type": "code",
"execution_count": 91,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T18:40:38.689101Z",
"start_time": "2020-08-11T18:40:38.671329Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"['magenta / fuchsia',\n",
" 'dim gray / dim grey',\n",
" 'gray / grey',\n",
" 'dark gray / dark grey',\n",
" 'light gray / light grey']"
]
},
"execution_count": 91,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"[x for x in df.color if '/' in x]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It obviously is there to mark alternative names. We'll choose to keep them all, which means that for every `us_name / brit_name` row we'll produce two rows: One with the `us_name` and one with the `brit_name`..."
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T19:50:14.325089Z",
"start_time": "2020-08-11T19:50:14.269125Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>color</th>\n",
" <th>hex</th>\n",
" <th>dec</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>maroon</td>\n",
" <td>#800000</td>\n",
" <td>(128, 0, 0)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>dark red</td>\n",
" <td>#8B0000</td>\n",
" <td>(139, 0, 0)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>brown</td>\n",
" <td>#A52A2A</td>\n",
" <td>(165, 42, 42)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>firebrick</td>\n",
" <td>#B22222</td>\n",
" <td>(178, 34, 34)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>crimson</td>\n",
" <td>#DC143C</td>\n",
" <td>(220, 20, 60)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>139</th>\n",
" <td>light gray</td>\n",
" <td>#D3D3D3</td>\n",
" <td>(211, 211, 211)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>140</th>\n",
" <td>light grey</td>\n",
" <td>#D3D3D3</td>\n",
" <td>(211, 211, 211)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>141</th>\n",
" <td>gainsboro</td>\n",
" <td>#DCDCDC</td>\n",
" <td>(220, 220, 220)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>142</th>\n",
" <td>white smoke</td>\n",
" <td>#F5F5F5</td>\n",
" <td>(245, 245, 245)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>143</th>\n",
" <td>white</td>\n",
" <td>#FFFFFF</td>\n",
" <td>(255, 255, 255)</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>144 rows × 3 columns</p>\n",
"</div>"
],
"text/plain": [
" color hex dec\n",
"0 maroon #800000 (128, 0, 0)\n",
"1 dark red #8B0000 (139, 0, 0)\n",
"2 brown #A52A2A (165, 42, 42)\n",
"3 firebrick #B22222 (178, 34, 34)\n",
"4 crimson #DC143C (220, 20, 60)\n",
".. ... ... ...\n",
"139 light gray #D3D3D3 (211, 211, 211)\n",
"140 light grey #D3D3D3 (211, 211, 211)\n",
"141 gainsboro #DCDCDC (220, 220, 220)\n",
"142 white smoke #F5F5F5 (245, 245, 245)\n",
"143 white #FFFFFF (255, 255, 255)\n",
"\n",
"[144 rows x 3 columns]"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from i2.deco import postprocess\n",
"\n",
"@postprocess(pd.DataFrame.from_dict)\n",
"def with_multiple_spellings(df):\n",
" for _, r in df.iterrows():\n",
" if '/' in r.color:\n",
" for color in r.color.split('/'):\n",
" rr = r.copy()\n",
" rr.color = color.strip()\n",
" yield rr.to_dict()\n",
" else:\n",
" yield r.to_dict()\n",
" \n",
"df = with_multiple_spellings(df)\n",
"df\n"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T19:56:33.311764Z",
"start_time": "2020-08-11T19:56:33.291657Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"{'b': 'blue',\n",
" 'g': 'green',\n",
" 'r': 'red',\n",
" 'c': 'cyan',\n",
" 'm': 'magenta',\n",
" 'y': 'yellow',\n",
" 'k': 'black',\n",
" 'w': 'white'}"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Found a list of matplotlib single letter color refs here: \n",
"# https://matplotlib.org/3.3.0/tutorials/colors/colors.html\n",
"\n",
"matplotlib_shorthands = dict(zip(\n",
" ['b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'],\n",
" ['blue', 'green', 'red', 'cyan', 'magenta', 'yellow', 'black', 'white']))\n",
"matplotlib_shorthands"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Make sure we have all those names in `df`"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T19:57:05.914675Z",
"start_time": "2020-08-11T19:57:05.897460Z"
}
},
"outputs": [],
"source": [
"assert all(x in set(df.color) for x in matplotlib_shorthands.values())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let's see what letters of the `df.color` (first letter) are not covered."
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T20:10:44.623071Z",
"start_time": "2020-08-11T20:10:44.606282Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"{'a', 'd', 'f', 'h', 'i', 'l', 'n', 'o', 'p', 's', 't', 'v'}"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"letters_not_covered_by_matplotlib = Counter(x[0] for x in df.color).keys() - matplotlib_shorthands.keys()\n",
"letters_not_covered_by_matplotlib"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Make a list of \"base colors\" (i.e. not just a \"dark\" or \"light\" version of another color)"
]
},
{
"cell_type": "code",
"execution_count": 56,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T20:18:57.961058Z",
"start_time": "2020-08-11T20:18:57.941698Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"103"
]
},
"execution_count": 56,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"forbidden_prefixes = ['dark', 'light', 'medium']\n",
"base_colors = [x for x in df.color if not any(x.startswith(w) for w in forbidden_prefixes)]\n",
"len(base_colors)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"And now let's make a list of colors for each not covered letter."
]
},
{
"cell_type": "code",
"execution_count": 62,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T20:25:31.911785Z",
"start_time": "2020-08-11T20:25:31.892166Z"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* f\n",
"\t'firebrick', 'forest green', 'fuchsia', 'floral white'\n",
"* t\n",
"\t'tomato', 'teal', 'turquoise', 'thistle', 'tan'\n",
"* i\n",
"\t'indian red', 'indigo', 'ivory'\n",
"* s\n",
"\t'salmon', 'spring green', 'sea green', 'steel blue', 'sky blue', 'slate blue', 'saddle brown', 'sienna', 'sandy brown', 'sea shell', 'slate gray', 'snow', 'silver'\n",
"* o\n",
"\t'orange red', 'orange', 'olive', 'olive drab', 'orchid', 'old lace'\n",
"* p\n",
"\t'pale golden rod', 'pale green', 'pale turquoise', 'powder blue', 'purple', 'plum', 'pale violet red', 'pink', 'peru', 'peach puff', 'papaya whip'\n",
"* l\n",
"\t'lawn green', 'lime', 'lime green', 'lemon chiffon', 'lavender blush', 'linen', 'lavender'\n",
"* a\n",
"\t'aqua', 'aqua marine', 'antique white', 'alice blue', 'azure'\n",
"* d\n",
"\t'deep sky blue', 'dodger blue', 'deep pink', 'dim gray', 'dim grey'\n",
"* n\n",
"\t'navy', 'navajo white'\n",
"* v\n",
"\t'violet'\n",
"* h\n",
"\t'hot pink', 'honeydew'\n"
]
}
],
"source": [
"from i2.genu import groupby\n",
"g = groupby(base_colors, lambda x: x[0])\n",
"for letter, color_names in g.items():\n",
" if letter in letters_not_covered_by_matplotlib:\n",
" print('* ' + letter + '\\n\\t' + ', '.join(f\"'{c}'\" for c in color_names))"
]
},
{
"cell_type": "code",
"execution_count": 64,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T20:26:54.413619Z",
"start_time": "2020-08-11T20:26:54.394768Z"
}
},
"outputs": [],
"source": [
"# We'll extend it with our \n",
"extended_matplotlib_shorthands = {\n",
" # matlab shorthands\n",
" 'b': 'blue', \n",
" 'g': 'green',\n",
" 'r': 'red',\n",
" 'c': 'cyan',\n",
" 'm': 'magenta',\n",
" 'y': 'yellow',\n",
" 'k': 'black',\n",
" 'w': 'white', \n",
" # and more...\n",
" 'f': 'firebrick',\n",
" 't': 'teal',\n",
" 'i': 'indigo',\n",
" 's': 'salmon',\n",
" 'o': 'orange',\n",
" 'p': 'purple',\n",
" 'l': 'lime',\n",
" 'a': 'aqua',\n",
" 'd': 'deep pink',\n",
" 'n': 'navy',\n",
" 'v': 'violet',\n",
" 'h': 'honeydew'\n",
"}\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# So my color table is..."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Extend the existing table with the `extended_matplotlib_shorthands`, jsonize this, and be done."
]
},
{
"cell_type": "code",
"execution_count": 71,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T20:32:49.024193Z",
"start_time": "2020-08-11T20:32:48.977612Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>color</th>\n",
" <th>hex</th>\n",
" <th>dec</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>b</td>\n",
" <td>#0000FF</td>\n",
" <td>(0, 0, 255)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>g</td>\n",
" <td>#008000</td>\n",
" <td>(0, 128, 0)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>r</td>\n",
" <td>#FF0000</td>\n",
" <td>(255, 0, 0)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>c</td>\n",
" <td>#00FFFF</td>\n",
" <td>(0, 255, 255)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>m</td>\n",
" <td>#FF00FF</td>\n",
" <td>(255, 0, 255)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>y</td>\n",
" <td>#FFFF00</td>\n",
" <td>(255, 255, 0)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>k</td>\n",
" <td>#000000</td>\n",
" <td>(0, 0, 0)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>w</td>\n",
" <td>#FFFFFF</td>\n",
" <td>(255, 255, 255)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>f</td>\n",
" <td>#B22222</td>\n",
" <td>(178, 34, 34)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>t</td>\n",
" <td>#008080</td>\n",
" <td>(0, 128, 128)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>i</td>\n",
" <td>#4B0082</td>\n",
" <td>(75, 0, 130)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>s</td>\n",
" <td>#FA8072</td>\n",
" <td>(250, 128, 114)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>o</td>\n",
" <td>#FFA500</td>\n",
" <td>(255, 165, 0)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>p</td>\n",
" <td>#800080</td>\n",
" <td>(128, 0, 128)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>l</td>\n",
" <td>#00FF00</td>\n",
" <td>(0, 255, 0)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>a</td>\n",
" <td>#00FFFF</td>\n",
" <td>(0, 255, 255)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>d</td>\n",
" <td>#FF1493</td>\n",
" <td>(255, 20, 147)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>n</td>\n",
" <td>#000080</td>\n",
" <td>(0, 0, 128)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>v</td>\n",
" <td>#EE82EE</td>\n",
" <td>(238, 130, 238)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>h</td>\n",
" <td>#F0FFF0</td>\n",
" <td>(240, 255, 240)</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" color hex dec\n",
"0 b #0000FF (0, 0, 255)\n",
"1 g #008000 (0, 128, 0)\n",
"2 r #FF0000 (255, 0, 0)\n",
"3 c #00FFFF (0, 255, 255)\n",
"4 m #FF00FF (255, 0, 255)\n",
"5 y #FFFF00 (255, 255, 0)\n",
"6 k #000000 (0, 0, 0)\n",
"7 w #FFFFFF (255, 255, 255)\n",
"8 f #B22222 (178, 34, 34)\n",
"9 t #008080 (0, 128, 128)\n",
"10 i #4B0082 (75, 0, 130)\n",
"11 s #FA8072 (250, 128, 114)\n",
"12 o #FFA500 (255, 165, 0)\n",
"13 p #800080 (128, 0, 128)\n",
"14 l #00FF00 (0, 255, 0)\n",
"15 a #00FFFF (0, 255, 255)\n",
"16 d #FF1493 (255, 20, 147)\n",
"17 n #000080 (0, 0, 128)\n",
"18 v #EE82EE (238, 130, 238)\n",
"19 h #F0FFF0 (240, 255, 240)"
]
},
"execution_count": 71,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from i2.deco import postprocess\n",
"\n",
"@postprocess(pd.DataFrame.from_dict)\n",
"def mk_extended_matplotlib_shorthands_df(extended_matplotlib_shorthands):\n",
" for letter, color_name in extended_matplotlib_shorthands.items():\n",
" match = df[df.color == color_name]\n",
" assert len(match) == 1, f\"Oops, you were supposed to have one and one only match for {color_name}\"\n",
" r = match.iloc[0]\n",
" rr = r.copy()\n",
" rr.color = letter\n",
" yield rr.to_dict()\n",
" \n",
"extra_df = mk_extended_matplotlib_shorthands_df(extended_matplotlib_shorthands)\n",
"extra_df"
]
},
{
"cell_type": "code",
"execution_count": 126,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T21:26:07.645358Z",
"start_time": "2020-08-11T21:26:07.616551Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>color</th>\n",
" <th>hex</th>\n",
" <th>dec</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>b</td>\n",
" <td>#0000FF</td>\n",
" <td>(0, 0, 255)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>g</td>\n",
" <td>#008000</td>\n",
" <td>(0, 128, 0)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>r</td>\n",
" <td>#FF0000</td>\n",
" <td>(255, 0, 0)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>c</td>\n",
" <td>#00FFFF</td>\n",
" <td>(0, 255, 255)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>m</td>\n",
" <td>#FF00FF</td>\n",
" <td>(255, 0, 255)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>159</th>\n",
" <td>light gray</td>\n",
" <td>#D3D3D3</td>\n",
" <td>(211, 211, 211)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>160</th>\n",
" <td>light grey</td>\n",
" <td>#D3D3D3</td>\n",
" <td>(211, 211, 211)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>161</th>\n",
" <td>gainsboro</td>\n",
" <td>#DCDCDC</td>\n",
" <td>(220, 220, 220)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>162</th>\n",
" <td>white smoke</td>\n",
" <td>#F5F5F5</td>\n",
" <td>(245, 245, 245)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>163</th>\n",
" <td>white</td>\n",
" <td>#FFFFFF</td>\n",
" <td>(255, 255, 255)</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>164 rows × 3 columns</p>\n",
"</div>"
],
"text/plain": [
" color hex dec\n",
"0 b #0000FF (0, 0, 255)\n",
"1 g #008000 (0, 128, 0)\n",
"2 r #FF0000 (255, 0, 0)\n",
"3 c #00FFFF (0, 255, 255)\n",
"4 m #FF00FF (255, 0, 255)\n",
".. ... ... ...\n",
"159 light gray #D3D3D3 (211, 211, 211)\n",
"160 light grey #D3D3D3 (211, 211, 211)\n",
"161 gainsboro #DCDCDC (220, 220, 220)\n",
"162 white smoke #F5F5F5 (245, 245, 245)\n",
"163 white #FFFFFF (255, 255, 255)\n",
"\n",
"[164 rows x 3 columns]"
]
},
"execution_count": 126,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"final_df = pd.concat([extra_df, df]).reset_index(drop=True)\n",
"final_df"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Replace spaces by underscores"
]
},
{
"cell_type": "code",
"execution_count": 145,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T22:47:30.768934Z",
"start_time": "2020-08-11T22:47:30.740351Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>color</th>\n",
" <th>hex</th>\n",
" <th>dec</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>b</td>\n",
" <td>#0000FF</td>\n",
" <td>(0, 0, 255)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>g</td>\n",
" <td>#008000</td>\n",
" <td>(0, 128, 0)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>r</td>\n",
" <td>#FF0000</td>\n",
" <td>(255, 0, 0)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>c</td>\n",
" <td>#00FFFF</td>\n",
" <td>(0, 255, 255)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>m</td>\n",
" <td>#FF00FF</td>\n",
" <td>(255, 0, 255)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>159</th>\n",
" <td>light_gray</td>\n",
" <td>#D3D3D3</td>\n",
" <td>(211, 211, 211)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>160</th>\n",
" <td>light_grey</td>\n",
" <td>#D3D3D3</td>\n",
" <td>(211, 211, 211)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>161</th>\n",
" <td>gainsboro</td>\n",
" <td>#DCDCDC</td>\n",
" <td>(220, 220, 220)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>162</th>\n",
" <td>white_smoke</td>\n",
" <td>#F5F5F5</td>\n",
" <td>(245, 245, 245)</td>\n",
" </tr>\n",
" <tr>\n",
" <th>163</th>\n",
" <td>white</td>\n",
" <td>#FFFFFF</td>\n",
" <td>(255, 255, 255)</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>164 rows × 3 columns</p>\n",
"</div>"
],
"text/plain": [
" color hex dec\n",
"0 b #0000FF (0, 0, 255)\n",
"1 g #008000 (0, 128, 0)\n",
"2 r #FF0000 (255, 0, 0)\n",
"3 c #00FFFF (0, 255, 255)\n",
"4 m #FF00FF (255, 0, 255)\n",
".. ... ... ...\n",
"159 light_gray #D3D3D3 (211, 211, 211)\n",
"160 light_grey #D3D3D3 (211, 211, 211)\n",
"161 gainsboro #DCDCDC (220, 220, 220)\n",
"162 white_smoke #F5F5F5 (245, 245, 245)\n",
"163 white #FFFFFF (255, 255, 255)\n",
"\n",
"[164 rows x 3 columns]"
]
},
"execution_count": 145,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"final_df.color = final_df.color.apply(lambda c: c.replace(' ', '_'))\n",
"final_df"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Save to json"
]
},
{
"cell_type": "code",
"execution_count": 146,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T22:47:36.280775Z",
"start_time": "2020-08-11T22:47:36.258829Z"
}
},
"outputs": [],
"source": [
"json.dump(final_df.to_dict(orient='records'), open('color_names_and_codes.json', 'w'))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 123,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T21:19:31.306156Z",
"start_time": "2020-08-11T21:19:31.287685Z"
}
},
"outputs": [],
"source": [
"pts = rgb[:, :2]\n",
"# pts = rgb\n",
"pts = pts.tolist()\n",
"\n",
"pts = [{'fv': x, 'tag': str(i)} for i, x in enumerate(pts)]"
]
},
{
"cell_type": "code",
"execution_count": 124,
"metadata": {
"ExecuteTime": {
"end_time": "2020-08-11T21:19:31.883603Z",
"start_time": "2020-08-11T21:19:31.865257Z"
}
},
"outputs": [
{
"data": {
"text/plain": [
"['pts',\n",
" 'nodeSize',\n",
" 'height',\n",
" 'width',\n",
" 'untaggedColor',\n",
" 'maxIterations',\n",
" 'fps',\n",
" 'fillColors',\n",
" 'dim',\n",
" 'epsilon',\n",
" 'perplexity',\n",
" 'spread']"
]
},
"execution_count": 124,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from i2.signatures import Sig\n",
"[x.name for x in Sig(splatter_raw).values()]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autoclose": false,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": false,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": true,
"toc_position": {
"height": "141px",
"left": "34px",
"top": "110px",
"width": "872px"
},
"toc_section_display": true,
"toc_window_display": true
}
},
"nbformat": 4,
"nbformat_minor": 4
}
@thorwhalen
Copy link
Author

[
	{
		"color": "b",
		"hex": "#0000FF",
		"dec": [
			0,
			0,
			255
		]
	},
	{
		"color": "g",
		"hex": "#008000",
		"dec": [
			0,
			128,
			0
		]
	},
	{
		"color": "r",
		"hex": "#FF0000",
		"dec": [
			255,
			0,
			0
		]
	},
	{
		"color": "c",
		"hex": "#00FFFF",
		"dec": [
			0,
			255,
			255
		]
	},
	{
		"color": "m",
		"hex": "#FF00FF",
		"dec": [
			255,
			0,
			255
		]
	},
	{
		"color": "y",
		"hex": "#FFFF00",
		"dec": [
			255,
			255,
			0
		]
	},
	{
		"color": "k",
		"hex": "#000000",
		"dec": [
			0,
			0,
			0
		]
	},
	{
		"color": "w",
		"hex": "#FFFFFF",
		"dec": [
			255,
			255,
			255
		]
	},
	{
		"color": "f",
		"hex": "#B22222",
		"dec": [
			178,
			34,
			34
		]
	},
	{
		"color": "t",
		"hex": "#008080",
		"dec": [
			0,
			128,
			128
		]
	},
	{
		"color": "i",
		"hex": "#4B0082",
		"dec": [
			75,
			0,
			130
		]
	},
	{
		"color": "s",
		"hex": "#FA8072",
		"dec": [
			250,
			128,
			114
		]
	},
	{
		"color": "o",
		"hex": "#FFA500",
		"dec": [
			255,
			165,
			0
		]
	},
	{
		"color": "p",
		"hex": "#800080",
		"dec": [
			128,
			0,
			128
		]
	},
	{
		"color": "l",
		"hex": "#00FF00",
		"dec": [
			0,
			255,
			0
		]
	},
	{
		"color": "a",
		"hex": "#00FFFF",
		"dec": [
			0,
			255,
			255
		]
	},
	{
		"color": "d",
		"hex": "#FF1493",
		"dec": [
			255,
			20,
			147
		]
	},
	{
		"color": "n",
		"hex": "#000080",
		"dec": [
			0,
			0,
			128
		]
	},
	{
		"color": "v",
		"hex": "#EE82EE",
		"dec": [
			238,
			130,
			238
		]
	},
	{
		"color": "h",
		"hex": "#F0FFF0",
		"dec": [
			240,
			255,
			240
		]
	},
	{
		"color": "maroon",
		"hex": "#800000",
		"dec": [
			128,
			0,
			0
		]
	},
	{
		"color": "dark_red",
		"hex": "#8B0000",
		"dec": [
			139,
			0,
			0
		]
	},
	{
		"color": "brown",
		"hex": "#A52A2A",
		"dec": [
			165,
			42,
			42
		]
	},
	{
		"color": "firebrick",
		"hex": "#B22222",
		"dec": [
			178,
			34,
			34
		]
	},
	{
		"color": "crimson",
		"hex": "#DC143C",
		"dec": [
			220,
			20,
			60
		]
	},
	{
		"color": "red",
		"hex": "#FF0000",
		"dec": [
			255,
			0,
			0
		]
	},
	{
		"color": "tomato",
		"hex": "#FF6347",
		"dec": [
			255,
			99,
			71
		]
	},
	{
		"color": "coral",
		"hex": "#FF7F50",
		"dec": [
			255,
			127,
			80
		]
	},
	{
		"color": "indian_red",
		"hex": "#CD5C5C",
		"dec": [
			205,
			92,
			92
		]
	},
	{
		"color": "light_coral",
		"hex": "#F08080",
		"dec": [
			240,
			128,
			128
		]
	},
	{
		"color": "dark_salmon",
		"hex": "#E9967A",
		"dec": [
			233,
			150,
			122
		]
	},
	{
		"color": "salmon",
		"hex": "#FA8072",
		"dec": [
			250,
			128,
			114
		]
	},
	{
		"color": "light_salmon",
		"hex": "#FFA07A",
		"dec": [
			255,
			160,
			122
		]
	},
	{
		"color": "orange_red",
		"hex": "#FF4500",
		"dec": [
			255,
			69,
			0
		]
	},
	{
		"color": "dark_orange",
		"hex": "#FF8C00",
		"dec": [
			255,
			140,
			0
		]
	},
	{
		"color": "orange",
		"hex": "#FFA500",
		"dec": [
			255,
			165,
			0
		]
	},
	{
		"color": "gold",
		"hex": "#FFD700",
		"dec": [
			255,
			215,
			0
		]
	},
	{
		"color": "dark_golden_rod",
		"hex": "#B8860B",
		"dec": [
			184,
			134,
			11
		]
	},
	{
		"color": "golden_rod",
		"hex": "#DAA520",
		"dec": [
			218,
			165,
			32
		]
	},
	{
		"color": "pale_golden_rod",
		"hex": "#EEE8AA",
		"dec": [
			238,
			232,
			170
		]
	},
	{
		"color": "dark_khaki",
		"hex": "#BDB76B",
		"dec": [
			189,
			183,
			107
		]
	},
	{
		"color": "khaki",
		"hex": "#F0E68C",
		"dec": [
			240,
			230,
			140
		]
	},
	{
		"color": "olive",
		"hex": "#808000",
		"dec": [
			128,
			128,
			0
		]
	},
	{
		"color": "yellow",
		"hex": "#FFFF00",
		"dec": [
			255,
			255,
			0
		]
	},
	{
		"color": "yellow_green",
		"hex": "#9ACD32",
		"dec": [
			154,
			205,
			50
		]
	},
	{
		"color": "dark_olive_green",
		"hex": "#556B2F",
		"dec": [
			85,
			107,
			47
		]
	},
	{
		"color": "olive_drab",
		"hex": "#6B8E23",
		"dec": [
			107,
			142,
			35
		]
	},
	{
		"color": "lawn_green",
		"hex": "#7CFC00",
		"dec": [
			124,
			252,
			0
		]
	},
	{
		"color": "chart_reuse",
		"hex": "#7FFF00",
		"dec": [
			127,
			255,
			0
		]
	},
	{
		"color": "green_yellow",
		"hex": "#ADFF2F",
		"dec": [
			173,
			255,
			47
		]
	},
	{
		"color": "dark_green",
		"hex": "#006400",
		"dec": [
			0,
			100,
			0
		]
	},
	{
		"color": "green",
		"hex": "#008000",
		"dec": [
			0,
			128,
			0
		]
	},
	{
		"color": "forest_green",
		"hex": "#228B22",
		"dec": [
			34,
			139,
			34
		]
	},
	{
		"color": "lime",
		"hex": "#00FF00",
		"dec": [
			0,
			255,
			0
		]
	},
	{
		"color": "lime_green",
		"hex": "#32CD32",
		"dec": [
			50,
			205,
			50
		]
	},
	{
		"color": "light_green",
		"hex": "#90EE90",
		"dec": [
			144,
			238,
			144
		]
	},
	{
		"color": "pale_green",
		"hex": "#98FB98",
		"dec": [
			152,
			251,
			152
		]
	},
	{
		"color": "dark_sea_green",
		"hex": "#8FBC8F",
		"dec": [
			143,
			188,
			143
		]
	},
	{
		"color": "medium_spring_green",
		"hex": "#00FA9A",
		"dec": [
			0,
			250,
			154
		]
	},
	{
		"color": "spring_green",
		"hex": "#00FF7F",
		"dec": [
			0,
			255,
			127
		]
	},
	{
		"color": "sea_green",
		"hex": "#2E8B57",
		"dec": [
			46,
			139,
			87
		]
	},
	{
		"color": "medium_aqua_marine",
		"hex": "#66CDAA",
		"dec": [
			102,
			205,
			170
		]
	},
	{
		"color": "medium_sea_green",
		"hex": "#3CB371",
		"dec": [
			60,
			179,
			113
		]
	},
	{
		"color": "light_sea_green",
		"hex": "#20B2AA",
		"dec": [
			32,
			178,
			170
		]
	},
	{
		"color": "dark_slate_gray",
		"hex": "#2F4F4F",
		"dec": [
			47,
			79,
			79
		]
	},
	{
		"color": "teal",
		"hex": "#008080",
		"dec": [
			0,
			128,
			128
		]
	},
	{
		"color": "dark_cyan",
		"hex": "#008B8B",
		"dec": [
			0,
			139,
			139
		]
	},
	{
		"color": "aqua",
		"hex": "#00FFFF",
		"dec": [
			0,
			255,
			255
		]
	},
	{
		"color": "cyan",
		"hex": "#00FFFF",
		"dec": [
			0,
			255,
			255
		]
	},
	{
		"color": "light_cyan",
		"hex": "#E0FFFF",
		"dec": [
			224,
			255,
			255
		]
	},
	{
		"color": "dark_turquoise",
		"hex": "#00CED1",
		"dec": [
			0,
			206,
			209
		]
	},
	{
		"color": "turquoise",
		"hex": "#40E0D0",
		"dec": [
			64,
			224,
			208
		]
	},
	{
		"color": "medium_turquoise",
		"hex": "#48D1CC",
		"dec": [
			72,
			209,
			204
		]
	},
	{
		"color": "pale_turquoise",
		"hex": "#AFEEEE",
		"dec": [
			175,
			238,
			238
		]
	},
	{
		"color": "aqua_marine",
		"hex": "#7FFFD4",
		"dec": [
			127,
			255,
			212
		]
	},
	{
		"color": "powder_blue",
		"hex": "#B0E0E6",
		"dec": [
			176,
			224,
			230
		]
	},
	{
		"color": "cadet_blue",
		"hex": "#5F9EA0",
		"dec": [
			95,
			158,
			160
		]
	},
	{
		"color": "steel_blue",
		"hex": "#4682B4",
		"dec": [
			70,
			130,
			180
		]
	},
	{
		"color": "corn_flower_blue",
		"hex": "#6495ED",
		"dec": [
			100,
			149,
			237
		]
	},
	{
		"color": "deep_sky_blue",
		"hex": "#00BFFF",
		"dec": [
			0,
			191,
			255
		]
	},
	{
		"color": "dodger_blue",
		"hex": "#1E90FF",
		"dec": [
			30,
			144,
			255
		]
	},
	{
		"color": "light_blue",
		"hex": "#ADD8E6",
		"dec": [
			173,
			216,
			230
		]
	},
	{
		"color": "sky_blue",
		"hex": "#87CEEB",
		"dec": [
			135,
			206,
			235
		]
	},
	{
		"color": "light_sky_blue",
		"hex": "#87CEFA",
		"dec": [
			135,
			206,
			250
		]
	},
	{
		"color": "midnight_blue",
		"hex": "#191970",
		"dec": [
			25,
			25,
			112
		]
	},
	{
		"color": "navy",
		"hex": "#000080",
		"dec": [
			0,
			0,
			128
		]
	},
	{
		"color": "dark_blue",
		"hex": "#00008B",
		"dec": [
			0,
			0,
			139
		]
	},
	{
		"color": "medium_blue",
		"hex": "#0000CD",
		"dec": [
			0,
			0,
			205
		]
	},
	{
		"color": "blue",
		"hex": "#0000FF",
		"dec": [
			0,
			0,
			255
		]
	},
	{
		"color": "royal_blue",
		"hex": "#4169E1",
		"dec": [
			65,
			105,
			225
		]
	},
	{
		"color": "blue_violet",
		"hex": "#8A2BE2",
		"dec": [
			138,
			43,
			226
		]
	},
	{
		"color": "indigo",
		"hex": "#4B0082",
		"dec": [
			75,
			0,
			130
		]
	},
	{
		"color": "dark_slate_blue",
		"hex": "#483D8B",
		"dec": [
			72,
			61,
			139
		]
	},
	{
		"color": "slate_blue",
		"hex": "#6A5ACD",
		"dec": [
			106,
			90,
			205
		]
	},
	{
		"color": "medium_slate_blue",
		"hex": "#7B68EE",
		"dec": [
			123,
			104,
			238
		]
	},
	{
		"color": "medium_purple",
		"hex": "#9370DB",
		"dec": [
			147,
			112,
			219
		]
	},
	{
		"color": "dark_magenta",
		"hex": "#8B008B",
		"dec": [
			139,
			0,
			139
		]
	},
	{
		"color": "dark_violet",
		"hex": "#9400D3",
		"dec": [
			148,
			0,
			211
		]
	},
	{
		"color": "dark_orchid",
		"hex": "#9932CC",
		"dec": [
			153,
			50,
			204
		]
	},
	{
		"color": "medium_orchid",
		"hex": "#BA55D3",
		"dec": [
			186,
			85,
			211
		]
	},
	{
		"color": "purple",
		"hex": "#800080",
		"dec": [
			128,
			0,
			128
		]
	},
	{
		"color": "thistle",
		"hex": "#D8BFD8",
		"dec": [
			216,
			191,
			216
		]
	},
	{
		"color": "plum",
		"hex": "#DDA0DD",
		"dec": [
			221,
			160,
			221
		]
	},
	{
		"color": "violet",
		"hex": "#EE82EE",
		"dec": [
			238,
			130,
			238
		]
	},
	{
		"color": "magenta",
		"hex": "#FF00FF",
		"dec": [
			255,
			0,
			255
		]
	},
	{
		"color": "fuchsia",
		"hex": "#FF00FF",
		"dec": [
			255,
			0,
			255
		]
	},
	{
		"color": "orchid",
		"hex": "#DA70D6",
		"dec": [
			218,
			112,
			214
		]
	},
	{
		"color": "medium_violet_red",
		"hex": "#C71585",
		"dec": [
			199,
			21,
			133
		]
	},
	{
		"color": "pale_violet_red",
		"hex": "#DB7093",
		"dec": [
			219,
			112,
			147
		]
	},
	{
		"color": "deep_pink",
		"hex": "#FF1493",
		"dec": [
			255,
			20,
			147
		]
	},
	{
		"color": "hot_pink",
		"hex": "#FF69B4",
		"dec": [
			255,
			105,
			180
		]
	},
	{
		"color": "light_pink",
		"hex": "#FFB6C1",
		"dec": [
			255,
			182,
			193
		]
	},
	{
		"color": "pink",
		"hex": "#FFC0CB",
		"dec": [
			255,
			192,
			203
		]
	},
	{
		"color": "antique_white",
		"hex": "#FAEBD7",
		"dec": [
			250,
			235,
			215
		]
	},
	{
		"color": "beige",
		"hex": "#F5F5DC",
		"dec": [
			245,
			245,
			220
		]
	},
	{
		"color": "bisque",
		"hex": "#FFE4C4",
		"dec": [
			255,
			228,
			196
		]
	},
	{
		"color": "blanched_almond",
		"hex": "#FFEBCD",
		"dec": [
			255,
			235,
			205
		]
	},
	{
		"color": "wheat",
		"hex": "#F5DEB3",
		"dec": [
			245,
			222,
			179
		]
	},
	{
		"color": "corn_silk",
		"hex": "#FFF8DC",
		"dec": [
			255,
			248,
			220
		]
	},
	{
		"color": "lemon_chiffon",
		"hex": "#FFFACD",
		"dec": [
			255,
			250,
			205
		]
	},
	{
		"color": "light_golden_rod_yellow",
		"hex": "#FAFAD2",
		"dec": [
			250,
			250,
			210
		]
	},
	{
		"color": "light_yellow",
		"hex": "#FFFFE0",
		"dec": [
			255,
			255,
			224
		]
	},
	{
		"color": "saddle_brown",
		"hex": "#8B4513",
		"dec": [
			139,
			69,
			19
		]
	},
	{
		"color": "sienna",
		"hex": "#A0522D",
		"dec": [
			160,
			82,
			45
		]
	},
	{
		"color": "chocolate",
		"hex": "#D2691E",
		"dec": [
			210,
			105,
			30
		]
	},
	{
		"color": "peru",
		"hex": "#CD853F",
		"dec": [
			205,
			133,
			63
		]
	},
	{
		"color": "sandy_brown",
		"hex": "#F4A460",
		"dec": [
			244,
			164,
			96
		]
	},
	{
		"color": "burly_wood",
		"hex": "#DEB887",
		"dec": [
			222,
			184,
			135
		]
	},
	{
		"color": "tan",
		"hex": "#D2B48C",
		"dec": [
			210,
			180,
			140
		]
	},
	{
		"color": "rosy_brown",
		"hex": "#BC8F8F",
		"dec": [
			188,
			143,
			143
		]
	},
	{
		"color": "moccasin",
		"hex": "#FFE4B5",
		"dec": [
			255,
			228,
			181
		]
	},
	{
		"color": "navajo_white",
		"hex": "#FFDEAD",
		"dec": [
			255,
			222,
			173
		]
	},
	{
		"color": "peach_puff",
		"hex": "#FFDAB9",
		"dec": [
			255,
			218,
			185
		]
	},
	{
		"color": "misty_rose",
		"hex": "#FFE4E1",
		"dec": [
			255,
			228,
			225
		]
	},
	{
		"color": "lavender_blush",
		"hex": "#FFF0F5",
		"dec": [
			255,
			240,
			245
		]
	},
	{
		"color": "linen",
		"hex": "#FAF0E6",
		"dec": [
			250,
			240,
			230
		]
	},
	{
		"color": "old_lace",
		"hex": "#FDF5E6",
		"dec": [
			253,
			245,
			230
		]
	},
	{
		"color": "papaya_whip",
		"hex": "#FFEFD5",
		"dec": [
			255,
			239,
			213
		]
	},
	{
		"color": "sea_shell",
		"hex": "#FFF5EE",
		"dec": [
			255,
			245,
			238
		]
	},
	{
		"color": "mint_cream",
		"hex": "#F5FFFA",
		"dec": [
			245,
			255,
			250
		]
	},
	{
		"color": "slate_gray",
		"hex": "#708090",
		"dec": [
			112,
			128,
			144
		]
	},
	{
		"color": "light_slate_gray",
		"hex": "#778899",
		"dec": [
			119,
			136,
			153
		]
	},
	{
		"color": "light_steel_blue",
		"hex": "#B0C4DE",
		"dec": [
			176,
			196,
			222
		]
	},
	{
		"color": "lavender",
		"hex": "#E6E6FA",
		"dec": [
			230,
			230,
			250
		]
	},
	{
		"color": "floral_white",
		"hex": "#FFFAF0",
		"dec": [
			255,
			250,
			240
		]
	},
	{
		"color": "alice_blue",
		"hex": "#F0F8FF",
		"dec": [
			240,
			248,
			255
		]
	},
	{
		"color": "ghost_white",
		"hex": "#F8F8FF",
		"dec": [
			248,
			248,
			255
		]
	},
	{
		"color": "honeydew",
		"hex": "#F0FFF0",
		"dec": [
			240,
			255,
			240
		]
	},
	{
		"color": "ivory",
		"hex": "#FFFFF0",
		"dec": [
			255,
			255,
			240
		]
	},
	{
		"color": "azure",
		"hex": "#F0FFFF",
		"dec": [
			240,
			255,
			255
		]
	},
	{
		"color": "snow",
		"hex": "#FFFAFA",
		"dec": [
			255,
			250,
			250
		]
	},
	{
		"color": "black",
		"hex": "#000000",
		"dec": [
			0,
			0,
			0
		]
	},
	{
		"color": "dim_gray",
		"hex": "#696969",
		"dec": [
			105,
			105,
			105
		]
	},
	{
		"color": "dim_grey",
		"hex": "#696969",
		"dec": [
			105,
			105,
			105
		]
	},
	{
		"color": "gray",
		"hex": "#808080",
		"dec": [
			128,
			128,
			128
		]
	},
	{
		"color": "grey",
		"hex": "#808080",
		"dec": [
			128,
			128,
			128
		]
	},
	{
		"color": "dark_gray",
		"hex": "#A9A9A9",
		"dec": [
			169,
			169,
			169
		]
	},
	{
		"color": "dark_grey",
		"hex": "#A9A9A9",
		"dec": [
			169,
			169,
			169
		]
	},
	{
		"color": "silver",
		"hex": "#C0C0C0",
		"dec": [
			192,
			192,
			192
		]
	},
	{
		"color": "light_gray",
		"hex": "#D3D3D3",
		"dec": [
			211,
			211,
			211
		]
	},
	{
		"color": "light_grey",
		"hex": "#D3D3D3",
		"dec": [
			211,
			211,
			211
		]
	},
	{
		"color": "gainsboro",
		"hex": "#DCDCDC",
		"dec": [
			220,
			220,
			220
		]
	},
	{
		"color": "white_smoke",
		"hex": "#F5F5F5",
		"dec": [
			245,
			245,
			245
		]
	},
	{
		"color": "white",
		"hex": "#FFFFFF",
		"dec": [
			255,
			255,
			255
		]
	}
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment