From: mathog <mathog@ca...>  20120814 23:02:16

I am looking into adding features to EMF export where it can (optionally) convert dot/dash to line/bezier segments, and can convert gradients into piles of (near) rectangles to approximate gradients. It turns out that most drawing programs make these two conversions automatically when exporting to EMF. The first one can be done now with convert2dashes.py, but that changes the SVG, which isn't the intent, and there is not, I believe, currently an automatic way to do the gradient conversion. Anyway, for the first case what I am looking for is a function that will return {x1,y2} given {x1,y1} on a Bezier and the parameter "d", a length along the Bezier. Is there such a method? (The equivalent for a line is not a problem.) The other conversion looks like it will be fairly tricky, in general. Imagine a gradient at some arbitrary angle that will be approximated by 20 color slices  picture that as a ray extending from the first slice to the last, with the ray perpendicular to the slices. The object that is filled may have a complex geometry (for instance a spiral with 13 turns). The i'th slice would be found by finding a whole bunch of intersections. If that ray has length L, then the front end of the slice would be the intersection of the filled path with the line perpendicular to the ray at offset Li/20 along it. The back end of the slice would be the same at L(i+1)/20. As the spiral case demonstrates, there could be a set of front ends, and a set of back ends, which would need to be paired up, and connected by what would in general by a Bezier segment. In some cases one face or the other of the slice segment could also be a Bezier. Somewhere in Inkscape the code to find these slice pieces already exists: PATH INTERSECTION(filled spiral path, long skinny rectangle that lies over it) reduces to one or more filled paths which make up that slice. Do the same thing N times with a series of slightly overlapping rectangles and the job is basically done. Where in Inkscape are the methods for finding path intersections? Thanks, David Mathog mathog@... Manager, Sequence Analysis Facility, Biology Division, Caltech 