📝 Bigger names

This commit is contained in:
jona605a
2020-08-08 20:13:07 +02:00
parent 8be15b6dd5
commit 8b13137ccb
2 changed files with 68 additions and 62 deletions

View File

@ -18,20 +18,25 @@ TEXTCOLOR = (0,0,0)
fnt = ImageFont.truetype('resources/futura-bold.ttf', FONTSIZE)
LINETHICKNESS = 15
HEXTHICKNESS = 6
HEXTHICKNESS = 6 # This is half the width of the background lining between every hex
X_THICKNESS = HEXTHICKNESS * math.cos(math.pi/6)
Y_THICKNESS = HEXTHICKNESS * math.sin(math.pi/6)
BACKGROUND_COLOR = (230,230,230)
BETWEEN_COLOR = BACKGROUND_COLOR
BLANK_COLOR = "lightgrey" # maybe lighter?
BLANK_COLOR = "lightgrey"
PIECECOLOR = {1:(237,41,57),2:(0,165,255),0:BLANK_COLOR} # player1 is red, player2 is blue
BOARDCOORDINATES = [ [(X_OFFSET + HEXAGONWIDTH*(column + row/2),Y_OFFSET + HEXAGONHEIGHT*row) for column in range(11)] for row in range(11)] # These are the coordinates for the upperleft corner of every hex
COLHEXTHICKNESS = 4
COLHEXTHICKNESS = 4 # When placing a hex, it is a little bigger than the underlying hex in the background (4 < 6)
COLX_THICKNESS = COLHEXTHICKNESS * math.cos(math.pi/6)
COLY_THICKNESS = COLHEXTHICKNESS * math.sin(math.pi/6)
# The Name display things:
NAMESIZE = 60
NAME_fnt = ImageFont.truetype('resources/futura-bold.ttf', NAMESIZE)
X_NAME = {1:175, 2:CANVAS_WIDTH-100}
Y_NAME = {1:CANVAS_HEIGHT-150, 2:150}
NAMEHEXPADDING = 75
NAMEHEXPADDING = 90
SMOL_WIDTH = HEXAGONWIDTH * 0.6
SMOL_SIDELENGTH = SIDELENGTH * 0.6
def drawBoard(channel):
logThis("Drawing empty Hex board")
@ -115,18 +120,18 @@ def drawBoard(channel):
playername = getName(data[channel]["players"][p-1])
# Draw name
x = X_NAME[p]
x -= fnt.getsize(playername)[0] if p==2 else 0 # player2's name is right-aligned
x -= NAME_fnt.getsize(playername)[0] if p==2 else 0 # player2's name is right-aligned
y = Y_NAME[p]
d.text((x,y),playername, font=fnt, fill = TEXTCOLOR)
d.text((x,y),playername, font=NAME_fnt, fill = TEXTCOLOR)
# Draw a half-size Hexagon to indicate the player's color
x -= NAMEHEXPADDING # To the left of both names
d.polygon([
(x, y),
(x+HEXAGONWIDTH/4, y-SIDELENGTH/4),
(x+HEXAGONWIDTH/2, y),
(x+HEXAGONWIDTH/2, y+SIDELENGTH/2),
(x+HEXAGONWIDTH/4, y+SIDELENGTH*3/4),
(x, y+SIDELENGTH/2),
(x+SMOL_WIDTH/2, y-SMOL_SIDELENGTH/2),
(x+SMOL_WIDTH, y),
(x+SMOL_WIDTH, y+SMOL_SIDELENGTH),
(x+SMOL_WIDTH/2, y+SMOL_SIDELENGTH*3/2),
(x, y+SMOL_SIDELENGTH),
],fill = PIECECOLOR[p])
im.save("resources/games/hexBoards/board"+channel+".png")