ansi-art-convert 0.1.0__py3-none-any.whl → 0.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,312 @@
1
+ FONT_DATA = {
2
+ 'IBM VGA': {
3
+ 'name': 'IBM VGA',
4
+ 'font_size': '9x16',
5
+ 'resolution': '720x400',
6
+ 'aspect_ratio': '4:3',
7
+ 'pixel_aspect_ratio': '20:27 (1:1.35)',
8
+ 'vertical_stretch': '35%',
9
+ 'description': 'Standard hardware font on VGA cards for 80x25 text mode (code page 437)'
10
+ },
11
+ 'IBM VGA (8px)': {
12
+ 'name': 'IBM VGA (8px)',
13
+ 'font_size': '8x16',
14
+ 'resolution': '640x400',
15
+ 'aspect_ratio': '4:3',
16
+ 'pixel_aspect_ratio': '6:5 (1:1.2)',
17
+ 'vertical_stretch': '20%',
18
+ 'description': 'Modified stats when using an 8 pixel wide version of \'IBM VGA\' or code page variant.'
19
+ },
20
+ 'IBM VGA50': {
21
+ 'name': 'IBM VGA50',
22
+ 'font_size': '9x8',
23
+ 'resolution': '720x400',
24
+ 'aspect_ratio': '4:3',
25
+ 'pixel_aspect_ratio': '20:27 (1:1.35)',
26
+ 'vertical_stretch': '35%',
27
+ 'description': 'Standard hardware font on VGA cards for condensed 80x50 text mode (code page 437)'
28
+ },
29
+ 'IBM VGA50 (8px)': {
30
+ 'name': 'IBM VGA50 (8px)',
31
+ 'font_size': '8x8',
32
+ 'resolution': '640x400',
33
+ 'aspect_ratio': '4:3',
34
+ 'pixel_aspect_ratio': '5:6 (1:1.2)',
35
+ 'vertical_stretch': '20%',
36
+ 'description': 'Modified stats when using an 8 pixel wide version of \'IBM VGA50\' or code page variant.'
37
+ },
38
+ 'IBM VGA25G': {
39
+ 'name': 'IBM VGA25G',
40
+ 'font_size': '8x19',
41
+ 'resolution': '640x480',
42
+ 'aspect_ratio': '4:3',
43
+ 'pixel_aspect_ratio': '1:1',
44
+ 'vertical_stretch': '0%',
45
+ 'description': 'Custom font for emulating 80x25 in VGA graphics mode 12 (640x480 16 color) (code page 437).'
46
+ },
47
+ 'IBM EGA': {
48
+ 'name': 'IBM EGA',
49
+ 'font_size': '8x14',
50
+ 'resolution': '640x350',
51
+ 'aspect_ratio': '4:3',
52
+ 'pixel_aspect_ratio': '35:48 (1:1.3714)',
53
+ 'vertical_stretch': '37.14%',
54
+ 'description': 'Standard hardware font on EGA cards for 80x25 text mode (code page 437)'
55
+ },
56
+ 'IBM EGA43': {
57
+ 'name': 'IBM EGA43',
58
+ 'font_size': '8x8',
59
+ 'resolution': '640x350',
60
+ 'aspect_ratio': '4:3',
61
+ 'pixel_aspect_ratio': '35:48 (1:1.3714)',
62
+ 'vertical_stretch': '37.14%',
63
+ 'description': 'Standard hardware font on EGA cards for condensed 80x43 text mode (code page 437)'
64
+ },
65
+ 'IBM VGA ###': {
66
+ 'name': 'IBM VGA ###',
67
+ 'font_size': '9x16',
68
+ 'resolution': '720x400',
69
+ 'aspect_ratio': '4:3',
70
+ 'pixel_aspect_ratio': '20:27 (1:1.35)',
71
+ 'vertical_stretch': '35%',
72
+ 'description': 'Software installed code page font for VGA 80x25 text mode'
73
+ },
74
+ 'IBM VGA50 ###': {
75
+ 'name': 'IBM VGA50 ###',
76
+ 'font_size': '9x8',
77
+ 'resolution': '720x400',
78
+ 'aspect_ratio': '4:3',
79
+ 'pixel_aspect_ratio': '20:27 (1:1.35)',
80
+ 'vertical_stretch': '35%',
81
+ 'description': 'Software installed code page font for VGA condensed 80x50 text mode'
82
+ },
83
+ 'IBM VGA25G ###': {
84
+ 'name': 'IBM VGA25G ###',
85
+ 'font_size': '8x19',
86
+ 'resolution': '640x480',
87
+ 'aspect_ratio': '4:3',
88
+ 'pixel_aspect_ratio': '1:1',
89
+ 'vertical_stretch': '0%',
90
+ 'description': 'Custom font for emulating 80x25 in VGA graphics mode 12 (640x480 16 color).'
91
+ },
92
+ 'IBM EGA ###': {
93
+ 'name': 'IBM EGA ###',
94
+ 'font_size': '8x14',
95
+ 'resolution': '640x350',
96
+ 'aspect_ratio': '4:3',
97
+ 'pixel_aspect_ratio': '35:48 (1:1.3714)',
98
+ 'vertical_stretch': '37.14%',
99
+ 'description': 'Software installed code page font for EGA 80x25 text mode'
100
+ },
101
+ 'IBM EGA43 ###': {
102
+ 'name': 'IBM EGA43 ###',
103
+ 'font_size': '8x8',
104
+ 'resolution': '640x350',
105
+ 'aspect_ratio': '4:3',
106
+ 'pixel_aspect_ratio': '35:48 (1:1.3714)',
107
+ 'vertical_stretch': '37.14%',
108
+ 'description': 'Software installed code page font for EGA condensed 80x43 text mode'
109
+ },
110
+ 'Amiga Topaz 1': {
111
+ 'name': 'Amiga Topaz 1',
112
+ 'font_size': '8x8',
113
+ 'resolution': '640x200',
114
+ 'aspect_ratio': '4:3',
115
+ 'pixel_aspect_ratio': '5:12 (1:2.4)',
116
+ 'vertical_stretch': '140%',
117
+ 'description': 'Original Amiga Topaz Kickstart 1.x font. (A500, A1000, A2000)'
118
+ },
119
+ 'Amiga Topaz 1+': {
120
+ 'name': 'Amiga Topaz 1+',
121
+ 'font_size': '8x8',
122
+ 'resolution': '640x200',
123
+ 'aspect_ratio': '4:3',
124
+ 'pixel_aspect_ratio': '5:12 (1:2.4)',
125
+ 'vertical_stretch': '140%',
126
+ 'description': 'Modified Amiga Topaz Kickstart 1.x font. (A500, A1000, A2000)'
127
+ },
128
+ 'Amiga Topaz 2': {
129
+ 'name': 'Amiga Topaz 2',
130
+ 'font_size': '8x8',
131
+ 'resolution': '640x200',
132
+ 'aspect_ratio': '4:3',
133
+ 'pixel_aspect_ratio': '5:12 (1:2.4)',
134
+ 'vertical_stretch': '140%',
135
+ 'description': 'Original Amiga Topaz Kickstart 2.x font (A600, A1200, A4000)'
136
+ },
137
+ 'Amiga Topaz 2+': {
138
+ 'name': 'Amiga Topaz 2+',
139
+ 'font_size': '8x8',
140
+ 'resolution': '640x200',
141
+ 'aspect_ratio': '4:3',
142
+ 'pixel_aspect_ratio': '5:12 (1:2.4)',
143
+ 'vertical_stretch': '140%',
144
+ 'description': 'Modified Amiga Topaz Kickstart 2.x font (A600, A1200, A4000)'
145
+ },
146
+ 'Amiga P0T-NOoDLE': {
147
+ 'name': 'Amiga P0T-NOoDLE',
148
+ 'font_size': '8x8',
149
+ 'resolution': '640x200',
150
+ 'aspect_ratio': '4:3',
151
+ 'pixel_aspect_ratio': '5:12 (1:2.4)',
152
+ 'vertical_stretch': '140%',
153
+ 'description': 'Original P0T-NOoDLE font.'
154
+ },
155
+ 'Amiga MicroKnight': {
156
+ 'name': 'Amiga MicroKnight',
157
+ 'font_size': '8x8',
158
+ 'resolution': '640x200',
159
+ 'aspect_ratio': '4:3',
160
+ 'pixel_aspect_ratio': '5:12 (1:2.4)',
161
+ 'vertical_stretch': '140%',
162
+ 'description': 'Original MicroKnight font.'
163
+ },
164
+ 'Amiga MicroKnight+': {
165
+ 'name': 'Amiga MicroKnight+',
166
+ 'font_size': '8x8',
167
+ 'resolution': '640x200',
168
+ 'aspect_ratio': '4:3',
169
+ 'pixel_aspect_ratio': '5:12 (1:2.4)',
170
+ 'vertical_stretch': '140%',
171
+ 'description': 'Modified MicroKnight font.'
172
+ },
173
+ 'Amiga mOsOul': {
174
+ 'name': 'Amiga mOsOul',
175
+ 'font_size': '8x8',
176
+ 'resolution': '640x200',
177
+ 'aspect_ratio': '4:3',
178
+ 'pixel_aspect_ratio': '5:12 (1:2.4)',
179
+ 'vertical_stretch': '140%',
180
+ 'description': 'Original mOsOul font.'
181
+ },
182
+ 'C64 PETSCII unshifted': {
183
+ 'name': 'C64 PETSCII unshifted',
184
+ 'font_size': '8x8',
185
+ 'resolution': '320x200',
186
+ 'aspect_ratio': '4:3',
187
+ 'pixel_aspect_ratio': '5:6 (1:1.2)',
188
+ 'vertical_stretch': '20%',
189
+ 'description': 'Original Commodore PETSCII font (PET, VIC-20, C64, CBM-II, Plus/4, C16, C116 and C128) in the unshifted mode. Unshifted mode (graphics) only has uppercase letters and additional graphic characters. This is the normal boot font.'
190
+ },
191
+ 'C64 PETSCII shifted': {
192
+ 'name': 'C64 PETSCII shifted',
193
+ 'font_size': '8x8',
194
+ 'resolution': '320x200',
195
+ 'aspect_ratio': '4:3',
196
+ 'pixel_aspect_ratio': '5:6 (1:1.2)',
197
+ 'vertical_stretch': '20%',
198
+ 'description': 'Original PETSCII font in shifted mode. Shifted mode (text) has both uppercase and lowercase letters. This mode is actuated by pressing Shift+Commodore key.'
199
+ },
200
+ 'Atari ATASCII': {
201
+ 'name': 'Atari ATASCII',
202
+ 'font_size': '8x8',
203
+ 'resolution': '320x192',
204
+ 'aspect_ratio': '4:3',
205
+ 'pixel_aspect_ratio': '4:5 (1:1.25)',
206
+ 'vertical_stretch': '25%',
207
+ 'description': 'Original ATASCII font (Atari 400, 800, XL, XE)'
208
+ }
209
+ }
210
+
211
+ FILE_DATA_TYPES = {
212
+ (1, 0): {
213
+ "name": "ASCII",
214
+ "description": "Plain ASCII text file with no formatting codes or color codes.",
215
+ "tinfo1": "Character width",
216
+ "tinfo2": "Number of lines",
217
+ "tinfo3": "0",
218
+ "tinfo4": "0",
219
+ "flags": "ANSiFlags",
220
+ "tinfos": "FontName"
221
+ },
222
+ (1, 1): {
223
+ "name": "ANSi",
224
+ "description": "A file with ANSi coloring codes and cursor positioning.",
225
+ "tinfo1": "Character width",
226
+ "tinfo2": "Number of lines",
227
+ "tinfo3": "0",
228
+ "tinfo4": "0",
229
+ "flags": "ANSiFlags",
230
+ "tinfos": "FontName"
231
+ },
232
+ (1, 2): {
233
+ "name": "ANSiMation",
234
+ "description": "Like an ANSi file, but it relies on a fixed screen size.",
235
+ "tinfo1": "Character width",
236
+ "tinfo2": "Character screen height [5]",
237
+ "tinfo3": "0",
238
+ "tinfo4": "0",
239
+ "flags": "ANSiFlags",
240
+ "tinfos": "FontName"
241
+ },
242
+ (1, 3): {
243
+ "name": "RIP script",
244
+ "description": "Remote Imaging Protocol graphics.",
245
+ "tinfo1": "Pixel width (640)",
246
+ "tinfo2": "Pixel height (350)",
247
+ "tinfo3": "Number of colors (16)",
248
+ "tinfo4": "0",
249
+ "flags": "0",
250
+ "tinfos": "0"
251
+ },
252
+ (1, 4): {
253
+ "name": "PCBoard",
254
+ "description": "A file with PCBoard color codes and macros, and ANSi codes.",
255
+ "tinfo1": "Character width",
256
+ "tinfo2": "Number of lines",
257
+ "tinfo3": "0",
258
+ "tinfo4": "0",
259
+ "flags": "0",
260
+ "tinfos": "0"
261
+ },
262
+ (1, 5): {
263
+ "name": "Avatar",
264
+ "description": "A file with Avatar color codes, and ANSi codes.",
265
+ "tinfo1": "Character width",
266
+ "tinfo2": "Number of lines",
267
+ "tinfo3": "0",
268
+ "tinfo4": "0",
269
+ "flags": "0",
270
+ "tinfos": "0"
271
+ },
272
+ (1, 6): {
273
+ "name": "HTML",
274
+ "description": "HyperText Markup Language",
275
+ "tinfo1": "0",
276
+ "tinfo2": "0",
277
+ "tinfo3": "0",
278
+ "tinfo4": "0",
279
+ "flags": "0",
280
+ "tinfos": "0"
281
+ },
282
+ (1, 7): {
283
+ "name": "Source",
284
+ "description": "Source code for some programming language. The file extension should determine the programming language.",
285
+ "tinfo1": "0",
286
+ "tinfo2": "0",
287
+ "tinfo3": "0",
288
+ "tinfo4": "0",
289
+ "flags": "0",
290
+ "tinfos": "0"
291
+ },
292
+ (1, 8): {
293
+ "name": "TundraDraw",
294
+ "description": "A TundraDraw file. Like ANSI, but with a custom palette.",
295
+ "tinfo1": "Character width",
296
+ "tinfo2": "Number of lines",
297
+ "tinfo3": "0",
298
+ "tinfo4": "0",
299
+ "flags": "0",
300
+ "tinfos": "0"
301
+ },
302
+ (6, 0): {
303
+ "name": "-",
304
+ "description": "eXtended Bin",
305
+ "tinfo1": "Character width",
306
+ "tinfo2": "Number of lines",
307
+ "tinfo3": "0",
308
+ "tinfo4": "0",
309
+ "flags": "0",
310
+ "tinfos": "0"
311
+ }
312
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ansi-art-convert
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: ANSI > UTF-8 Conversion
5
5
  Author-email: Tom McKeesick <tmck01@gmail.com>
6
6
  Maintainer-email: Tom McKeesick <tmck01@gmail.com>
@@ -20,6 +20,43 @@ Dynamic: license-file
20
20
 
21
21
  # ANSI > UTF-8 Conversion
22
22
 
23
+ - [ANSI \> UTF-8 Conversion](#ansi--utf-8-conversion)
24
+ - [Installation](#installation)
25
+ - [Usage](#usage)
26
+ - [Documentation](#documentation)
27
+ - [Resources](#resources)
28
+
29
+ ---
30
+
31
+ ## Installation
32
+
33
+ You can install the [`ansi-art-convert`](https://pypi.org/project/ansi-art-convert/) package via pip:
34
+
35
+ ```shell
36
+ pip install ansi-art-convert
37
+ ```
38
+
39
+ > [!IMPORTANT]
40
+ > _As a prerequisite, you will need to install the [`ANSI megafont`](https://github.com/tmck-code/ansi-megafont) on your system via your regular font installer, and ensure that your terminal emulator is configured to use it._
41
+
42
+ Alternatively, you can install it via a one-liner (you will still need to configure your terminal to use it):
43
+ <details>
44
+ <summary>install commands:</summary>
45
+
46
+ ```shell
47
+ # osx
48
+ curl -sOL --output-dir ~/Library/Fonts/ https://github.com/tmck-code/ansi-megafont/releases/download/v0.1.0/TopazPlusPlus.ttf \
49
+ && fc-cache -f ~/Library/Fonts/ \
50
+ && fc-list | grep "TopazPlusPlus"
51
+
52
+ # linux
53
+ curl -sOL --output-dir ~/.fonts/ https://github.com/tmck-code/ansi-megafont/releases/download/v0.1.0/TopazPlusPlus.ttf \
54
+ && fc-cache -f ~/.fonts/ \
55
+ && fc-list | grep "TopazPlusPlus"
56
+ ```
57
+
58
+ </details>
59
+
23
60
  ## Usage
24
61
 
25
62
  ```shell
@@ -0,0 +1,11 @@
1
+ ansi_art_convert/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ ansi_art_convert/convert.py,sha256=yTZoDZu37NhId-QKG7uqDf31EL6O59hyANQPMqAnjik,45675
3
+ ansi_art_convert/font_data.py,sha256=cnYUyyg-1JeBz4-C7Q7vycA2mGUG8b-0vBgEz5CLHdE,11936
4
+ ansi_art_convert-0.1.1.dist-info/licenses/LICENSE,sha256=AkvQ6sNVzAHBt26pKN2O3PBpY9HHmmJhwZrL8UHR6qo,1500
5
+ bin/scroll_and_screenshot.py,sha256=Ms9AWQ32mRMbm9DmVFrWADbsnGYh7cXlnjCln3thOYA,1498
6
+ bin/scroll_print.py,sha256=p8NDUP1_rwFIiir6cl3rpP7x5e6WgGmi6pIqB1XqKKY,387
7
+ ansi_art_convert-0.1.1.dist-info/METADATA,sha256=3bhIudlC37oCxLXaB1sxbEEw60fWGw58hhuHQXn2p1s,3269
8
+ ansi_art_convert-0.1.1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
9
+ ansi_art_convert-0.1.1.dist-info/entry_points.txt,sha256=9VSbd7NZQe8Nv1aJt0fyMVry1FbqkaNHO8t4eHdOVgo,67
10
+ ansi_art_convert-0.1.1.dist-info/top_level.txt,sha256=gOZTUKOcFLezHi2Lgcj-iRu1bocpJMQIMzdDxBhkz4g,21
11
+ ansi_art_convert-0.1.1.dist-info/RECORD,,
@@ -0,0 +1,2 @@
1
+ ansi_art_convert
2
+ bin
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import glob
4
+ import os
5
+ import shutil
6
+ import sys
7
+ import time
8
+ from itertools import batched
9
+
10
+ from tqdm import tqdm
11
+
12
+ def screenshot():
13
+ os.makedirs('screenshots', exist_ok=True)
14
+ os.system(f'flameshot screen -p ./screenshots 2> /dev/null')
15
+
16
+ def crop(ifpath, ofpath, x, y, w, h):
17
+ os.system(f'magick {ifpath} -crop {w}x{h}+{x}+{y} tmp.png && mv tmp.png {ofpath}')
18
+
19
+ def vertical_stack(images, ofpath):
20
+ inputs = ' '.join(images)
21
+ os.system(f'magick {inputs} -append {ofpath}')
22
+
23
+ def get_mtimes(root, files):
24
+ for f in files:
25
+ yield os.path.getmtime(root+f), f
26
+
27
+ import operator as op
28
+ def sort_by_mtime(file_list: list[str]) -> list[str]:
29
+ for _mtime, f in sorted(get_mtimes('', file_list)):
30
+ yield f
31
+
32
+ data = open(sys.argv[1]).readlines()
33
+ output_png = sys.argv[2]
34
+ window_height = shutil.get_terminal_size().lines
35
+
36
+ print(f'printing {len(data[:window_height])} initial lines and {len(data[window_height:])} remainder lines')
37
+
38
+ time.sleep(2)
39
+
40
+ initial, remainder = data[:window_height], data[window_height:]
41
+
42
+ for line in initial:
43
+ print(' ', line, flush=True, end='')
44
+
45
+ screenshot()
46
+
47
+ for lines in batched(remainder, window_height-1):
48
+ for line in lines:
49
+ print(' ', line, flush=True, end='')
50
+ screenshot()
51
+
52
+ fpaths = list(sort_by_mtime(glob.glob('./screenshots/*.png')))
53
+
54
+ with tqdm(total=len(fpaths)) as pbar:
55
+ for fpath in fpaths:
56
+ crop(fpath, fpath, 20, 78, 972, 1274)
57
+ pbar.update()
58
+
59
+ vertical_stack(fpaths, output_png)
bin/scroll_print.py ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import shutil
4
+ import sys
5
+ import time
6
+
7
+ data = open(sys.argv[1]).readlines()
8
+ window_height = shutil.get_terminal_size().lines
9
+
10
+ print('\n\n\n\n\n')
11
+
12
+ initial, remainder = data[:window_height], data[window_height:]
13
+
14
+ for line in initial:
15
+ print(line, flush=True, end='')
16
+
17
+ for line in remainder:
18
+ print(line, flush=True, end='')
19
+ time.sleep(float(sys.argv[2]))
@@ -1,6 +0,0 @@
1
- ansi_art_convert-0.1.0.dist-info/licenses/LICENSE,sha256=AkvQ6sNVzAHBt26pKN2O3PBpY9HHmmJhwZrL8UHR6qo,1500
2
- ansi_art_convert-0.1.0.dist-info/METADATA,sha256=Q92qmQX82WNGssGAgINJN_fyZ1EF3j6nTBk6AhW_O4E,2101
3
- ansi_art_convert-0.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
4
- ansi_art_convert-0.1.0.dist-info/entry_points.txt,sha256=9VSbd7NZQe8Nv1aJt0fyMVry1FbqkaNHO8t4eHdOVgo,67
5
- ansi_art_convert-0.1.0.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
6
- ansi_art_convert-0.1.0.dist-info/RECORD,,