forked from rbanffy/3270font
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_grid.py
executable file
·56 lines (45 loc) · 1.86 KB
/
generate_grid.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
#!/usr/bin/env python3
import argparse
import sys
parser = argparse.ArgumentParser(description='Generate a grid for 3270font.')
parser.add_argument('origin_x', type=float, help='Origin X')
parser.add_argument('origin_y', type=float, help='Origin Y')
parser.add_argument('bottom', type=float, help='Bottom Y')
parser.add_argument('top', type=float, help='Top Y')
parser.add_argument('left', type=float, help='Leftmost X')
parser.add_argument('right', type=float, help='Rightmost X')
parser.add_argument('delta_x', type=float, help='Division width')
parser.add_argument('delta_y', type=float, help='Division height')
args = parser.parse_args()
if __name__ == '__main__':
print('Grid')
# Draw the origins
print('{:.0f} 1300 m 0\n{:.0f} -700 l 1024\n Named: "Origin X"'.format(
args.origin_x, args.origin_x))
print('-1000 {:.0f} m 0\n2000 {:.0f} l 1024\n Named: "Origin Y"'.format(
args.origin_y, args.origin_y))
# Draw horizontals above zero.
y = args.origin_y + args.delta_y
while y < args.top + args.delta_y:
print('-1000 {:.0f} m 0\n2000 {:.0f} l 1024'.format(
round(y, 0), round(y, 0)))
y += args.delta_y
# Draw horizontals below zero.
y = args.origin_y - args.delta_y
while y > args.bottom:
print('-1000 {:.0f} m 0\n2000 {:.0f} l 1024'.format(
round(y, 0), round(y, 0)))
y -= args.delta_y
# Draw verticals to the right of the origin
x = args.origin_x + args.delta_x
while x < args.right + args.delta_x:
print('{:.0f} 1300 m 0\n{:.0f} -700 l 1024'.format(
round(x, 0), round(x, 0)))
x += args.delta_x
# And to the left
x = args.origin_x - args.delta_x
while x > args.left:
print('{:.0f} 1300 m 0\n{:.0f} -700 l 1024'.format(
round(x, 0), round(x, 0)))
x -= args.delta_x
print('EndSplineSet')