コード例 #1
0
ファイル: hex_grid.py プロジェクト: vincent/irlig
    def effect(self):

        # Get script's options values
        margins     = self.options.margins
        topMargin   = self.options.topmargin
        units       = self.options.units
        gridsize    = self.options.gridsize
        gridkind    = self.options.gridkind
        mapwidth    = self.options.mapwidth
        mapheight   = self.options.mapheight
        resolution  = self.options.resolution

        lineColor   = "black"
        fillColor   = "none"
        pen         = .01
        bigGrid     = None
        bigGridPen  = .02
        description = "map grid"
        bigGridColor="red"

        # Get access to main SVG document element and get its dimensions.
        svg = self.document.getroot()

        gridMap = gridmaps.grid(mapheight, mapwidth, description, gridsize, units, lineColor, fillColor, pen, margins, bigGrid, bigGridColor, bigGridPen, gridkind)

        # Connect elements together.
        svg.append(inkex.etree.fromstring(gridMap.save()))
コード例 #2
0
ファイル: test.py プロジェクト: ternus/assassin-hexgrid
#!/usr/bin/env python
#
#  This is a file which demonstrates the grid generation routine.
#
#######################

import gridmaps, random, os

gridMap = gridmaps.grid()

## Set up the parameters.

gridMap.setType('hex')
gridMap.setGrid(.6)


## First, we'll generate the full map (gridfull.png)

gridMap.setDrawAll(1)
gridMap.setNodes({})

filename = "tmp" + str(random.Random().random()) + ".svg"
gridMap.save(filename)

os.spawnlp(os.P_WAIT, "convert", "",  filename, "gridfull.png");
os.remove("./" + filename)

## Next, we'll generate an example user-visible map (gridtest.png)

gridMap.setDrawAll(0)
gridMap.setDrawNumbers(1)