🎨
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import math, random
|
||||
import math, random, json
|
||||
|
||||
from PIL import ImageDraw, Image, ImageFont
|
||||
from funcs import logThis
|
||||
@ -14,8 +14,11 @@ armPosition = 200
|
||||
manx = (limbSize*2)+lineWidth*4
|
||||
many = (circleSize+bodySize+limbSize)+lineWidth*4
|
||||
|
||||
letterSize = 200
|
||||
textSize = 50
|
||||
letterSize = 250
|
||||
textSize = 70
|
||||
|
||||
letterLineLength = 300
|
||||
letterLineDistance = 100
|
||||
|
||||
gallowx, gallowy = 1200,2000
|
||||
goldenRatio = 1-(1 / ((1 + 5 ** 0.5) / 2))
|
||||
@ -164,7 +167,12 @@ def drawGallows():
|
||||
return background
|
||||
|
||||
def drawImage(channel):
|
||||
background = Image.new("RGBA",(1920,1080),color=backgroundColor)
|
||||
with open("resources/games/hangmanGames.json", "r") as f:
|
||||
data = json.load(f)
|
||||
|
||||
random.seed(data[channel]["game ID"])
|
||||
|
||||
background = Image.new("RGBA",(1600,1000),color=backgroundColor)
|
||||
try:
|
||||
gallow = drawGallows()
|
||||
except:
|
||||
@ -173,7 +181,7 @@ def drawImage(channel):
|
||||
gallow = gallow.resize((smolGallowx,smolGallowy))
|
||||
|
||||
try:
|
||||
man = drawMan(6)
|
||||
man = drawMan(data[channel]["misses"])
|
||||
except:
|
||||
logThis("Error drawing stick figure (error code 1712)")
|
||||
|
||||
@ -185,4 +193,22 @@ def drawImage(channel):
|
||||
background.paste(gallow,(100,100),gallow)
|
||||
background.paste(man,(280,210),man)
|
||||
|
||||
letterLines = Image.new("RGBA",((letterLineLength+letterLineDistance)*len(data[channel]["word"]),300+lineWidth*3),color=(0,0,0,0))
|
||||
for x, letter in enumerate(data[channel]["word"]):
|
||||
line = badLine(letterLineLength,True)
|
||||
letterLines.paste(line,(x*(letterLineLength+letterLineDistance),300),line)
|
||||
if data[channel]["guessed"][x]:
|
||||
letterDrawing = badText(letter,True)
|
||||
letterWidth = fnt.getsize(letter)[0]
|
||||
letterx = int(x*(letterLineLength+letterLineDistance)-(letterWidth/2)+(letterLineLength*0.5)+(lineWidth*2))
|
||||
letterLines.paste(letterDrawing,(letterx,0),letterDrawing)
|
||||
|
||||
llw, llh = letterLines.size
|
||||
letterLines = letterLines.resize((int(llw*(3/10)),int(llh*(3/10))))
|
||||
|
||||
background.paste(letterLines,(120,860),letterLines)
|
||||
|
||||
d = ImageDraw.Draw(background,"RGBA")
|
||||
d.text((850,50),"Misses",font=smolfnt,fill=(0,0,0,255))
|
||||
|
||||
background.save("resources/games/hangmanBoards/hangmanBoard"+channel+".png")
|
||||
|
Reference in New Issue
Block a user