예제 #1
0
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)
예제 #2
0
파일: draw.py 프로젝트: tolcreator/uwputils
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'])
예제 #3
0
파일: draw.py 프로젝트: tolcreator/uwputils
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'])
예제 #4
0
파일: draw.py 프로젝트: tolcreator/uwputils
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'])
예제 #5
0
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)