Exemplo n.º 1
0
def get_animation_frame(image_format, physical_size, scale, newick,
                        eigenvector_index, yaw, pitch):
    """
    This function is about drawing the tree.
    @param image_format: the image extension
    @param physical_size: the width and height of the image in pixels
    @param scale: a scaling factor
    @return: the animation frame as an image as a string
    """
    # before we begin drawing we need to create the cairo surface and context
    cairo_helper = CairoUtil.CairoHelper(image_format)
    surface = cairo_helper.create_surface(physical_size[0], physical_size[1])
    ctx = cairo.Context(surface)
    # draw a white background
    ctx.save()
    ctx.set_source_rgb(1, 1, 1)
    ctx.paint()
    ctx.restore()
    # define some helper variables
    x0 = physical_size[0] / 2.0
    y0 = physical_size[1] / 2.0
    # translate to the center of the frame
    ctx.translate(x0, y0)
    ctx.scale(1, -1)
    # draw the info
    TreeProjection.draw_cairo_frame(ctx, scale, newick, eigenvector_index, yaw,
                                    pitch)
    # create the image
    return cairo_helper.get_image_string()
Exemplo n.º 2
0
def get_animation_frame(
        image_format, physical_size, scale,
        newick, eigenvector_index, yaw, pitch):
    """
    This function is about drawing the tree.
    @param image_format: the image extension
    @param physical_size: the width and height of the image in pixels
    @param scale: a scaling factor
    @return: the animation frame as an image as a string
    """
    # before we begin drawing we need to create the cairo surface and context
    cairo_helper = CairoUtil.CairoHelper(image_format)
    surface = cairo_helper.create_surface(physical_size[0], physical_size[1])
    ctx = cairo.Context(surface)
    # draw a white background 
    ctx.save() 
    ctx.set_source_rgb(1, 1, 1)
    ctx.paint() 
    ctx.restore() 
    # define some helper variables
    x0 = physical_size[0] / 2.0
    y0 = physical_size[1] / 2.0
    # translate to the center of the frame
    ctx.translate(x0, y0)
    ctx.scale(1, -1)
    # draw the info
    TreeProjection.draw_cairo_frame(
            ctx, scale, newick, eigenvector_index, yaw, pitch)
    # create the image
    return cairo_helper.get_image_string()
Exemplo n.º 3
0
def get_response_content(fs):
    """
    @param fs: a FieldStorage object containing the cgi arguments
    @return: the response
    """
    tikz_body_lines = TreeProjection.get_tikz_lines(fs.tree,
                                                    fs.eigenvector_index,
                                                    fs.yaw, fs.pitch)
    tikz_body = '\n'.join(tikz_body_lines)
    options = {'x': '1em', 'y': '1em', 'inner sep': '0pt'}
    tikzpicture = tikz.get_picture(tikz_body, **options)
    return tikz.get_response(tikzpicture, fs.tikzformat)
Exemplo n.º 4
0
def get_response_content(fs):
    """
    @param fs: a FieldStorage object containing the cgi arguments
    @return: the response
    """
    tikz_body_lines = TreeProjection.get_tikz_lines(
            fs.tree, fs.eigenvector_index, fs.yaw, fs.pitch)
    tikz_body = '\n'.join(tikz_body_lines)
    options = {
            'x' : '1em',
            'y' : '1em',
            'inner sep': '0pt'}
    tikzpicture = tikz.get_picture(tikz_body, **options)
    return tikz.get_response(tikzpicture, fs.tikzformat)