Esempio n. 1
0
def testclipbbox(c):
    clip = canvas.clip(rect(11,-9,10,5))

    p1 = path(moveto(10,-10), curveto(12,-4, 14,-5, 12,-1));   
    p2 = path(moveto(12,-8), curveto(6,-2, 5,-4, 7,-5));  
    
    # just a simple test for clipping
    sc = c.insert(canvas.canvas([clip]))
    drawpathwbbox(sc, p1)
    drawpathwbbox(sc, p2)

    # more complicated operations
    
    # 1. transformation followed by clipping:
    # in this case, the clipping path will be evaluated in the
    # context of the already transformed canvas, so that the
    # actually displayed portion of the path should be the same
    sc = c.insert(canvas.canvas([trafo.translate(5,0), clip]))
    drawpathwbbox(sc, p1)
    drawpathwbbox(sc, p2)

    # 2. clipping followed by transformation 
    # in this case, the clipping path will not be transformed, so
    # that the display portionof the path should change
    sc = c.insert(canvas.canvas([clip, trafo.translate(1,1)]))
    drawpathwbbox(sc, p1)
    drawpathwbbox(sc, p2)
Esempio n. 2
0
def testtrafobbox(c):
    sc = c.insert(canvas.canvas([trafo.translate(0, 40).rotated(10)]))

    p = path(moveto(10, 10), curveto(12, 16, 14, 15, 12, 19))
    drawpathwbbox(sc, p)
    p = path(moveto(5, 17), curveto(6, 18, 5, 16, 7, 15))
    drawpathwbbox(sc, p)
Esempio n. 3
0
def testclipbbox(c):
    clip = canvas.clip(rect(11, -9, 10, 5))

    p1 = path(moveto(10, -10), curveto(12, -4, 14, -5, 12, -1))
    p2 = path(moveto(12, -8), curveto(6, -2, 5, -4, 7, -5))

    # just a simple test for clipping
    sc = c.insert(canvas.canvas([clip]))
    drawpathwbbox(sc, p1)
    drawpathwbbox(sc, p2)

    # more complicated operations

    # 1. transformation followed by clipping:
    # in this case, the clipping path will be evaluated in the
    # context of the already transformed canvas, so that the
    # actually displayed portion of the path should be the same
    sc = c.insert(canvas.canvas([trafo.translate(5, 0), clip]))
    drawpathwbbox(sc, p1)
    drawpathwbbox(sc, p2)

    # 2. clipping followed by transformation
    # in this case, the clipping path will not be transformed, so
    # that the display portionof the path should change
    sc = c.insert(canvas.canvas([clip, trafo.translate(1, 1)]))
    drawpathwbbox(sc, p1)
    drawpathwbbox(sc, p2)
Esempio n. 4
0
def testspeedintersect():
    p = path(moveto(10, 10), curveto(12, 16, 14, 15, 12, 19))
    bp = normpath(p)

    for x in range(1, 100):
        q = path(moveto(x / 5.0, 10), curveto(12, 16, 14, 22, 11, 16))
        bq = normpath(q)
        isect = bp.intersect(bq, epsilon=1e-3)
Esempio n. 5
0
def testspeedintersect():
    p=path(moveto(10,10), curveto(12,16,14,15,12,19))
    bp=normpath(p)

    for x in range(1,100):
        q=path(moveto(x/5.0,10), curveto(12,16,14,22,11,16))
        bq=normpath(q)
        isect = bp.intersect(bq, epsilon=1e-3)
Esempio n. 6
0
def testintersectbezier(c):
    p = path(moveto(0, 0), curveto(2, 6, 4, 5, 2, 9)).normpath(epsilon=1e-4)
    q = path(moveto(2, 0), curveto(2, 6, 4, 12, 1, 6)).normpath(epsilon=1e-4)

    c.stroke(q, [style.linewidth.THIN])
    c.stroke(p, [style.linewidth.THIN])

    isect = p.intersect(q)

    for i in isect[0]:
        x, y = p.at(i)
        c.stroke(cross(x, y), [style.linewidth.THIN])
Esempio n. 7
0
def testintersectbezier(c):
    p=path(moveto(0,0), curveto(2,6,4,5,2,9)).normpath(epsilon=1e-4)
    q=path(moveto(2,0), curveto(2,6,4,12,1,6)).normpath(epsilon=1e-4)

    c.stroke(q, [style.linewidth.THIN])
    c.stroke(p, [style.linewidth.THIN])

    isect = p.intersect(q)

    for i in isect[0]:
        x, y = p.at(i)
        c.stroke(cross(x, y), [style.linewidth.THIN])
