-----Original Message----- From: Hans Meine [mailto:hans_meine@...240...] Sent: Thursday, January 07, 2010 21:24 To: inkscape-devel@lists.sourceforge.net Subject: [Inkscape-devel] Programming python extensions (not onlypathscatter)
Hi again,
looking at pathscatter.py, I got some questions concerning the programming of (path-modifying) python extensions:
- Is it possible to use more or less the same code in a
standalone script? And/or what is your preferred way of developing extensions, i.e. reload the module etc.?
- The code seems to use many helper functions from modules
in the "extensions" directory, for example in the "bezmisc" module. I was surprised to see that they are all based on pure Python. Wouldn't it be more convenient and efficient to have (more of) inkscapes C routines available? (For instance, there must already be code for beziers, for computing point/slope at t, converting to parameter form etc.)
- Along the same lines: The code (e.g. in bezmisc) does not
seem to make use of any special classes, but handle point-by-point as coordinate pairs. AFAICS it would be much more efficient to at least make use of numpy, e.g. for polygonal coordinate data.
- Is it possible to query the length of a path? Actually, I
have searched for this functionality already in the GUI itself, but could not find it. Did I overlook something? For pathscatter, it could be useful to preview the number of copies that would fit along the path, for instance.
You could try using lib2geom's python library, although it is still in alpha phase. http://wiki.inkscape.org/wiki/index.php/Lib2geom_py2geom Inkscape uses lib2geom to do a lot of the path operations. Because py2geom is still in alpha, we have not converted any extension to use it. But I am very sure that the lib2geom team would welcome anybody using py2geom warmly, and will try to give support (including modifying/expanding py2geom).
Cheers, Johan