Correcting myself:

Michael J Gruber venit, vidit, dixit 2006-04-03 11:51:
...
> In your original code snippet, note that text.text() returns a canvas

It returns a "textbox", which is why you can use it for the connector
module. [ Note: It might be best to derive a class canvasbox from
box.rect and canvas._canvas. Is something like this in the pipeline?
Would be a quicker (read: sooner) solution than boxifying all of PyX. ]

>  whereas path.circle() returns a path. Stroke the path on a canvas
> and go from there.

Actually, already a path has a bbox() method. So, the full modified
connector example would be as follows.

Cheers,
Michael

from pyx import *

c = canvas.canvas()
unit.set(uscale=3)

textattrs = [text.halign.center, text.vshift.middlezero]
A = text.text(0, 0, r"\bf A", textattrs)
B = text.text(1, 0, r"\bf B", textattrs)
C = text.text(1, 1, r"\bf C", textattrs)
#D = text.text(0, 1, r"\bf D", textattrs)
p = path.circle(0,1,0.2)
bb = p.bbox()
D = box.rect(bb.left(), bb.bottom(), bb.width(), bb.height())

for X in [A, B, C, D]:
    c.draw(X.bbox().enlarged(0.1).path(),
        [deco.stroked(), deco.filled([color.grey(0.85)])])
    if X is D:
        c.stroke(p)
    else:
        c.insert(X)

for X,Y in [[A, B], [B, C], [C, D], [D, A]]:
    c.stroke(connector.arc(X, Y, boxdists=0.2), [color.rgb.red,
deco.earrow.normal])

c.stroke(connector.curve(D, B, boxdists=0.2, relangle1=45,
relangle2=-45, relbulge=0.8),
         [color.rgb.blue, deco.earrow.normal])

c.writeEPSfile(__file__[:-3])


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
PyX-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyx-user

Reply via email to