forked from d101tm/tmstats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakepins.py
executable file
·65 lines (55 loc) · 2.08 KB
/
makepins.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
62
63
64
#!/usr/bin/env python3
""" Make all pins - needs Python 3.6 or better because it uses f-strings
Run in the directory containing pins - uses 'empty.png' as the source pin.
"""
import sys
fillcolors = {
'A': '#ffa500',
'B': '#66ffff',
'C': '#add8e6',
'D': '#f08080',
'E': '#cccc00',
'F': '#a3d7a3',
'G': '#bdb76b',
'H': '#6cd9b5',
'I': '#a38aff',
'J': '#ffff00'
}
divisions = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']
areas = ['1', '2', '3', '4', '5', '6', 'M']
font = 'ConsolasB'
loff = 2
roff = 1
toff = -2
try:
font = sys.argv[1]
except IndexError:
pass
def makecmd(leftdiv, rightdiv, leftstart, rightstart, leftitem, rightitem, outfile):
return f"convert pin.png -fill '{fillcolors[leftdiv]}' -draw 'rectangle 1,1 9,10' -fill '{fillcolors[rightdiv]}' -draw 'rectangle 10,1 18,10' -draw 'image SrcOver {leftstart},1 0,0 {leftitem}.png' -draw 'image SrcOver {rightstart},1 0,0 {rightitem}.png' {outfile}.png"
for d in divisions:
leftitem = d
leftdiv = d
rightdiv = d
for rightitem in areas:
if rightitem != 'M':
leftstart = 2
rightstart = 10
outfile = leftitem+rightitem
label = leftitem+rightitem
else:
leftstart = 1
rightstart = 10
outfile = leftitem+rightitem
label = leftitem
cmd = f"convert pin.png -fill '{fillcolors[leftdiv]}' -draw 'rectangle 1,1 18,10' -fill black -font {font} -pointsize 11 -draw 'gravity Center text 0,-2 {label}' {outfile}.png"
print(cmd)
# Now, do the multi-division pins:
leftstart = 0
rightstart = 11
for rightitem in divisions:
if rightitem > d:
rightdiv = rightitem
outfile = leftitem+rightitem
cmd = f"convert pin.png -fill '{fillcolors[leftdiv]}' -draw 'rectangle 1,1 9,10' -fill '{fillcolors[rightdiv]}' -draw 'rectangle 10,1 18,10' -fill black -font {font} -pointsize 11 -draw ' gravity West text {loff},{toff} {leftdiv}' -draw 'gravity East text {roff},{toff} {rightdiv}' {outfile}.png"
print(cmd)