Esempio n. 8
0
def testnormpathtrafo(c):
    p = path(moveto(0, 5), curveto(2, 1, 4, 0, 2, 4),
             rcurveto(-3, 2, 1, 2, 3, 6), rlineto(0, 3), closepath())

    c.stroke(p)
    c.stroke(p.normpath(), [color.rgb.green, style.linestyle.dashed])
    c.stroke(p, [trafo.translate(3, 1), color.rgb.red])
    c.insert(canvas.canvas([trafo.translate(3, 1)])).stroke(
        p, [color.rgb.green, style.linestyle.dashed])

    c.stroke(p.reversed(),
             [color.rgb.blue, style.linestyle.dotted, style.linewidth.THick])

    c.stroke(cross(*(p.at(0))))
    c.stroke(cross(*(p.reversed().at(0))))

    p1, p2 = p.split([1.0, 2.1])
    c.stroke(p1, [color.rgb.red, style.linestyle.dashed])
    c.stroke(p2, [color.rgb.green, style.linestyle.dashed])

    circ1 = circle(0, 10, 1)
    circ2 = circle(1.7, 10, 1)

    c.stroke(circ1)
    c.stroke(circ2)

    isectcirc1, isectcirc2 = circ1.intersect(circ2)
    segment1 = circ1.split(isectcirc1)[0]
    segment2 = circ2.split(isectcirc2)[1]

    segment = segment1 << segment2
    segment[-1].close()

    c.stroke(segment, [style.linewidth.THick, deco.filled([color.rgb.green])])
Esempio n. 9
0
def testtangent(c):
    p = path(moveto(0, 5), curveto(2, 1, 4, 0, 2, 4),
             rcurveto(-3, 2, 1, 2, 3, 6), rlineto(2, 3)) + circle(5, 5, 1)
    c.stroke(p, [style.linewidth.THick])
    arclen = p.arclen()
    points = 20
    for i in range(points):
        c.stroke(p.tangent(arclen * i / points, length=20 * unit.t_pt),
                 [color.rgb.blue, deco.earrow.normal])
        c.stroke(
            line(0, 0, 1, 0).transformed(p.trafo(arclen * i / points)),
            [color.rgb.green, deco.earrow.normal])
        c.stroke(
            line(0, 0, 0, 1).transformed(p.trafo(arclen * i / points)),
            [color.rgb.red, deco.earrow.normal])

    # test the curvature
    cc = canvas.canvas()
    cc.stroke(p)
    cc = canvas.canvas([canvas.clip(cc.bbox().path())])
    for i in range(points):
        curvature_pt = p.curvature_pt(unit.topt(arclen) * i / points)
        if curvature_pt != 0:
            radius_pt = 1 / curvature_pt
            x_pt, y_pt = p.trafo(arclen * i / points).apply_pt(0, radius_pt)
            cc.stroke(circle_pt(x_pt, y_pt, radius_pt), [color.grey(0.5)])
    c.insert(cc)
Esempio n. 10
0
 def testarct(c, r, x0, y0, dx1, dy1, dx2, dy2):
     p = path(moveto(x0, y0), arct(x0 + dx1, y0 + dy1, x0 + dx2, y0 + dy2,
                                   r), rlineto(dx2 - dx1, dy2 - dy1),
              closepath())
     np = p.normpath()
     c.stroke(p, [color.rgb.red, style.linewidth.Thick])
     c.stroke(np, [
         color.rgb.green, style.linewidth.THin,
         deco.filled([color.rgb.green])
     ])
Esempio n. 11
0
def testspeed3():
    "coordinates in pts (internal routines)"

    c = canvas.canvas()
    p = path(pyx.path.moveto_pt(0, 0))

    for i in range(1000):
        p.append(pyx.path.lineto_pt(i, i))

    c.stroke(p)
    c.writeEPSfile("testspeed")
Esempio n. 12
0
def testspeed():
    "coordinates as strings"
    
    c=canvas.canvas()
    p=path(moveto(0,0))

    for i in range(1000):
        p.append(lineto("%d pt" % i, "%d pt" % i))

    c.stroke(p)
    c.writeEPSfile("testspeed")
