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()