Four in a row is almost done

This commit is contained in:
NikolajDanger
2020-07-31 15:49:58 +02:00
parent 796b209a5b
commit daa2d0ddde
7 changed files with 338 additions and 31 deletions

View File

@ -16,18 +16,22 @@ def drawImage(channel):
gridBorder = 40
cornerSize = 100
outlineSize = 20
bottomBorder = 110
exampleCircles = 100
w, h = 2800,2000
backgroundColor = (128,128,128,255)
boardColor = (0,0,170)
placeSize = 285
fnt = ImageFont.truetype('resources/futura-bold.ttf', exampleCircles)
boardSize = [w-(2*(border+gridBorder)),h-(2*(border+gridBorder))]
placeGridSize = [math.floor(boardSize[0]/7),math.floor(boardSize[1]/6)]
pieceStartx = (border+gridBorder)+math.floor(placeGridSize[0]/2)-math.floor(placeSize/2)
pieceStarty = (border+gridBorder)+math.floor(placeGridSize[1]/2)-math.floor(placeSize/2)
background = Image.new("RGB", (w,h),backgroundColor)
background = Image.new("RGB", (w,h+bottomBorder),backgroundColor)
d = ImageDraw.Draw(background,"RGBA")
# This whole part was the easiest way to make a rectangle with rounded corners and an outline
@ -110,4 +114,16 @@ def drawImage(channel):
winBar.putalpha(mask)
background.paste(winBar,(startx,starty),winBar)
# Bottom
textPadding = 20
exampleHeight = h - border + int((bottomBorder+border)/2) - int(exampleCircles/2)
d.ellipse([(border,exampleHeight),(border+exampleCircles),(exampleHeight+exampleCircles)],fill=(255,255,0),outline=(0,0,0),width=3)
d.text((border+exampleCircles+textPadding,exampleHeight),data["4 in a row games"][channel]["players"][0],font=fnt,stroke_fill=(0,0,0))
textWidth = fnt.getsize(data["4 in a row games"][channel]["players"][1])[0]
d.ellipse([(w-border-exampleCircles-textWidth-textPadding,exampleHeight),(w-border-textWidth-textPadding),(exampleHeight+exampleCircles)],fill=(255,0,0),outline=(0,0,0),width=3)
d.text((w-border-textWidth,exampleHeight),data["4 in a row games"][channel]["players"][1],font=fnt,stroke_fill=(0,0,0))
background.save("resources/games/4InARowBoards/board"+channel+".png")