Skip to content

Commit 82e51b3

Browse files
committed
Add optional deck icons and two-digit p/t
1 parent ce25fed commit 82e51b3

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
*.p
33
__pycache__/
44
pages/
5+
icons/

basics/makeBasics.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ def makeBlankLand(cardName):
2222
pen.text((70, 170), typeLine, font=typeFont, fill="black", anchor="lm")
2323

2424
proxyFont = ImageFont.truetype("matrixb.ttf", 30)
25-
pen.text((70, 950), "BWPROXY 1.2", font=proxyFont, fill="black")
25+
pen.text((70, 950),
26+
"BWPROXY {}".format(drawUtil.VERSION),
27+
font=proxyFont,
28+
fill="black")
2629

2730
brushFont = ImageFont.truetype("MagicSymbols2008.ttf", 20)
2831
pen.text((70, 970), "L", font=brushFont, fill="black")

drawUtil.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import os
33
from tqdm import tqdm
44

5+
VERSION = "1.3"
6+
57

68
def blankCard():
79
cardImg = Image.new('RGB', size=(750, 1050), color=(255, 255, 255, 0))

makeProxies.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def loadCards(fileLoc, deckName):
5353
return [card for card in allCards if card is not None]
5454

5555

56-
def makeImage(card):
56+
def makeImage(card, setSymbol):
5757
cardImg, pen = drawUtil.blankCard()
5858

5959
# mana cost TODO cleanup and fix phyrexian
@@ -81,11 +81,14 @@ def makeImage(card):
8181
nameFont = drawUtil.fitOneLine("matrixb.ttf", card.name, xPos - 100, 60)
8282
pen.text((70, 85), card.name, font=nameFont, fill="black", anchor="lm")
8383

84-
# 600 width for typeline, default font 60
84+
# 600 width for typeline with symbol, default font 60
8585
typeLine = drawUtil.makeTypeLine(card.supertypes, card.types,
8686
card.subtypes)
87-
typeFont = drawUtil.fitOneLine("matrixb.ttf", typeLine, 600, 60)
88-
pen.text((70, 525), typeLine, font=typeFont, fill="black")
87+
typeFont = drawUtil.fitOneLine("matrixb.ttf", typeLine, 540, 60)
88+
pen.text((70, 530), typeLine, font=typeFont, fill="black", achor="lm")
89+
90+
if setSymbol is not None:
91+
cardImg.paste(setSymbol, (620, 520), setSymbol)
8992

9093
fmtText, textFont = drawUtil.fitMultiLine("MPLANTIN.ttf", card.text, 600,
9194
300, 40)
@@ -96,17 +99,22 @@ def makeImage(card):
9699
outline="black",
97100
fill="white",
98101
width=5)
99-
ptFont = ImageFont.truetype("MPLANTIN.ttf", 60)
102+
100103
if "Creature" in typeLine:
101104
# TODO two-digit p/t
102-
pen.text((570, 940), card.power, font=ptFont, fill="black")
103-
pen.text((600, 940), "/", font=ptFont, fill="black")
104-
pen.text((615, 940), card.toughness, font=ptFont, fill="black")
105+
pt = "{}/{}".format(card.power, card.toughness)
106+
ptFont = drawUtil.fitOneLine("MPLANTIN.ttf", pt, 85, 60)
107+
pen.text((570, 970), pt, font=ptFont, fill="black", anchor="lm")
108+
105109
else:
106-
pen.text((595, 940), card.loyalty, font=ptFont, fill="black")
110+
loyaltyFont = ImageFont.truetype("MPLANTIN.ttf", 60)
111+
pen.text((595, 940), card.loyalty, font=loyaltyFont, fill="black")
107112

108113
proxyFont = ImageFont.truetype("matrixb.ttf", 30)
109-
pen.text((70, 950), "BWPROXY 1.2", font=proxyFont, fill="black")
114+
pen.text((70, 950),
115+
"BWPROXY {}".format(drawUtil.VERSION),
116+
font=proxyFont,
117+
fill="black")
110118

111119
brushFont = ImageFont.truetype("MagicSymbols2008.ttf", 20)
112120
pen.text((70, 970), "L", font=brushFont, fill="black")
@@ -120,10 +128,12 @@ def makeImage(card):
120128
if __name__ == "__main__":
121129
#print(deckName)
122130
deckName = sys.argv[1].split(".")[0]
131+
setSymbol = Image.open(sys.argv[2]).convert("RGBA").resize(
132+
(60, 60)) if len(sys.argv) > 2 else None
123133

124134
allCards = loadCards(sys.argv[1], deckName)
125135

126-
images = [makeImage(card) for card in tqdm(allCards)]
136+
images = [makeImage(card, setSymbol) for card in tqdm(allCards)]
127137

128138
print(images)
129139
drawUtil.savePages(images, deckName)

0 commit comments

Comments
 (0)