Esempio n. 13
0
def testspeed3():
    "coordinates in pts (internal routines)"

    c=canvas.canvas()
    p=path(pyx.path.moveto_pt(0,0))

    for i in range(1000):
        p.append(pyx.path.lineto_pt(i, i))

    c.stroke(p)
    c.writeEPSfile("testspeed")
Esempio n. 14
0
def testspeed2():
    "coordinates in user units"

    c=canvas.canvas()
    p=path(moveto(0,0))

    for i in range(1000):
        p.append(lineto(i,i))

    c.stroke(p)
    c.writeEPSfile("testspeed")
Esempio n. 15
0
def testspeed():
    "coordinates as strings"

    c = canvas.canvas()
    p = path(moveto(0, 0))

    for i in range(1000):
        p.append(lineto("%d pt" % i, "%d pt" % i))

    c.stroke(p)
    c.writeEPSfile("testspeed")
Esempio n. 16
0
def testspeed2():
    "coordinates in user units"

    c = canvas.canvas()
    p = path(moveto(0, 0))

    for i in range(1000):
        p.append(lineto(i, i))

    c.stroke(p)
    c.writeEPSfile("testspeed")
Esempio n. 17
0
def testarclentoparam(c):
    curve=path(moveto(0,0), lineto(0,5), curveto(5,0,0,10,5,5), closepath(),
               moveto(5,0), lineto(10,5))
    ll = curve.arclen()
    # l=[-0.8*ll, -0.6*ll, -0.4*ll, -0.2*ll, 0, 0.1*ll, 0.3*ll, 0.5*ll, 0.7*ll, 0.9*ll]
    l=[0, 0.1*ll, 0.2*ll, 0.3*ll, 0.4*ll, 0.5*ll, 0.6*ll, 0.7*ll, 0.8*ll, 0.9*ll]
    cols=[color.gray.black, color.gray(0.3), color.gray(0.7), color.rgb.red,
          color.rgb.green, color.rgb.blue, color.cmyk(1,0,0,0),
          color.cmyk(0,1,0,0), color.cmyk(0,0,1,0), color.gray.black]
    t=curve.arclentoparam(l)
    c.stroke(curve)
    for i in range(len(t)):
        c.draw(circle(curve.at(t[i])[0], curve.at(t[i])[1], 0.1), [deco.filled([cols[i]]), deco.stroked()])
Esempio n. 18
0
def testarclentoparam(c):
    curve = path(moveto(0, 0), lineto(0, 5), curveto(5, 0, 0, 10, 5, 5),
                 closepath(), moveto(5, 0), lineto(10, 5))
    ll = curve.arclen()
    # l=[-0.8*ll, -0.6*ll, -0.4*ll, -0.2*ll, 0, 0.1*ll, 0.3*ll, 0.5*ll, 0.7*ll, 0.9*ll]
    l = [
        0, 0.1 * ll, 0.2 * ll, 0.3 * ll, 0.4 * ll, 0.5 * ll, 0.6 * ll,
        0.7 * ll, 0.8 * ll, 0.9 * ll
    ]
    cols = [
        color.gray.black,
        color.gray(0.3),
        color.gray(0.7), color.rgb.red, color.rgb.green, color.rgb.blue,
        color.cmyk(1, 0, 0, 0),
        color.cmyk(0, 1, 0, 0),
        color.cmyk(0, 0, 1, 0), color.gray.black
    ]
    t = curve.arclentoparam(l)
    c.stroke(curve)
    for i in range(len(t)):
        c.draw(circle(curve.at(t[i])[0],
                      curve.at(t[i])[1], 0.1),
               [deco.filled([cols[i]]), deco.stroked()])
