## Re: [PyX-user] Pathitems questions

 Re: [PyX-user] Pathitems questions From: William Henney - 2006-10-29 16:21:40 ```On 10/29/06, William Henney wrote: > > Just a last one: > > I really need to implement MetaPost-like B=E9zier curves, "z0..z1" draw= s a > > B=E9zier curve from z0 to z1 without having to calculate the control > > points. Is there something similar in PyX and if not, where to find any > > reference ? > > As far as I know, there is nothing built in to PyX for doing this. It > would be great if there were! > > If you want to implement this yourself, then the wikipedia article > looks like a reasonable general introduction > (http://en.wikipedia.org/wiki/B%C3%A9zier_curve). The way metapost > does it seems to be reasonably well documented - see > http://www.tlhiv.org/MetaPost/documentation/, particularly > Metapost_Curves.pdf > I just found a better reference. This is John Hobby's original paper from 1985 on the algorithm that got used in metapost: ftp://db.stanford.edu/pub/cstr/reports/cs/tr/85/1047/CS-TR-85-1047.pdf You also might want to look at how this is done in asymptote (http://asymptote.sourceforge.net). They seem to have reimplemented Hobby's algorithm and also have generalized it to be invariant under 3D transformations. Cheers Will --=20 Dr William Henney, Centro de Radioastronom=EDa y Astrof=EDsica, Universidad Nacional Aut=F3noma de M=E9xico, Campus Morelia ```

 [PyX-user] Pathitems questions From: kib2 - 2006-10-28 09:24:37 ```Hi, I wanted to know if I can retrieve all the pathitems of a path class=20 instance. Another question : what is the meaning of the "*" in Python syntax (like=20 in class path(*pathitems)) ? Thanks, Kib=B2 ```
 [PyX-user] Fwd: Pathitems questions From: William Henney - 2006-10-28 18:37:29 ```I originally sent this from an unsubscibed mail address, so it will probably have been stopped by the new spam filters. Apologies if it shows up twice. Will ---------- Forwarded message ---------- From: William Henney Date: Oct 28, 2006 1:32 PM Subject: Re: [PyX-user] Pathitems questions To: kib2 Cc: pyx-user@... Hi Kib2 On 10/28/06, kib2 wrote: > I wanted to know if I can retrieve all the pathitems of a path class > instance. Have you tried the pathitems instance variable. As in p =3D pyx.path.rect(0, 0, 1, 1) print p.pathitems which gives the output [, , , , ] > Another question : what is the meaning of the "*" in Python syntax (like > in class path(*pathitems)) ? *args is just a notation for a list of arguments of arbitrary length. For example: ################### def f(*args): for i in range(len(args)): print "Argument #%i is %s" % (i+1, args[i]) print "" f(100, 200) f("a", "b", "c") f("one", "two", 99, -1) #################### will print out Argument #1 is 100 Argument #2 is 200 Argument #1 is a Argument #2 is b Argument #3 is c Argument #1 is one Argument #2 is two Argument #3 is 99 Argument #4 is -1 In other words, you can call path with as many pathitem arguments as you li= ke. Hope this helps Will P.S. You might want to try out some of the books listed at http://wiki.python.org/moin/IntroductoryBooks Several are freely available online. -- Dr William Henney, Centro de Radioastronom=EDa y Astrof=EDsica, Universidad Nacional Aut=F3noma de M=E9xico, Campus Morelia --=20 Dr William Henney, Centro de Radioastronom=EDa y Astrof=EDsica, Universidad Nacional Aut=F3noma de M=E9xico, Campus Morelia ```
 Re: [PyX-user] Pathitems questions From: William Henney - 2006-10-29 15:48:02 ```Hi Kib2 I'm CCing back to the list - hope this is OK. > > On 10/28/06, kib2 wrote: > >> I wanted to know if I can retrieve all the pathitems of a path class > >> instance. > > > > Have you tried the pathitems instance variable. As in > > > > p =3D pyx.path.rect(0, 0, 1, 1) > > print p.pathitems > > > > which gives the output > Thanks, it was so easy...I had a look at the docs in PyX's online > manual, but couldn't find the pathitems method in the path module. It isn't a method - it is just a variable. You are right that it doesn't seem to be mentioned in the docs. I don't know if this was just an oversight, or if it is because it is not supposed to be part of the public API. Could the developers comment on this? The way I found out about it was using the "?" feature in IPython, which is an interactive python interpreter. [snip] > Just a last one: > I really need to implement MetaPost-like B=E9zier curves, "z0..z1" draws = a > B=E9zier curve from z0 to z1 without having to calculate the control > points. Is there something similar in PyX and if not, where to find any > reference ? As far as I know, there is nothing built in to PyX for doing this. It would be great if there were! If you want to implement this yourself, then the wikipedia article looks like a reasonable general introduction (http://en.wikipedia.org/wiki/B%C3%A9zier_curve). The way metapost does it seems to be reasonably well documented - see http://www.tlhiv.org/MetaPost/documentation/, particularly Metapost_Curves.pdf Cheers Will --=20 Dr William Henney, Centro de Radioastronom=EDa y Astrof=EDsica, Universidad Nacional Aut=F3noma de M=E9xico, Campus Morelia ```
 Re: [PyX-user] Pathitems questions From: William Henney - 2006-10-29 16:21:40 ```On 10/29/06, William Henney wrote: > > Just a last one: > > I really need to implement MetaPost-like B=E9zier curves, "z0..z1" draw= s a > > B=E9zier curve from z0 to z1 without having to calculate the control > > points. Is there something similar in PyX and if not, where to find any > > reference ? > > As far as I know, there is nothing built in to PyX for doing this. It > would be great if there were! > > If you want to implement this yourself, then the wikipedia article > looks like a reasonable general introduction > (http://en.wikipedia.org/wiki/B%C3%A9zier_curve). The way metapost > does it seems to be reasonably well documented - see > http://www.tlhiv.org/MetaPost/documentation/, particularly > Metapost_Curves.pdf > I just found a better reference. This is John Hobby's original paper from 1985 on the algorithm that got used in metapost: ftp://db.stanford.edu/pub/cstr/reports/cs/tr/85/1047/CS-TR-85-1047.pdf You also might want to look at how this is done in asymptote (http://asymptote.sourceforge.net). They seem to have reimplemented Hobby's algorithm and also have generalized it to be invariant under 3D transformations. Cheers Will --=20 Dr William Henney, Centro de Radioastronom=EDa y Astrof=EDsica, Universidad Nacional Aut=F3noma de M=E9xico, Campus Morelia ```
 Re: [PyX-user] Pathitems questions From: William Henney - 2006-10-29 22:49:52 ```Hi Christophe > Thanks a lot for these ones, the Hobby's article is really worth a look, > even if it seems complicated to do what I wanted. > I just looked at the Asymptote sources, but I'm not a C++ expert, so > I'll ask you in which file to look at exactly ? Glad you found them useful. I don't really know C++ either. Perhaps you could ask the asymptote developers. > I started a geometry package with PyX, maybe some of you could be > interested...(not updated, but I could do it on your request): > h**p://kib2.webfactional.com/projets/ Looks interesting. I found the sources at http://kib2.free.fr/geoPyX/sources/. Unfortunately, I don't have the time to look into it in much detail right now. One thing I noticed is that you import a lot of PyX's classes and functions into your own namespace: from pyx.path import line, curve, rect, circle, path, pathitem, moveto, lineto, \ rmoveto, rlineto, curveto, rcurveto, closepath, \ arc, arcn, arct, moveto_pt, lineto_pt from pyx.graph import style from pyx.graph.style import symbol from pyx import text, canvas from pyx.text import mathmode, valign, halign, vshift, texrunner from pyx.trafo import trafo, mirror, rotate, scale, slant, translate from pyx.color import gray, grey, rgb, hsb, cmyk from pyx.deco import stroked, filled, barrow, earrow from pyx.style import linewidth, linestyle, linejoin from pyx.pattern import hatched0, hatched45, hatched90, hatched135 from pyx.unit import topt, tocm from pyx import unit from pyx.canvas import clip This is probably a bad idea for any but the simplest of programs. The "recommended" thing to do is just import pyx which forces you to fully qualify everything (e.g., pyx.canvas,canvas()). Admittedly, this style is more verbose, but it makes the source easier to understand and means that you won't have namespace collision problems, such a you mention on your web page with "circle". Cheers Will --=20 Dr William Henney, Centro de Radioastronom=EDa y Astrof=EDsica, Universidad Nacional Aut=F3noma de M=E9xico, Campus Morelia ```
 Re: [PyX-user] Pathitems questions From: Alan G Isaac - 2006-10-30 15:25:18 ```On Sun, 29 Oct 2006, Christoph apparently wrote: > http://kib2.free.fr/geoPyX 1. I agree with William about the best way to avoid namespace collision. 2. Did you really think about the license before picking it? Most "academic" software, including yours, is IMO best served by the MIT license. If you are concerned that this is a "derivative work" well IANAL but I do not think so http://www4.law.cornell.edu/uscode/17/101.html (and such complicated considerations again highlight the clean simplicity of the MIT license) 3. Putting the download link at the top of your page would be helpful. Cheers, Alan Isaac ```
 Re: [PyX-user] Pathitems questions From: Joerg Lehmann - 2006-11-02 12:44:19 ```Hello Alan, On 30.10.06, Alan G Isaac wrote: > On Sun, 29 Oct 2006, Christoph apparently wrote: > > http://kib2.free.fr/geoPyX > 2. Did you really think about the license before > picking it? Most "academic" software, including yours, is > IMO best served by the MIT license. > > If you are concerned that this is a "derivative > work" well IANAL but I do not think so > http://www4.law.cornell.edu/uscode/17/101.html (and > such complicated considerations again highlight the > clean simplicity of the MIT license) IANAL neither, but just to make this point clear: If a module using PyX, which is licensed under the GPL, is considered to be a derivative work, then it can only be distributed and/or if it is published free of charge under the terms of the GPL. [1] Now the question whether a work is a derivative work or not can be a rather subtle one. The most prominent example in the context of the GPL is arguably the case of binary-only Linux kernel modules. The opinions as to whether they are allowed according to the GPL or not strongly differ. So I really do not want to start a discussion on the question whether modules using PyX are derivative works, but I can only recommend anybody who wants to be on the safe side to license work using PyX under the GPL. Alternatively, one can obtain PyX under a proprietary license from the authors. [2] Jörg [1] Sect. 2 of the GNU General Public license. [2] http://pyx.sourceforge.net/license.html ```