From 8a247c84bafb97d34d69e7410911e587471faed7 Mon Sep 17 00:00:00 2001 From: Roel Harbers Date: Sat, 24 Dec 2022 14:36:01 +0100 Subject: [PATCH 1/2] use # modifier to print hex --- tools/convert.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/convert.py b/tools/convert.py index 1bdf717..b268635 100755 --- a/tools/convert.py +++ b/tools/convert.py @@ -45,12 +45,12 @@ frames.append(cut_frame) if is_icon: - print('icon = ([0x' + - ', 0x'.join([', 0x'.join([format(r << 24 | g << 16 | b << 8 | a, '08x') for r, g, b, a in frame]) for frame in + print('icon = ([' + + ', '.join([', '.join([format(r << 24 | g << 16 | b << 8 | a, '#010x') for r, g, b, a in frame]) for frame in frames]) + '], %d)' % used_frames) else: - print('rgb.gif([0x' + - ', 0x'.join([', 0x'.join([format(r << 24 | g << 16 | b << 8 | a, '08x') for r, g, b, a in frame]) for frame in + print('rgb.gif([' + + ', '.join([', '.join([format(r << 24 | g << 16 | b << 8 | a, '#010x') for r, g, b, a in frame]) for frame in frames]) + '], (%d, %d), (%d, %d), %d)' % (0, 0, used_width, used_height, used_frames)) From e388e46d84e05b4d5007471ea241cc9b506f3375 Mon Sep 17 00:00:00 2001 From: Roel Harbers Date: Sat, 24 Dec 2022 15:02:11 +0100 Subject: [PATCH 2/2] split lines and frames over multiple lines, so you get sane line lengths and you can actually paste the output to the python cli --- tools/convert.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/tools/convert.py b/tools/convert.py index b268635..db25657 100755 --- a/tools/convert.py +++ b/tools/convert.py @@ -45,12 +45,22 @@ frames.append(cut_frame) if is_icon: - print('icon = ([' + - ', '.join([', '.join([format(r << 24 | g << 16 | b << 8 | a, '#010x') for r, g, b, a in frame]) for frame in - frames]) + - '], %d)' % used_frames) + print('icon = ([') + for frame_idx, frame in enumerate(frames): + print(' # frame %d' % frame_idx) + for i in range(0, len(frame), length_x): + print(' ', end='') + for r, g, b, a in frame[i:i+length_x]: + print(' ' + format(r << 24 | g << 16 | b << 8 | a, '#010x') + ',', end='') + print() + print('], %d)' % used_frames) else: - print('rgb.gif([' + - ', '.join([', '.join([format(r << 24 | g << 16 | b << 8 | a, '#010x') for r, g, b, a in frame]) for frame in - frames]) + - '], (%d, %d), (%d, %d), %d)' % (0, 0, used_width, used_height, used_frames)) + print('rgb.gif([') + for frame_idx, frame in enumerate(frames): + print(' # frame %d' % frame_idx) + for i in range(0, len(frame), length_x): + print(' ', end='') + for r, g, b, a in frame[i:i+length_x]: + print(' ' + format(r << 24 | g << 16 | b << 8 | a, '#010x') + ',', end='') + print() + print('], (%d, %d), (%d, %d), %d)' % (0, 0, used_width, used_height, used_frames))