Make background of png images configurable (#200)

This commit is contained in:
Igor Chubin 2021-04-05 13:13:16 +02:00
parent 33399b193b
commit 5ef9e3eddb
2 changed files with 7 additions and 2 deletions

View file

@ -163,7 +163,7 @@ def _load_emojilib():
emojilib = {}
for filename in glob.glob("share/emoji/*.png"):
character = os.path.basename(filename)[:-4]
character = os.path.basename(filename)[:-3]
emojilib[character] = \
Image.open(filename).resize((CHAR_HEIGHT, CHAR_HEIGHT))
return emojilib
@ -183,7 +183,11 @@ def _gen_term(buf, graphemes, options=None):
cols = max(len(x) for x in buf)
rows = len(buf)
image = Image.new('RGB', (cols * CHAR_WIDTH, rows * CHAR_HEIGHT))
bg_color = 0
if "background" in options:
bg_color = _color_mapping(options["background"])
image = Image.new('RGB', (cols * CHAR_WIDTH, rows * CHAR_HEIGHT), color=bg_color)
buf = buf[-ROWS:]

View file

@ -42,6 +42,7 @@ PNG options:
p # add frame around the output
t # transparency 150
transparency=... # transparency from 0 to 255 (255 = not transparent)
background=... # background color in form RRGGBB, e.g. 00aaaa
Options can be combined: