Example #1
0
    def path_SER(cls,
                 ha=-30,
                 tn=1.5,
                 ta=-140,
                 d=-60,
                 dz=P(0, 0),
                 before=None,
                 after=None):
        if before:
            if before.tail_type == 'NER':
                ha = 0
                tn = 1.5
                d = -60

        if after:
            if after.head_type in {'SWR', 'S', 'SR', 'SE'}:
                ta = 160
            elif after.head_type == 'SW':
                ta = after.head_angle
            elif after.head_type in {'NER'}:
                ta = -120
            elif after.head_type in {'SEL', 'N'}:
                ta = -90
            elif before and before.tail_type == 'NER':
                ta = -90

        return path([
            beginknot(0, 0, angle=ha),
            tensioncurve(tn),
            endknot(*(PP(16, d) + dz), angle=ta)
        ])
Example #2
0
def mypath(knots): # <<<
    p = path.path(path.moveto_pt(knots.x_pt, knots.y_pt))
    cx, cy = knots.rx_pt, knots.ry_pt
    prev = knots
    k = knots.next
    while not k is knots:
        p.append(path.curveto_pt(cx, cy, k.lx_pt, k.ly_pt, k.x_pt, k.y_pt))
        cx, cy = k.rx_pt, k.ry_pt
        prev = k
        k = k.next
    if knots.ltype == mp_explicit:
        p.append(path.curveto_pt(prev.rx_pt, prev.ry_pt, knots.lx_pt, knots.ly_pt, knots.x_pt, knots.y_pt))
        p.append(path.closepath())
    return p
Example #3
0
    def path_NER(cls,
                 ha=70,
                 tn=1.7,
                 ta=0,
                 d=45,
                 dz=P(0, 0),
                 before=None,
                 after=None):
        if before:
            if before.tail_type == 'SWR':
                ha = 50
                d = 35
            #elif before.tail_type == 'NW|SWCR1':
            #    ha = 40
            #    d = 30
            #elif before.tail_type == 'SW':
            #    ha = before_tail_angle + 170
            #    d = 30
            elif before.tail_type in {'SR'}:
                ha = 50
                d = 30
                dz = P(1, 0)
            #else:
            #    ha = 70
            #    d = 40

        if after:
            if after.head_type in {'E', 'ER', 'NE', 'NER'}:
                ta = -80
                d = 35
            elif after.head_type in {'S', 'SW', 'SWR', 'SR', 'NEL'}:
                ta = after.head_angle
            elif after.head_type in {'SER'}:
                ha = 90
                ta = 0
                tn = 1.5
                d = 60
            elif after.head_type in {'NEL|SWR'}:
                tn = 1.5
                td = -40
            #else:
            #    tn = 1.1
            #    td = 0

        return path([
            beginknot(0, 0, angle=ha),
            tensioncurve(tn),
            endknot(*(PP(16, d) + dz), angle=ta)
        ])
Example #4
0
def mypath(knots):  # <<<
    p = path.path(path.moveto_pt(knots.x_pt, knots.y_pt))
    cx, cy = knots.rx_pt, knots.ry_pt
    prev = knots
    k = knots.next
    while not k is knots:
        p.append(path.curveto_pt(cx, cy, k.lx_pt, k.ly_pt, k.x_pt, k.y_pt))
        cx, cy = k.rx_pt, k.ry_pt
        prev = k
        k = k.next
    if knots.ltype == mp_explicit:
        p.append(
            path.curveto_pt(prev.rx_pt, prev.ry_pt, knots.lx_pt, knots.ly_pt,
                            knots.x_pt, knots.y_pt))
        p.append(path.closepath())
    return p
Example #5
0
def interface():  # <<<
    c = None

    for p in [
            # ordinary open path:
            mppath.path([
                beginknot(0, 0),
                curve(),
                knot(6, 4),
                curve(),
                knot(4, 9),
                curve(),
                knot(1, 7),
                curve(),
                endknot(3, 5)
            ], epsilon),
            # path containing two open subpaths:
            mppath.path([
                beginknot(0, 0),
                curve(),
                endknot(6, 4),
                beginknot(4, 9),
                curve(),
                knot(1, 7),
                curve(),
                endknot(3, 5)
            ], epsilon),
            # closed path:
            mppath.path([
                knot(0, 0),
                curve(),
                knot(6, 4),
                curve(),
                knot(4, 9),
                curve(),
                knot(1, 7),
                curve(),
                knot(3, 5),
                curve()
            ], epsilon),
            # open path, but with endpoints in the middle:
            mppath.path([
                knot(0, 0),
                curve(),
                knot(6, 4),
                curve(),
                endknot(4, 9),
                beginknot(1, 7),
                curve(),
                knot(3, 5),
                curve()
            ], epsilon),
            # the same path in the right order
            mppath.path([
                beginknot(1, 7),
                curve(),
                knot(3, 5),
                curve(),
                knot(0, 0),
                curve(),
                knot(6, 4),
                curve(),
                endknot(4, 9)
            ], epsilon),
            # include a line
            mppath.path([
                knot(0, 0),
                curve(),
                knot(6, 4),
                curve(),
                roughknot(4, 9),
                line(),
                roughknot(1, 7),
                curve(),
                knot(3, 5),
                curve()
            ], epsilon),
            # XXX the endpoints have "open" at their other sides, not "curl" as in the open example above
            mppath.path([
                knot(0, 0),
                curve(),
                knot(6, 4),
                curve(),
                knot(4, 9),
                line(),
                knot(1, 7),
                curve(),
                knot(3, 5),
                curve()
            ], epsilon),
            mppath.path(
                [knot(0, 0),
                 curve(),
                 knot(6, 4),
                 line(),
                 knot(3, 5),
                 curve()], epsilon),
            mppath.path([
                knot(0, 0),
                curve(),
                knot(6, 4),
                curve(),
                knot(3, 5),
                curve()
            ], epsilon),
            # TODO the internal mp_make_choices treats this as closed, but the last curve is not plotted:
            mppath.path([
                knot(0, 0),
                curve(),
                knot(6, 4),
                curve(),
                knot(4, 9),
                line(),
                knot(1, 7),
                curve(),
                knot(3, 5)
            ], epsilon),
            # include a line with given angles
            mppath.path([
                knot(0, 0),
                curve(),
                knot(6, 4),
                curve(),
                knot(4, 9),
                line(keepangles=True),
                knot(1, 7),
                curve(),
                knot(3, 5),
                curve()
            ], epsilon),
            # include rough knots
            mppath.path([
                beginknot(0, 0),
                curve(),
                roughknot(6, 4, langle=90),
                curve(),
                roughknot(4, 9, langle=-90),
                line(keepangles=True),
                roughknot(1, 7, lcurl=3),
                curve(),
                endknot(3, 5, angle=0)
            ], epsilon),
    ]:
        cc = canvas.canvas()
        cc.stroke(p, [deco.shownormpath(), deco.earrow.normal])
        if c is None:
            c = cc
        else:
            c.insert(cc, [
                trafo.translate(c.bbox().right() - cc.bbox().left() + 0.5, 0)
            ])
    c.writePDFfile()
    c.writeEPSfile()
    c.writeSVGfile()
Example #6
0
 def path_template(cls, ta=90, tn=2.5):
     return path([
         beginknot(0, 0, angle=-13),
         tensioncurve(tn),
         endknot(16, 0, angle=ta)
     ])
Example #7
0
 def path_template(cls, ta=80, tn=1.7):
     return path([
         beginknot(0, 0, angle=-18),
         tensioncurve(tn),
         endknot(8, 0, angle=ta)
     ])
Example #8
0
def interface(): # <<<
    c = None

    for p in [
      # ordinary open path:
      mppath.path([beginknot(0,0), curve(), knot(6,4), curve(), knot(4,9), curve(), knot(1,7), curve(), endknot(3,5)], epsilon),
      # path containing two open subpaths:
      mppath.path([beginknot(0,0), curve(), endknot(6,4), beginknot(4,9), curve(), knot(1,7), curve(), endknot(3,5)], epsilon),
      # closed path:
      mppath.path([knot(0,0), curve(), knot(6,4), curve(), knot(4,9), curve(), knot(1,7), curve(), knot(3,5), curve()], epsilon),
      # open path, but with endpoints in the middle:
      mppath.path([knot(0,0), curve(), knot(6,4), curve(), endknot(4,9), beginknot(1,7), curve(), knot(3,5), curve()], epsilon),
      # the same path in the right order
      mppath.path([beginknot(1,7), curve(), knot(3,5), curve(), knot(0,0), curve(), knot(6,4), curve(), endknot(4,9)], epsilon),
      # include a line
      mppath.path([knot(0,0), curve(), knot(6,4), curve(), roughknot(4,9), line(), roughknot(1,7), curve(), knot(3,5), curve()], epsilon),
      # XXX the endpoints have "open" at their other sides, not "curl" as in the open example above
      mppath.path([knot(0,0), curve(), knot(6,4), curve(), knot(4,9), line(), knot(1,7), curve(), knot(3,5), curve()], epsilon),
      mppath.path([knot(0,0), curve(), knot(6,4), line(), knot(3,5), curve()], epsilon),
      mppath.path([knot(0,0), curve(), knot(6,4), curve(), knot(3,5), curve()], epsilon),
      # TODO the internal mp_make_choices treats this as closed, but the last curve is not plotted:
      mppath.path([knot(0,0), curve(), knot(6,4), curve(), knot(4,9), line(), knot(1,7), curve(), knot(3,5)], epsilon),
      # include a line with given angles
      mppath.path([knot(0,0), curve(), knot(6,4), curve(), knot(4,9), line(keepangles=True), knot(1,7), curve(), knot(3,5), curve()], epsilon),
      # include rough knots
      mppath.path([beginknot(0,0), curve(), roughknot(6,4,langle=90), curve(), roughknot(4,9,langle=-90),
            line(keepangles=True), roughknot(1,7,lcurl=3), curve(), endknot(3,5,angle=0)], epsilon),
    ]:
        cc = canvas.canvas()
        cc.stroke(p, [deco.shownormpath(), deco.earrow.normal])
        if c is None:
            c = cc
        else:
            c.insert(cc, [trafo.translate(c.bbox().right() - cc.bbox().left() + 0.5, 0)])
    c.writePDFfile()
    c.writeEPSfile()
    c.writeSVGfile()
Example #9
0
 def path_EL(cls, ta=80):
     return path([
         beginknot(0, 0, angle=-28),
         tensioncurve(1.2),
         endknot(4, 0, angle=ta)
     ])
Example #10
0
 def path_SELnel(cls, ha=-90, tn=1.5, ta=0):
     return path([
         beginknot(0, 0, angle=ha),
         tensioncurve(tn),
         endknot(*PP(16, -60), angle=ta)
     ])
Example #11
0
 def path_SEL(cls, ha=-90, tn=0.88, ta=0, d=-60, sellen=16, dz=P(0, 0)):
     return path([
         beginknot(0, 0, angle=ha),
         tensioncurve(tn),
         endknot(*(PP(sellen, d) + dz), angle=ta)
     ])