From: Alan G I. <ai...@am...> - 2005-09-22 21:59:12
|
OK, this basically works. Thanks, Alan from pyx import * text.reset() text.set(mode=3D'latex') #unit.set(uscale=3D2) unit.set(defaultunit=3D'cm') class Node: =09def __init__(self, canvas, x, y, label, radius=3D0.25*unit.t_cm): =09=09self.box =3D canvas.text(x, y, label,[ text.halign.center, =09=09=09=09=09=09 text.valign.middle]) =09=09canvas.stroke(path.circle(x, y, radius)) =09=09self.radius =3D radius =09=09self.x =3D x =09=09self.y =3D y =09=09# XXX Bogus null-box for use with connectors: =09=09# self.center =3D box.rect(x, y, 0, 0) class Edge: =09def __init__(self, canvas, source, target, *args, **kwds): =09=09connclass =3D kwds.get('connclass', connector.line) =09=09self.source =3D source =09=09self.target =3D target =09=09self.conn =3D connclass(source.box, target.box, =09=09=09=09=09=09=09 # XXX Add half the width of the circle =09=09=09=09=09=09=09 # path: =09=09=09=09=09=09=09 boxdists=3D[source.radius, target.radius]) =09=09canvas.stroke(self.conn, *args) def drawNodes(canvas): =09A =3D Node(c, 0, 1, '$a$') =09B =3D Node(c, 0, 0, '$b$') =09T =3D Node(c, 1, 1, '$t$') =09C =3D Node(c, 1, 0, '$c$') =09return A, B, T, C c =3D canvas.canvas() A, B, T, C =3D drawNodes(c) for X, Y in [[A, T], [A, C], [B, C]]: =09Edge(c, X, Y, [style.linestyle.dashed, =09=09 #deco.earrow.normal(style.linestyle.solid)) =09=09 deco.earrow.normal([deco.stroked.clear])]) c.writeEPSfile('c:/temp/temp.eps') |