def drawSubsectorGrid(draw, size, subsectors, hexSize, scheme): colour = scheme['subsectors'] xcoord = 0 ycoord = 0 for x in range(1, subsectors): xcoord += 8 * 3 * hexutils.widthBlock(hexSize) xactual = int(xcoord + (0.5 * hexutils.widthBlock(hexSize))) draw.line([(xactual, 0), (xactual, size[1])], fill=colour, width=3) for y in range(1, subsectors): ycoord += 10 * 2 * hexutils.heightBlock(hexSize) yactual = int(ycoord + (0.5 * hexutils.heightBlock(hexSize))) draw.line([(0, yactual), (size[0], yactual)], fill=colour, width=3)
def drawNavalBase(draw, origin, hexSize, scheme): coords = hexutils.getCenter(origin, hexSize) xoff = hexutils.widthBlock(hexSize) yoff = int(hexutils.heightBlock(hexSize) / 2) coords = (coords[0] - xoff, coords[1] - yoff) height = hexSize / 12 pentagon = [] for n in range(0, 5): x = height * math.cos(math.radians(270 + n * 72)) y = height * math.sin(math.radians(270 + n * 72)) pentagon.append((int(x), int(y))) vertices = [ coords[0] + pentagon[0][0], coords[1] + pentagon[0][1], coords[0] + pentagon[2][0], coords[1] + pentagon[2][1], coords[0] + pentagon[4][0], coords[1] + pentagon[4][1], coords[0] + pentagon[1][0], coords[1] + pentagon[1][1], coords[0] + pentagon[3][0], coords[1] + pentagon[3][1], coords[0] + pentagon[0][0], coords[1] + pentagon[0][1], ] draw.polygon(vertices, fill=scheme['base']['colour']) height = int(height / 4) + 1 box = [(coords[0] - height, coords[1] - height), (coords[0] + height, coords[1] + height)] draw.ellipse(box, fill=scheme['base']['colour'])
def drawScoutBase(draw, origin, hexSize, scheme): coords = hexutils.getCenter(origin, hexSize) xoff = hexutils.widthBlock(hexSize) coords = (coords[0] - xoff, coords[1]) height = hexSize / 12 xoff = int(height / math.sqrt(3)) yoff = int(height) vertices = [(coords[0], coords[1]), (coords[0] - xoff, coords[1] + yoff), (coords[0] + xoff, coords[1] + yoff), (coords[0], coords[1])] draw.polygon(vertices, fill=scheme['base']['colour'])
def drawGasGiant(draw, origin, giant, hexSize, scheme): if giant not in ['0', ' ']: coords = hexutils.getCenter(origin, hexSize) xoff = hexutils.widthBlock(hexSize) yoff = int(hexutils.heightBlock(hexSize) / 2) coords = (coords[0] + xoff, coords[1] - yoff) offset = int(hexSize / 25) box = [(coords[0] - offset, coords[1] - offset), (coords[0] + offset, coords[1] + offset)] draw.ellipse(box, fill=scheme['gasgiant']['colour'])
def drawHex(draw, x, y, hexSize, scheme, blank=False): colour = scheme['hexes'] # Draw the hex outline origin = hexutils.getPosition(x, y, hexSize) vertices = hexutils.getVertices(hexSize, origin) draw.line(vertices, fill=colour, width=2) # Write the hex coordinates if not blank: fnt = ImageFont.truetype('Arial.ttf', size=int(hexSize / 10)) coords = "%02d%02d" % (x + 1, y + 1) size = fnt.getsize(coords) position = ((hexutils.widthBlock(hexSize) * 2) - int(size[0] / 2) + origin[0], origin[1] + 3) draw.text(position, coords, font=fnt, fill=colour)