def generate_output(data_fname, config_fname, out_fname, outformat, colorscheme=None, scale=1.0, margins=['10%', '5%']): """ TODO """ tree = _buildtree(data_fname, config_fname, colorscheme) # Temporary context for layout calculations (need an actual graphics # context to be able to work with fonts & text extents). Note that # 'None' is given for the output filename, so a failed run won't # overwrite an already existing file with an empty one. The actual # output file will be created later. _ctx.initsurface(1, 1, outformat, None, scale) width, height = tree.calclayout() # Margins can be given as percentages of the total graph size, # that's why we have to wait with the margin calculations until the # layout is complete padtop, padleft, padbottom, padright = calculate_margins(width, height, margins) width += padleft + padright height += padtop + padbottom # Center tree tree.shiftnodes(padleft, padtop) # Create output file _ctx.initsurface(width, height, outformat, out_fname, scale) _ctx.background(tree.background_color()) tree.draw() _ctx.writesurface()
def generate_output_nodebox(data_fname, config_fname, colorscheme=None, margins=['10%', '5%']): tree = _buildtree(data_fname, config_fname, colorscheme) width, height = tree.calclayout() padtop, padleft, padbottom, padright = calculate_margins(width, height, margins) width += padleft + padright height += padtop + padbottom # Center tree tree.shiftnodes(padleft, padtop) _ctx.size(width, height) _ctx.background(tree.background_color()) tree.draw()