-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaffine_font_indeed.py
executable file
·61 lines (49 loc) · 1.66 KB
/
affine_font_indeed.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
from __future__ import print_function
import argparse
from text import Text
from font import Font
from layout import Layout
from affine_finder import AffineFinder
from flame_writer import FlameWriter
def make_flame(args):
"""
Use the arguments to make a flame file.
"""
# Select the padding style
pad_char = '█' if args.block_padding else ' '
text = Text(args.text, pad_char)
# Read in the font and sanitize the text
font = Font()
text.sanitize(font.alphabet)
print("Making fractal for the following text:")
print(text)
# The Layout handles positioning each character of text
layout = Layout(font, text)
# The AffineFinder calculates the necessary transformation
# matricies. It returns XForm Objects
finder = AffineFinder(layout.bounding_box)
xforms = list(finder.find_xforms(layout.geometry))
print("This fractal will use {} xforms + final xform".format(len(xforms)))
writer = FlameWriter()
writer.write(args.fname, args.flame_name, xforms)
def get_args():
parser = argparse.ArgumentParser()
parser.add_argument(
'fname',
help='Enter a path to the output .flame file')
parser.add_argument(
'flame_name',
help='Enter a name for the flame inside the pack')
parser.add_argument(
'text',
help='Text of the fractal. Use $\'these\\nstrings\' for multiline')
parser.add_argument(
'-b',
'--block-padding',
action='store_true',
help='Use █ to fill out the empty spaces in the text')
return parser.parse_args()
if __name__ == '__main__':
args = get_args()
make_flame(args)