Esempio n. 1
0
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()
Esempio n. 2
0
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()
Esempio n. 3
0
    p2y = y2 - cy2

    ctx.beginpath(x1, y1 - sw)
    ctx.curveto(p1x, p1y, p2x, p2y, x2, y2)
    ctx.curveto(p2x, p2y, p1x, p1y, x1, y1 + sw)
    ctx.endpath()

    ctx.nostroke()
    ctx.fill(1, 0, 0)
    ctx.oval(p1x - 3, p1y - 3, 6, 6)

    ctx.fill(0, 1, 0)
    ctx.oval(p2x - 3, p2y - 3, 6, 6)


init_surface(500, 150, scale=0.8)
ctx.background(ctx.color(1))

ctx.stroke(.3)
ctx.fill(.3)
#drawconn(ctx, 20, 3,
#         20, 20, 250, 120,
#         0.7, 0.28, 0.1, 0.2)

drawconn(ctx, 3, 3,
         20, 20, 250, 120,
         0.2, 0, 1.0, 0.0)

ctx.writesurface()

Esempio n. 4
0
    p1y = y1 + cy1

    p2x = x2 - cx2
    p2y = y2 - cy2

    ctx.beginpath(x1, y1 - sw)
    ctx.curveto(p1x, p1y, p2x, p2y, x2, y2)
    ctx.curveto(p2x, p2y, p1x, p1y, x1, y1 + sw)
    ctx.endpath()

    ctx.nostroke()
    ctx.fill(1, 0, 0)
    ctx.oval(p1x - 3, p1y - 3, 6, 6)

    ctx.fill(0, 1, 0)
    ctx.oval(p2x - 3, p2y - 3, 6, 6)


init_surface(500, 150, scale=0.8)
ctx.background(ctx.color(1))

ctx.stroke(.3)
ctx.fill(.3)
#drawconn(ctx, 20, 3,
#         20, 20, 250, 120,
#         0.7, 0.28, 0.1, 0.2)

drawconn(ctx, 3, 3, 20, 20, 250, 120, 0.2, 0, 1.0, 0.0)

ctx.writesurface()