def create_svg_image(styles, board_size, hexagons): """ Creates SVG drawing. The drawing contains all given css styles, a board (background rectangle) of given size and all given hexagons. The board can be styled using '.board'. All hexagonal fields can be styled using '.hex-field'. Fields can be also styled using 'hex-field-X', where X is the type of the field. :param styles iterable of css styles (strings) :param board_size tuple representing board size (width, height) :param hexagons iterable of hexagons (tuples in a form of (vertices, type) ) :returns SVG Drawing object """ svg_image = Drawing() for style in styles: svg_image.add(svg_image.style(style)) svg_image.add(svg_image.rect(size=board_size, class_="board")) for hexagon in hexagons: svg_image.add(svg_image.polygon(hexagon.vertices, class_="hex-field hex-field-%d" % hexagon.type)) return svg_image
fontsize = 12 titlefont = 16 w = width - 2*padding h = height - 2*padding - titlefont - fontsize line_width = 200 # styling for svg css = 'text { font-family: "Georgia", Georgia, serif; }' # create svg dwg = Drawing("test.svg", size=(width,height)) dwg.defs.add(dwg.style(css)) data = read_csv(indata) labels = data.iloc[:,0] cols = data.iloc[:,1:] ncols = cols.shape[1] nlines = ncols - 1 colspace = h - nlines*200 colwidth = colspace / float(ncols) collocs = (arange(ncols) + 1)*colwidth # pad g = dwg.add(dwg.g(transform="translate(%i,%i)" % (padding,padding))) title = g.add(dwg.g())
def init_image(width: int, height: int) -> Drawing: image = Drawing(size=('%dpx' % width, '%dpx' % height)) image.add(image.rect((0, 0), (width, height), fill='white')) image.defs.add(image.style(CSS)) return image
tabpad = " " fontsize = 12 titlefont = 16 w = width - 2 * padding h = height - 2 * padding - titlefont - fontsize line_width = 200 # styling for svg css = 'text { font-family: "Georgia", Georgia, serif; }' # create svg dwg = Drawing("test.svg", size=(width, height)) dwg.defs.add(dwg.style(css)) data = read_csv(indata) labels = data.iloc[:, 0] cols = data.iloc[:, 1:] ncols = cols.shape[1] nlines = ncols - 1 colspace = h - nlines * 200 colwidth = colspace / float(ncols) collocs = (arange(ncols) + 1) * colwidth # pad g = dwg.add(dwg.g(transform="translate(%i,%i)" % (padding, padding))) title = g.add(dwg.g())