Esempio n. 19
0
def testnormpathtrafo(c):
    p = path(moveto(0, 5),
             curveto(2, 1, 4, 0, 2, 4),
             rcurveto(-3, 2, 1, 2, 3, 6),
             rlineto(0, 3),
             closepath())

    c.stroke(p)
    c.stroke(p.normpath(), [color.rgb.green, style.linestyle.dashed])
    c.stroke(p, [trafo.translate(3, 1), color.rgb.red])
    c.insert(canvas.canvas([trafo.translate(3,1)])).stroke(p,
                                                          [color.rgb.green,
                                                          style.linestyle.dashed])

    c.stroke(p.reversed(), [color.rgb.blue, style.linestyle.dotted, style.linewidth.THick])

    c.stroke(cross(*(p.at(0))))
    c.stroke(cross(*(p.reversed().at(0))))

    p1, p2 = p.split([1.0, 2.1])
    c.stroke(p1, [color.rgb.red, style.linestyle.dashed])
    c.stroke(p2, [color.rgb.green, style.linestyle.dashed])

    circ1 = circle(0, 10, 1)
    circ2 = circle(1.7, 10, 1)

    c.stroke(circ1)
    c.stroke(circ2)

    isectcirc1, isectcirc2 = circ1.intersect(circ2)
    segment1 = circ1.split(isectcirc1)[0]
    segment2 = circ2.split(isectcirc2)[1]

    segment = segment1 << segment2
    segment[-1].close()

    c.stroke(segment, [style.linewidth.THick, deco.filled([color.rgb.green])])
Esempio n. 20
0
def testtangent(c):
    p=path(moveto(0,5),
           curveto(2,1,4,0,2,4),
           rcurveto(-3,2,1,2,3,6),
           rlineto(2,3)) + circle(5,5,1)
    c.stroke(p, [style.linewidth.THick])
    arclen = p.arclen()
    points = 20
    for i in range(points):
        c.stroke(p.tangent(arclen*i/points, length=20*unit.t_pt), [color.rgb.blue, deco.earrow.normal])
        c.stroke(line(0, 0, 1, 0).transformed(p.trafo(arclen*i/points)), [color.rgb.green, deco.earrow.normal])
        c.stroke(line(0, 0, 0, 1).transformed(p.trafo(arclen*i/points)), [color.rgb.red, deco.earrow.normal])

    # test the curvature
    cc = canvas.canvas()
    cc.stroke(p)
    cc = canvas.canvas([canvas.clip(cc.bbox().path())])
    for i in range(points):
        curvature_pt = p.curvature_pt(unit.topt(arclen)*i/points)
        if curvature_pt != 0:
            radius_pt = 1/curvature_pt
            x_pt, y_pt = p.trafo(arclen*i/points).apply_pt(0, radius_pt)
            cc.stroke(circle_pt(x_pt, y_pt, radius_pt), [color.grey(0.5)])
    c.insert(cc)
