Example #1
0
def PolybezierTo(ctx,page,i):
    for j in range(len(page.cmds[i].args)/3):
        x1,y1 = page.cmds[i].args[j*3]
        x1,y1 = mfdraw.convcoords(page,ctx,x1,y1)
        x2,y2 = page.cmds[i].args[j*3+1]
        x2,y2 = mfdraw.convcoords(page,ctx,x2,y2)
        x3,y3 = page.cmds[i].args[j*3+2]
        x3,y3 = mfdraw.convcoords(page,ctx,x3,y3)
        ctx.curve_to(x1,y1,x2,y2,x3,y3)
    print i,'PolybezierTo: ',page.cmds[i].args
Example #2
0
def Polygone(ctx,page,i):
    x,y = page.cmds[i].args[0]
    x,y = mfdraw.convcoords(page,ctx,x,y)
    ctx.move_to(x,y)
    for j in range(len(page.cmds[i].args)):
        x,y = page.cmds[i].args[j]
        x,y = mfdraw.convcoords(page,ctx,x,y)
        ctx.line_to(x,y)
    print i,'Polygone: ',page.cmds[i].args
    mfdraw.FillPath(ctx,page,i)
    mfdraw.StrokePath(ctx,page,i)
Example #3
0
def Polybezier(ctx,page,i):
    x0,y0 = ctx.get_current_point()
    x,y = page.cmds[i].args[0]
    x,y = mfdraw.convcoords(page,ctx,x,y)
    ctx.move_to(x,y)
    print i,'Polybezier: ',x0,y0,x,y
    for j in range(len(page.cmds[i].args)/3):
        x1,y1 = page.cmds[i].args[j*3+1]
        x1,y1 = mfdraw.convcoords(page,ctx,x1,y1)
        x2,y2 = page.cmds[i].args[j*3+2]
        x2,y2 = mfdraw.convcoords(page,ctx,x2,y2)
        x3,y3 = page.cmds[i].args[j*3+3]
        x3,y3 = mfdraw.convcoords(page,ctx,x3,y3)
        ctx.curve_to(x1,y1,x2,y2,x3,y3)
Example #4
0
def PolyPolyline(ctx,page,i):
    aPolyCounts = page.cmds[i].args[0]
    aptl = page.cmds[i].args[1]
    shift = 0
    for k in range(len(aPolyCounts)): ## number of polygones
        x,y = aptl[shift]
        x,y = mfdraw.convcoords(page,ctx,x,y)
        ctx.move_to(x,y)
        for j in range(aPolyCounts[k]-1): ## number of gones for i-th polygone
            x,y = aptl[j+1+shift]
            x,y = mfdraw.convcoords(page,ctx,x,y)
            ctx.line_to(x,y)
        shift+=aPolyCounts[k]
        print i,'Poly  Polyline: ',k,shift
Example #5
0
def Polyline(ctx,page,i):
    x,y = page.cmds[i].args[0]
    x,y = mfdraw.convcoords(page,ctx,x,y)
    ctx.move_to(x,y)
    print i,'Polyline: ',page.cmds[i].args[0]
    PolylineTo(ctx,page,i)
    mfdraw.StrokePath(ctx,page,i)
Example #6
0
def Pie(ctx,page,i):
    l,t,r,b,xs,ys,xe,ye = page.cmds[i].args
    xc,yc = mfdraw.convcoords(page,ctx,(l+r)/2.,(t+b)/2.)
    print 'Pie:',xc,yc
    Arc(ctx,page,i)
    ctx.line_to(xc,yc)
    ctx.close_path()
    mfdraw.FillPathPreserve(ctx,page,i)
    mfdraw.StrokePath(ctx,page,i)
Example #7
0
def ArcTo(ctx,page,i):
    l,t,r,b,xs,ys,xe,ye = page.cmds[i].args
    xc,yc = mfdraw.convcoords(page,ctx,(l+r)/2.,(t+b)/2.)
    dx = math.fabs(r-l)
    dy = math.fabs(b-t)
    ang1 = math.atan2((ys-yc),(xs-xc))
    ang2 = math.atan2((ye-yc),(xe-xc))
    ctx.move_to(xc,yc)
    ctx.save()
    ctx.translate(xc,yc)
    ctx.scale(dx/2., dy/2.)
    ctx.arc_negative(0.,0.,1.,ang1,ang2)
    ctx.restore()
    print 'Arc:',xc,yc,dx,dy,ang1,ang2
    mfdraw.StrokePath(ctx,page,i)
Example #8
0
def PolylineTo(ctx,page,i):
    for j in range(len(page.cmds[i].args)):
        x1,y1 = page.cmds[i].args[j]
        x1,y1 = mfdraw.convcoords(page,ctx,x1,y1)
        ctx.line_to(x1,y1)
    print i,'PolylineTo: ',page.cmds[i].args