Beispiel #1
0
def render_animatesvg( anime, args ):

    #Render each figure in a group
    args['ext'] = 'svg'
    output = []

    if len(anime)>0:
        #Test if output format support video
        if document._output_format=='html5':
            for iframe, svg in enumerate(anime):
                tmpout, tmpw, tmph = render_figure(svg, args)
                #parse the svg
                tmpout = '<g id="frame_%i">'%iframe + tmpout + '</g>'

                output += [tmpout]
        else:
            #Check if pdf_animations is True 
            output, tmpw, tmph = render_figure(anime[0], args)
            if document._pdf_animations:
                #Convert svg to pdf if we want to use them in animategraphics in latex
                
                #Remove the output from the svg slide (it will be rendered later in latex)
                output = ''
                

        return output, tmpw, tmph
    else:
        print('nothing found')
Beispiel #2
0
def render_animatesvg(ct):

    anime = ct['content']
    args = ct['args']

    #Render each figure in a group
    args['ext'] = 'svg'
    output = []

    if len(anime) > 0:
        #Test if output format support video
        if document._output_format == 'html5':
            for iframe, svg in enumerate(anime):
                tmpout = render_figure({
                    'content': svg,
                    'args': args,
                    'positionner': ct['positionner']
                })
                #parse the svg
                tmpout = '<g id="frame_%i">' % iframe + tmpout + '</g>'

                output += [tmpout]
        else:
            #Check if pdf_animations is True
            output = render_figure({
                'content': anime[0],
                'args': args,
                'positionner': ct['positionner']
            })

            #Todo
            """
            if document._pdf_animations:
                #Convert svg to pdf if we want to use them in animategraphics in latex

                #Remove the output from the svg slide (it will be rendered later in latex)
                output = ''
            """

        return output

    else:
        print('nothing found')
Beispiel #3
0
def render_animatesvg( ct ):

    anime = ct['content']
    args = ct['args']

    #Render each figure in a group
    args['ext'] = 'svg'
    output = []

    if len(anime)>0:
        #Test if output format support video
        if document._output_format=='html5':
            for iframe, svg in enumerate(anime):
                tmpout = render_figure( {'content':svg, 'args':args,
                                                'positionner':ct['positionner']} )
                #parse the svg
                tmpout = '<g id="frame_%i">'%iframe + tmpout + '</g>'

                output += [tmpout]
        else:
            #Check if pdf_animations is True
            output = render_figure({'content':anime[0], 'args':args,
                                               'positionner':ct['positionner']})

            #Todo
            """
            if document._pdf_animations:
                #Convert svg to pdf if we want to use them in animategraphics in latex

                #Remove the output from the svg slide (it will be rendered later in latex)
                output = ''
            """

        return output

    else:
        print('nothing found')
Beispiel #4
0
def render_code( ct ):
    """
        function to render figures
    """

    inkscapecmd=document._external_cmd['inkscape']
    codein = ct['content']
    args = ct['args']

    #Try to infer the lexer
    if args['langage'] == None:
        lexer = guess_lexer(codein)
    else:
        lexer = get_lexer_by_name(args['langage'], stripall=True)

    #Convert code to svgfile
    svgcode = highlight(codein, lexer, SvgFormatter(fontsize=args['font-size'],style='tango'))

    #Create a tmpfile
    tmpfile, tmpname = tempfile.mkstemp(prefix='beampytmp')
    #tmppath = tmpname.replace(os.path.basename(tmpname),'')

    with open( tmpname+'.svg', 'w' ) as f:
        f.write(svgcode)

    #Convert svgfile with inkscape to transform text to path
    cmd = inkscapecmd + ' -z -T -l=%s %s'%(tmpname+'_good.svg', tmpname+'.svg')

    req = os.popen(cmd)
    req.close()

    #Read the good svg
    with open(tmpname+'_good.svg','r') as f:
        goodsvg = f.read()

    #remove files
    os.remove(tmpname+'.svg')
    os.remove(tmpname+'_good.svg')

    #use the classic figure render
    args['ext'] = 'svg'
    tmpout = render_figure( {'content':goodsvg, 'args':args,
                            'positionner':ct['positionner']})
    #print tmpw, tmph
    tmpout = '<g> %s </g>'%(tmpout)
    return tmpout