Esempio n. 21
0
def testarrow(c):
    c.stroke(
        path(moveto(10, 20), curveto(12, 16, 14, 15, 12, 19),
             rcurveto(-3, 2, 3, 3, -2, 4)), [
                 deco.barrow.small, deco.earrow.normal,
                 deco.arrow(pos=0.5),
                 deco.arrow(pos=0.7, reversed=1)
             ])

    c.stroke(path(arc(8, 15, 4, 10, 70)),
             [deco.barrow.small, deco.earrow.normal])
    c.stroke(path(arc(8, 15, 3, 10, 70)),
             [deco.barrow.small, deco.earrow.normal])
    c.stroke(path(arc(8, 15, 2, 10, 70)),
             [deco.barrow.small, deco.earrow.normal])
    c.stroke(path(arc(8, 15, 1, 10, 70)),
             [deco.barrow.small, deco.earrow.normal])
    c.stroke(path(arc(8, 15, 0.5, 10, 70)),
             [deco.barrow.small, deco.earrow.normal])

    base = 2

    pal = color.lineargradient_rgb(color.rgb.red, color.rgb.blue)

    c.stroke(
        path(moveto(5, 10), rlineto(5, 0)),
        [  #deco.barrow(size=base/math.sqrt(8)*unit.t_pt, constriction=1),
            deco.earrow.SMall,
            deco.colorgradient(pal),
            deco.text("start", arclenfrombegin=0, angle=90)
        ])
    c.stroke(path(moveto(5, 10.5), rlineto(5, 0)), [
        deco.barrow(size=base / math.sqrt(4) * unit.t_pt, constriction=1),
        deco.earrow.Small,
        deco.colorgradient(pal),
        deco.text("start+1", arclenfrombegin=1, angle=90)
    ])
    c.stroke(path(moveto(5, 11), rlineto(5, 0)), [
        deco.barrow(size=base / math.sqrt(2) * unit.t_pt, constriction=1),
        deco.earrow.small,
        deco.colorgradient(pal),
        deco.text("center", angle=90)
    ])
    c.stroke(path(moveto(5, 11.5), rlineto(5, 0)), [
        deco.barrow(size=base / math.sqrt(1) * unit.t_pt, constriction=1),
        deco.earrow.normal,
        deco.colorgradient(pal),
        deco.text("end-1", arclenfromend=1, angle=90)
    ])
    c.stroke(path(moveto(5, 12), rlineto(5, 0)), [
        deco.barrow(size=base * math.sqrt(2) * unit.t_pt, constriction=1),
        deco.earrow.large,
        deco.text("end", arclenfromend=0, angle=90)
    ])
    c.stroke(path(moveto(5, 12.5), rlineto(5, 0)), [
        deco.barrow(size=base * math.sqrt(4) * unit.t_pt, constriction=1),
        deco.earrow.Large
    ])
    c.stroke(path(moveto(5, 13), rlineto(5, 0)), [
        deco.barrow(size=base * math.sqrt(8) * unit.t_pt, constriction=1),
        deco.earrow.LArge
    ])
    c.stroke(path(moveto(5, 13.5), rlineto(5, 0)), [
        deco.barrow(size=base * math.sqrt(16) * unit.t_pt, constriction=1),
        deco.earrow.LARge
    ])

    lt = style.linewidth.THick

    c.stroke(path(moveto(11, 10), rlineto(5, 0)), [
        lt,
        deco.barrow(size=base / math.sqrt(8) * unit.t_pt, constriction=1),
        deco.earrow.SMall,
        deco.colorgradient(pal, [style.linewidth.THIN])
    ])
    c.stroke(path(moveto(11, 10.5), rlineto(5, 0)), [
        lt,
        deco.barrow(size=base / math.sqrt(4) * unit.t_pt, constriction=1),
        deco.earrow.Small
    ])
    c.stroke(path(moveto(11, 11), rlineto(5, 0)), [
        lt,
        deco.barrow(size=base / math.sqrt(2) * unit.t_pt, constriction=1),
        deco.earrow.small
    ])
    c.stroke(path(moveto(11, 11.5), rlineto(5, 0)), [
        lt,
        deco.barrow(size=base / math.sqrt(1) * unit.t_pt, constriction=1),
        deco.earrow.normal
    ])
    c.stroke(path(moveto(11, 12), rlineto(5, 0)), [
        lt,
        deco.barrow(size=base * math.sqrt(2) * unit.t_pt, constriction=1),
        deco.earrow.large
    ])
    c.stroke(path(moveto(11, 12.5), rlineto(5, 0)), [
        lt,
        deco.barrow(size=base * math.sqrt(4) * unit.t_pt, constriction=1),
        deco.earrow.Large(
            attrs=[deco.stroked([style.linestyle.dashed]), deco.filled.clear])
    ])
    c.stroke(path(moveto(11, 13), rlineto(5, 0)), [
        lt,
        deco.barrow(size=base * math.sqrt(8) * unit.t_pt, constriction=1),
        deco.earrow.LArge(attrs=[style.linestyle.dashed, color.rgb.green])
    ])
    c.stroke(path(moveto(11, 13.5), rlineto(5, 0)), [
        lt,
        deco.barrow(size=base * math.sqrt(16) * unit.t_pt, constriction=1),
        deco.earrow.LARge(attrs=[
            color.rgb.red,
            deco.stroked([style.linejoin.round]),
            deco.filled([color.rgb.blue])
        ])
    ])
