I'm now in the process of optimising and
documenting my Inkscape extensions that implement the International Orienteering
Federation mapping standards. There are some areas of the extensions that
I would like to improve to make them more universal / intuitive.
1) Currently, a number of my routines apply
formatting and patterns of tags or dots to paths (strokes). I would like
to extend the routines to also be compatible with rectangles and arcs /
ellipses. I assume that the routines to do most of what I want already
exist in one or other of the 'helper' files like cubicsuperpath, pathmodifier
and simpletransform, but as yet I've not worked out how to make them work for
me. I need to understand how to implement the following from
within a Python extension:
a) Convert a rectangle to
a path. Will rectToPath in
pathmodifier do this and, if so, what do I need to provide for self amd
node?
b) Convert an arc/ellipse
to a path. Will ArcToPath in cubicsuperpath do this and,
if so, what do I need to provide for p1 and params?
2) I also need to understand how to apply a
transform to a path (i.e. embed the transformation into the path so the
transform is not required) so that effects applied to a heavil
transformed path (as can happen when using ellipses / arcs) are applied
correctly. Will one of the routines in simpletransform do what I want and,
if so, which one and what would I need to supply to it?
3) I still need to provide the
capability via an extension to convert a line into two lines of a given line
width and a set distance apart. This will need to work with curved
paths, both open and closed. The way that I would do this manually in
Inkscape would be to create a stroke, duplicate it, set the widths of the two
strokes such that the lower is the width of the two lines plus the gap and the
upper is the width of the gap, convert both strokes to paths using Path - Stroke to Path and then to use the
Path - Difference function to leave two
lines of the required width and separation. How could I go about
recreating this from within a extension? Is there an easier method to
do this, given that the two lines should not be joined at the ends?
Still outstanding from a previous request are a couple of
unanswered questions (rephrased):
4) Ho would I go about detecting
whether a point lies within the bounds of a closed shape passed to a Python
extension? Is there an existing routine in one of the Python
extension 'helper' files that can do this?
5) How would I go about
implementing a method to detect collision / distance between dots from
within an extension? I'd like to implement something similar to the
'Remove Overlaps' capability available within the 'Align and Distribute' dialog
as part of the routine generating the dots, but with a single (polar - sqrt(x^2
* y^2)) variable related to the user-selected dot density determining how
close the dots can be placed to each other. I can see that this could get
complex when the area, and hence the number of dots, gets large.
With regard to these last two, I believe there may be
something possible using py2geom, but where do I find details of this?
What are its capabilities and are they documented anywhere?
-----
Jon