Closed Vibhav201 closed 10 months ago
Tagging @Aonodensetsu
Ref. #164
that was before i added code re-creation so you'd have to go back to before version 3.0, and use that to recover the colors, i'll look at it
Get the old palette generator
pip install prev-gen==2.1
Convert to code, color names and settings are manual
from glob import glob
from prev_gen import Reverse
names = [
['bg_dim', 'bg0', 'bg1', 'bg2', 'bg3', 'bg4', 'bg5'],
['bg_statustline1','bg_statustline2','bg_statustline3','bg_diff_green','bg_visual_green','bg_diff_red','bg_visual_red'],
['bg_diff_blue','bg_visual_blue','bg_visual_yellow','bg_current_word','fg0','fg1','red'],
['orange','yellow','green','aqua','blue','purple','bg_red'],
['bg_green','bg_yellow','grey0','grey1','grey2']
]
for i in glob('*'):
if '.png' not in i:
continue
if 'main' in i:
continue
s = f'from prev_gen import Color, Preview, Settings\npalette = [\n Settings(fileName=\'{i.removesuffix(".png")}\', gridWidth=400, gridHeight=200),'
t = Reverse(i)
for r, k in zip(t, names):
s += '\n ['
for c, l in zip(r, k):
if c:
s += f'\n Color(\'{c.hex}\', \'{l}\'),'
s += '\n ],'
s += '\n]\nPreview(palette, save=True, show=False)'
with open(i.removesuffix('.png') + '.py', 'w') as f:
f.write(s)
Get the new palette generator
pip install -U prev-gen
(Optional) Generate new previews
from glob import glob
for i in glob('*'):
if '.py' not in i:
continue
if 'main' in i:
continue
with open(i, 'r') as f:
exec(f.read())
The palettes in new format, which allow prev_gen --out py filename
to get the code
(and then prev_gen --unsafe --out svg codefile
for svg previews)
gruvbox-material.zip
Copy the code above (and edit hardcoded values) for other palettes you want, but you can first try to extract code with the command above, because i added the re-creation quite early so hopefully most PNGs out there support it.
While doing this I discovered a bug, so you'll have to go into the generated code and remove the 'None'
strings, since for some reason the unquoting broke.
The PNGs I downloaded from Github READMEs don't work directly with this command - prev_gen --out py filename.png
. So, I guess have to manually edit the script you provided for each palette. Thanks for the help on this.
@antoineco I was able to recreate the palette python files with the script that @Aonodensetsu provided so I am closing this issue. If you want to add the files to the respective repos for all of @sainnhe's themes I can share them. Thanks for the help.
I saw in an old PR that prev_gen was used to generate the palette previews for this amazing colour scheme.
I wanted to have the palette previews in SVG format and it would be a lot easier for me to generate them if you could provide the config files (Python/JSON/TOML/YAML) that were used to generate the palette previews.
If you can please share the prev_gen files of Edge, Sonokai and Everforest as well. If possible please add them to the respective repos as well. SVGs help me to make ports quickly and the config files will help me to customise the palette previews.
Thanks in advance :)