Esempio n. 22
0
def testarrow(c):
    c.stroke(path(moveto(10,20),
                curveto(12,16,14,15,12,19),
                rcurveto(-3,2,3,3,-2,4)),
             [deco.barrow.small, deco.earrow.normal,
              deco.arrow(pos=0.5),
              deco.arrow(pos=0.7, reversed=1)])

    c.stroke(path(arc(8,15,4,10,70)), [deco.barrow.small, deco.earrow.normal])
    c.stroke(path(arc(8,15,3,10,70)), [deco.barrow.small, deco.earrow.normal])
    c.stroke(path(arc(8,15,2,10,70)), [deco.barrow.small, deco.earrow.normal])
    c.stroke(path(arc(8,15,1,10,70)), [deco.barrow.small, deco.earrow.normal])
    c.stroke(path(arc(8,15,0.5,10,70)), [deco.barrow.small, deco.earrow.normal])

    base = 2

    pal = color.lineargradient_rgb(color.rgb.red, color.rgb.blue)

    c.stroke(path(moveto(5,10), rlineto(5,0)),
           [#deco.barrow(size=base/math.sqrt(8)*unit.t_pt, constriction=1),
            deco.earrow.SMall,
            deco.colorgradient(pal),
            deco.text("start", arclenfrombegin=0, angle=90)])
    c.stroke(path(moveto(5,10.5), rlineto(5,0)),
           [deco.barrow(size=base/math.sqrt(4)*unit.t_pt, constriction=1),
            deco.earrow.Small,
            deco.colorgradient(pal),
            deco.text("start+1", arclenfrombegin=1, angle=90)])
    c.stroke(path(moveto(5,11), rlineto(5,0)),
           [deco.barrow(size=base/math.sqrt(2)*unit.t_pt, constriction=1),
            deco.earrow.small,
            deco.colorgradient(pal),
            deco.text("center", angle=90)])
    c.stroke(path(moveto(5,11.5), rlineto(5,0)),
           [deco.barrow(size=base/math.sqrt(1)*unit.t_pt, constriction=1),
            deco.earrow.normal,
            deco.colorgradient(pal),
            deco.text("end-1", arclenfromend=1, angle=90)])
    c.stroke(path(moveto(5,12), rlineto(5,0)),
           [deco.barrow(size=base*math.sqrt(2)*unit.t_pt, constriction=1),
            deco.earrow.large,
            deco.text("end", arclenfromend=0, angle=90)])
    c.stroke(path(moveto(5,12.5), rlineto(5,0)),
           [deco.barrow(size=base*math.sqrt(4)*unit.t_pt, constriction=1),
            deco.earrow.Large])
    c.stroke(path(moveto(5,13), rlineto(5,0)),
           [deco.barrow(size=base*math.sqrt(8)*unit.t_pt, constriction=1),
            deco.earrow.LArge])
    c.stroke(path(moveto(5,13.5), rlineto(5,0)),
           [deco.barrow(size=base*math.sqrt(16)*unit.t_pt, constriction=1),
            deco.earrow.LARge])

    lt = style.linewidth.THick

    c.stroke(path(moveto(11,10), rlineto(5,0)),
           [lt,
            deco.barrow(size=base/math.sqrt(8)*unit.t_pt, constriction=1),
            deco.earrow.SMall,
            deco.colorgradient(pal, [style.linewidth.THIN])])
    c.stroke(path(moveto(11,10.5), rlineto(5,0)),
           [lt,
            deco.barrow(size=base/math.sqrt(4)*unit.t_pt, constriction=1),
            deco.earrow.Small])
    c.stroke(path(moveto(11,11), rlineto(5,0)),
           [lt,
            deco.barrow(size=base/math.sqrt(2)*unit.t_pt, constriction=1),
            deco.earrow.small])
    c.stroke(path(moveto(11,11.5), rlineto(5,0)),
           [lt,
            deco.barrow(size=base/math.sqrt(1)*unit.t_pt, constriction=1),
            deco.earrow.normal])
    c.stroke(path(moveto(11,12), rlineto(5,0)),
           [lt,
            deco.barrow(size=base*math.sqrt(2)*unit.t_pt, constriction=1),
            deco.earrow.large])
    c.stroke(path(moveto(11,12.5), rlineto(5,0)),
           [lt,
            deco.barrow(size=base*math.sqrt(4)*unit.t_pt, constriction=1),
            deco.earrow.Large(attrs=[deco.stroked([style.linestyle.dashed]), deco.filled.clear])])
    c.stroke(path(moveto(11,13), rlineto(5,0)),
           [lt,
            deco.barrow(size=base*math.sqrt(8)*unit.t_pt, constriction=1),
            deco.earrow.LArge(attrs=[style.linestyle.dashed, color.rgb.green])])
    c.stroke(path(moveto(11,13.5), rlineto(5,0)),
           [lt,
            deco.barrow(size=base*math.sqrt(16)*unit.t_pt, constriction=1),
            deco.earrow.LARge(attrs=[color.rgb.red,
                                     deco.stroked([style.linejoin.round]),
                                     deco.filled([color.rgb.blue])])])
Esempio n. 23
0
def testcurvetobbox(c):
    drawpathwbbox(c, path(moveto(10, 60), curveto(12, 66, 14, 65, 12, 69)))
Esempio n. 24
0
def testarcbbox(c):
    for phi in range(0, 360, 30):
        drawpathwbbox(c, path(arc(phi * 0.1, phi * 0.1, 1, 0, phi)))

    for phi in range(0, 360, 30):
        drawpathwbbox(c, path(arc(phi * 0.1, 5 + phi * 0.1, 1, phi, 360)))

    for phi in range(0, 360, 30):
        drawpathwbbox(c, path(arc(phi * 0.1, 10 + phi * 0.1, 1, phi,
                                  phi + 30)))

    for phi in range(0, 360, 30):
        drawpathwbbox(c, path(arc(phi * 0.1, 15 + phi * 0.1, 1, phi,
                                  phi + 120)))

    for phi in range(0, 360, 30):
        drawpathwbbox(c, path(arc(phi * 0.1, 20 + phi * 0.1, 1, phi,
                                  phi + 210)))

    for phi in range(0, 360, 30):
        drawpathwbbox(c, path(arc(phi * 0.1, 25 + phi * 0.1, 1, phi,
                                  phi + 300)))

    for phi in range(0, 360, 30):
        drawpathwbbox(c, path(arc(phi * 0.1, 30 + phi * 0.1, 1, phi,
                                  phi + 390)))

    for phi in range(0, 360, 30):
        drawpathwbbox(
            c,
            path(moveto(20 + phi * 0.1, phi * 0.09),
                 arc(20 + phi * 0.1, phi * 0.1, 1, 0, phi)))

    for phi in range(0, 360, 30):
        drawpathwbbox(
            c,
            path(moveto(20 + phi * 0.1, 5 + phi * 0.11),
                 arc(20 + phi * 0.1, 5 + phi * 0.1, 1, 0, phi)))

    for phi in range(0, 360, 30):
        drawpathwbbox(
            c,
            path(moveto(20 + phi * 0.1, 10 + phi * 0.09),
                 arcn(20 + phi * 0.1, 10 + phi * 0.1, 1, 0, phi)))

    for phi in range(0, 360, 30):
        drawpathwbbox(
            c,
            path(moveto(20 + phi * 0.1, 15 + phi * 0.11),
                 arcn(20 + phi * 0.1, 15 + phi * 0.1, 1, 0, phi)))

    for phi in range(0, 360, 30):
        drawpathwbbox(
            c,
            path(moveto(50 + phi * 0.1, phi * 0.09),
                 arc(50 + phi * 0.1, phi * 0.1, 1, 0, phi), rlineto(1, 1)))

    for phi in range(0, 360, 30):
        drawpathwbbox(
            c,
            path(moveto(50 + phi * 0.1, 5 + phi * 0.11),
                 arc(50 + phi * 0.1, 5 + phi * 0.1, 1, 0, phi), rlineto(1, 1)))

    for phi in range(0, 360, 30):
        drawpathwbbox(
            c,
            path(moveto(50 + phi * 0.1, 10 + phi * 0.09),
                 arcn(50 + phi * 0.1, 10 + phi * 0.1, 1, 0, phi),
                 rlineto(1, 1)))

    for phi in range(0, 360, 30):
        drawpathwbbox(
            c,
            path(moveto(50 + phi * 0.1, 15 + phi * 0.11),
                 arcn(50 + phi * 0.1, 15 + phi * 0.1, 1, 0, phi),
                 rlineto(1, 1)))
Esempio n. 25
0
 def testarcn(c, x, y, phi1, phi2):
     p=path(arcn(x,y, 0.5, phi1, phi2))
     np = p.normpath()
     c.stroke(p, [color.rgb.red])
     c.stroke(np, [color.rgb.green, style.linestyle.dashed])
Esempio n. 26
0
 def testarcn(c, x, y, phi1, phi2):
     p = path(arcn(x, y, 0.5, phi1, phi2))
     np = p.normpath()
     c.stroke(p, [color.rgb.red])
     c.stroke(np, [color.rgb.green, style.linestyle.dashed])
Esempio n. 27
0
#!/usr/bin/env python
import sys; sys.path[:0] = ["../.."]

from pyx import *
from pyx.path import *

c=canvas.canvas()

unit.set(uscale=1)
c.stroke(path(moveto(0,0), lineto(unit.u_cm+unit.t_cm, unit.u_cm)), [color.rgb.red])
unit.set(uscale=2)
c.stroke(path(moveto(0,0), lineto(unit.u_cm+unit.t_cm, unit.u_cm)), [color.rgb.green])
unit.set(uscale=4)
c.stroke(path(moveto(0,0), lineto(unit.u_cm+unit.t_cm, unit.u_cm)), [color.rgb.blue])

