logogen: include a few style options

This commit is contained in:
Keone Hon 2021-12-29 18:39:38 -08:00 committed by keone
parent 3b647628e6
commit add3698adc
15 changed files with 56 additions and 14 deletions

View File

@ -7,7 +7,8 @@
"scripts": { "scripts": {
"test": "jest --config jestconfig.json --verbose", "test": "jest --config jestconfig.json --verbose",
"gen": "python3 src/gen.py", "gen": "python3 src/gen.py",
"genlogos": "python3 src/gen_logos.py" "gen-logos": "python3 src/gen_logos.py",
"gen-logos-overwrite": "python3 src/gen_logos.py --overwrite"
}, },
"keywords": [ "keywords": [
"wormhole", "wormhole",

View File

@ -42,9 +42,10 @@ def get_chain_logo(chain_name):
return img return img
def get_wormhole_logo(): def get_wormhole_logo(style=None):
# bottom right # bottom right
path = os.path.join(dir_path, 'components', 'wormhole.png') filename = 'wormhole' if style is None else 'wormhole_%s' % style
path = os.path.join(dir_path, 'components', filename + '.png')
img = Image.open(path).resize(MINI_DIM).convert('RGBA') img = Image.open(path).resize(MINI_DIM).convert('RGBA')
img = add_margin(img, L-S-OFFSET, OFFSET, OFFSET, L-S-OFFSET) img = add_margin(img, L-S-OFFSET, OFFSET, OFFSET, L-S-OFFSET)
return img return img
@ -82,10 +83,10 @@ def get_base_logo(name):
return img.resize(STANDARD_DIM).convert('RGBA') return img.resize(STANDARD_DIM).convert('RGBA')
def get_logo(name, wormhole=True, chain=None): def get_logo(name, wormhole=True, chain=None, style=None):
stack = [get_base_logo(name)] stack = [get_base_logo(name)]
if wormhole: if wormhole:
stack.append(get_wormhole_logo()) stack.append(get_wormhole_logo(style=style))
if chain is not None: if chain is not None:
stack.append(get_chain_logo(chain)) stack.append(get_chain_logo(chain))
@ -102,12 +103,12 @@ def get_logo_path(name, wormhole=True, chain=None):
return os.path.join(ASSET_PATH, '%s.png' % filename) return os.path.join(ASSET_PATH, '%s.png' % filename)
def write_logo(name, outpath, wormhole=True, chain=None): def write_logo(name, outpath, wormhole=True, chain=None, style=None):
composite = get_logo(name, wormhole=wormhole, chain=chain) composite = get_logo(name, wormhole=wormhole, chain=chain, style=style)
composite.save(outpath) composite.save(outpath)
def write_logos(overwrite=False): def write_logos(overwrite=False, style=None):
for src_chain, tok_list in TOKENS.items(): for src_chain, tok_list in TOKENS.items():
tokens = tok_list.keys() tokens = tok_list.keys()
for tok in tokens: for tok in tokens:
@ -115,12 +116,13 @@ def write_logos(overwrite=False):
outpath = get_logo_path(tok, wormhole=True, chain=src_chain if use_chain else None) outpath = get_logo_path(tok, wormhole=True, chain=src_chain if use_chain else None)
if not overwrite and os.path.exists(outpath): if not overwrite and os.path.exists(outpath):
continue continue
write_logo(tok, outpath, wormhole=True, chain=src_chain if use_chain else None) write_logo(tok, outpath, wormhole=True, chain=src_chain if use_chain else None, style=style)
print('wrote %s' % outpath) print('wrote %s' % outpath)
if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('--overwrite', '-o', action='store_true') parser.add_argument('--overwrite', '-o', action='store_true')
parser.add_argument('--style', '-s', choices=['barecolor', 'color', 'thickgray', 'thingray', None])
args, unknown_args = parser.parse_known_args() args, unknown_args = parser.parse_known_args()
write_logos(overwrite=args.overwrite) write_logos(overwrite=args.overwrite, style=args.style)

View File

@ -18,16 +18,55 @@ USDTpo:
## Instructions ## Instructions
### Base logos ### Base logos
Base logos should be supplied either by adding png files to [src/logogen/base/](base/), Base logos for token `TOK` should be supplied either by adding `TOK.png` to [src/logogen/base/](base/),
or by adding a logo component to [src/config/token_data.py](../config/token_data.py). or by adding a `"logo"` entry to the appropriate block for `TOK` in [src/config/token_data.py](../config/token_data.py).
If both are present, we'll use the one in [src/logogen/base/](base/), If both are present, we'll use the one in [src/logogen/base/](base/),
### Generating new logos ### Generating new logos
Run:
``` ```
npm run genlogos npm run gen-logos
```
This won't write over any existing images in [assets](../../assets]. To overwrite the existing assets:
```
npm run gen-logos-overwrite
``` ```
### Linking to logos ### Linking to logos
``` ```
https://raw.githubusercontent.com/certusone/wormhole-token-list/main/assets/CAKE_wh.png https://raw.githubusercontent.com/certusone/wormhole-token-list/main/assets/CAKE_wh.png
``` ```
## Styling
A few style choices are included (with examples):
thick_gray (default):
![CAKE](examples/CAKE_wh_thick_gray.png)
![UST](examples/UST_wh_thick_gray.png)
thin_gray:
![CAKE](examples/CAKE_wh_thin_gray.png)
![UST](examples/UST_wh_thin_gray.png)
color:
![CAKE](examples/CAKE_wh_color.png)
![UST](examples/UST_wh_color.png)
barecolor:
![CAKE](examples/CAKE_wh_barecolor.png)
![UST](examples/UST_wh_barecolor.png)
These variants are in [src/logogen/components](components/).
To generate all the outputs with a different style from the default, run:
```
python3 gen_logos.py --overwrite --style STYLE
```
To update the default style, copy one of them to [src/logogen/components/wormhole.png](components/wormhole.png).

View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB