Added support for themes.

This commit is contained in:
NicklasVraa
2023-08-24 00:12:48 +02:00
parent 876edd2b8a
commit 792b7e2b80
2 changed files with 79 additions and 52 deletions

View File

@@ -47,8 +47,8 @@ With these tools, one can build a pipeline to customize most assets to fit into
- [x] Add function to remap colors directly using a json dictionary.
- [x] Update GUI to support new features.
- [x] Support inline palette and mapping objects.
- [x] Basic framework for manipulating GTK, Cinnamon and Metacity themes.
- [ ] Optional automatic palette extending.
- [ ] Basic framework for manipulating GTK, Cinnamon and Metacity themes.
- [ ] Intelligent color inversion.
- [ ] GNU/Linux binary (deb, flatpak, appimage).
@@ -58,7 +58,7 @@ Currently, three operations are supported:
| Type | Result | Speed | Support |
| :--: | ------ | ----- | ------- |
| **Monochrome recoloring** | A monochromatic variant, colored by appropriate shades of the provided base color. | ~5050svg/s<br> ~500png/s | svg, xml, css, png, jpg |
| **Palette recoloring** | A multichromatic variant, where all colors are replaced by their nearest perceived equivalent that adheres to the provided color palette. | ~100svg/s<br> ~3png/s | svg, xml, css, png, jpg |
| **Palette recoloring** | A multichromatic variant, where all colors are replaced by their nearest perceived equivalent that adheres to the provided color palette. | ~110svg/s<br> ~3png/s | svg, xml, css, png, jpg |
| **Color remapping** | A multichromatic variant, where all colors that are specified in a given map will be replaced as dictated by said map. | ~1000svg/s<br> ~10png/s | svg, xml, css, png, jpg |
| **Extract colors** | Returns and optionally saves the color palette of an image, in specified detail. | ~10colors/s | svg, xml, css, png, jpg |
| **Add backdrop** | Add a rectangular or elliptical background (and anything in between) to all svg icons. | ~5000svg/s | svg |
@@ -81,7 +81,7 @@ Recoloring collections:
src = "test/graphics" # Also try "test/theme"
name = "my_pack"
dest = "~/Downloads"
color = (0.6, 0.54, 0.5) # = rc.normalize_hsl(180, 50, 50)
color = (0.5, 0.5, 0.5) # = rc.norm_hsl(180, 50, 50)
palette = "palettes/nord.json"
mapping = "mappings/renord.json"

View File

@@ -2,18 +2,9 @@
"cells": [
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n"
]
}
],
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2\n",
@@ -27,64 +18,100 @@
"metadata": {},
"outputs": [],
"source": [
"src = \"test/graphics\" # Also try \"test/theme\"\n",
"name = \"test\"\n",
"dest = \"~/Downloads\"\n",
"\n",
"palette = {\n",
" \"type\": \"palette\",\n",
" \"name\": \"Dracula\",\n",
" \"desc\": \"Dark mode scheme with vibrant and contrasting colors.\",\n",
" \"smooth\": False,\n",
" \"colors\": [\n",
" \"#44475a\",\n",
" \"#f8f8f2\",\n",
" \"#6272a4\",\n",
" \"#6272a4\",\n",
" \"#8be9fd\",\n",
" \"#50fa7b\",\n",
" \"#ffb86c\",\n",
" \"#ff79c6\",\n",
" \"#bd93f9\",\n",
" \"#ff5555\",\n",
" \"#f1fa8c\"\n",
" ]\n",
"}\n",
"\n",
"utils.recolor(src, dest, name, palette)"
"#resource = utils.norm_hsl(180, 50, 50) # Color\n",
"resource = \"palettes/dracula.json\""
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"/home/nv/Downloads/Soph/index.theme\n"
"/home/nv/.themes/My_theme/index.theme\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"svg: 100%|██████████| 7974/7974 [00:01<00:00, 5077.70it/s]\n"
"svg: 100%|██████████| 84/84 [00:02<00:00, 40.88it/s]\n",
"css: 100%|██████████| 27/27 [00:01<00:00, 13.56it/s]\n",
"png: 100%|██████████| 442/442 [03:01<00:00, 2.44it/s]\n"
]
}
],
"source": [
"src = \"~/Downloads/NovaOS-nord-icons\" # Also try \"test/theme\"\n",
"name = \"Soph\"\n",
"dest = \"~/Downloads\"\n",
"color = (0.6, 0.54, 0.5) # = rc.normalize_hsl(180, 50, 50)\n",
"color = utils.norm_hsl(234, 65, 65)\n",
"palette = \"palettes/nord.json\"\n",
"mapping = \"mappings/renord.json\"\n",
"\n",
"# Either input a single color, palette, or mapping.\n",
"utils.recolor(src, dest, name, color)"
"# Generate theme pack.\n",
"utils.recolor(\n",
" \"~/Downloads/NovaOS-nord-theme\", # Source\n",
" \"~/.themes\", # Destination\n",
" \"My_theme\", # New name\n",
" resource\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"/home/nv/.icons/My_icons/index.theme\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"svg: 100%|██████████| 7974/7974 [01:04<00:00, 123.98it/s]\n"
]
}
],
"source": [
"# Generate icon pack.\n",
"utils.recolor(\n",
" \"~/Downloads/NovaOS-nord-icons\", # Source\n",
" \"~/.icons\", # Destination\n",
" \"My_icons\", # New name\n",
" resource\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"/home/nv/.backgrounds/My_wallpapers/index.theme\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"png: 100%|██████████| 5/5 [00:03<00:00, 1.58it/s]\n"
]
}
],
"source": [
"# Generate wallpaper pack.\n",
"utils.recolor(\n",
" \"~/Downloads/NovaOS-nord-wallpapers\", # Source\n",
" \"~/.wallpapers\", # Destination\n",
" \"My_wallpapers\", # New name\n",
" resource\n",
")"
]
}
],