c.writeEPSfile("test_unit")
c.writePDFfile("test_unit")
c.writeSVGfile("test_unit")

Esempio n. 28
0
 def testarct(c, r, x0, y0, dx1, dy1, dx2, dy2):
     p=path(moveto(x0,y0), arct(x0+dx1,y0+dy1, x0+dx2, y0+dy2, r), rlineto(dx2-dx1, dy2-dy1), closepath())
     np = p.normpath()
     c.stroke(p, [color.rgb.red, style.linewidth.Thick])
     c.stroke(np, [color.rgb.green, style.linewidth.THin, deco.filled([color.rgb.green])])
Esempio n. 29
0
def testtrafobbox(c):
    sc=c.insert(canvas.canvas([trafo.translate(0,40).rotated(10)]))

    p=path(moveto(10,10), curveto(12,16,14,15,12,19));   drawpathwbbox(sc,p)
    p=path(moveto(5,17), curveto(6,18, 5,16, 7,15));     drawpathwbbox(sc,p)
Esempio n. 30
0
def testcurvetobbox(c):
    drawpathwbbox(c,path(moveto(10,60), curveto(12,66,14,65,12,69)))
Esempio n. 31
0
def testarcbbox(c):
    for phi in range(0,360,30):
       drawpathwbbox(c,path(arc(phi*0.1, phi*0.1, 1, 0, phi)))

    for phi in range(0,360,30):
       drawpathwbbox(c,path(arc(phi*0.1, 5+phi*0.1, 1, phi, 360)))

    for phi in range(0,360,30):
       drawpathwbbox(c,path(arc(phi*0.1, 10+phi*0.1, 1, phi, phi+30)))

    for phi in range(0,360,30):
       drawpathwbbox(c,path(arc(phi*0.1, 15+phi*0.1, 1, phi, phi+120)))

    for phi in range(0,360,30):
       drawpathwbbox(c,path(arc(phi*0.1, 20+phi*0.1, 1, phi, phi+210)))

    for phi in range(0,360,30):
       drawpathwbbox(c,path(arc(phi*0.1, 25+phi*0.1, 1, phi, phi+300)))

    for phi in range(0,360,30):
       drawpathwbbox(c,path(arc(phi*0.1, 30+phi*0.1, 1, phi, phi+390)))
       

    for phi in range(0,360,30):
       drawpathwbbox(c,path(moveto(20+phi*0.1, phi*0.09),
                            arc(20+phi*0.1, phi*0.1, 1, 0, phi)))

    for phi in range(0,360,30):
       drawpathwbbox(c,path(moveto(20+phi*0.1, 5+phi*0.11),
                            arc(20+phi*0.1, 5+phi*0.1, 1, 0, phi)))

    for phi in range(0,360,30):
       drawpathwbbox(c,path(moveto(20+phi*0.1, 10+phi*0.09),
                            arcn(20+phi*0.1, 10+phi*0.1, 1, 0, phi)))

    for phi in range(0,360,30):
       drawpathwbbox(c,path(moveto(20+phi*0.1, 15+phi*0.11),
                            arcn(20+phi*0.1, 15+phi*0.1, 1, 0, phi)))

    for phi in range(0,360,30):
       drawpathwbbox(c,path(moveto(50+phi*0.1, phi*0.09),
                            arc(50+phi*0.1, phi*0.1, 1, 0, phi),
                            rlineto(1,1)))

    for phi in range(0,360,30):
       drawpathwbbox(c,path(moveto(50+phi*0.1, 5+phi*0.11),
                            arc(50+phi*0.1, 5+phi*0.1, 1, 0, phi),
                            rlineto(1,1)))

    for phi in range(0,360,30):
       drawpathwbbox(c,path(moveto(50+phi*0.1, 10+phi*0.09),
                            arcn(50+phi*0.1, 10+phi*0.1, 1, 0, phi),
                            rlineto(1,1)))

    for phi in range(0,360,30):
       drawpathwbbox(c,path(moveto(50+phi*0.1, 15+phi*0.11),
                            arcn(50+phi*0.1, 15+phi*0.1, 1, 0, phi),
                            rlineto(1,1)))