length of a path - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: General questions (https://www.gimp-forum.net/Forum-General-questions) +--- Thread: length of a path (/Thread-length-of-a-path) |
length of a path - dinasset - 05-19-2017 Is it possible to know the length of a path? Thanks PS: I've seen there is the possibility to get the list of all strokes components of a path, and the possibiity to get the length of a single stroke. Is there an already written function to get the total length of the path or should I perform a loop to sum up the single lengths of each stroke? RE: length of a path - dinasset - 05-19-2017 I wrote this piece of code, it seems to work. Is it OK? Code: #!/usr/bin/env python RE: length of a path - Ofnuts - 05-19-2017 It would sort of work, but... the last parameter in stroke_get_length is a precision. This is necessary because the length of a Bezier curve cannot be computed directly, it is approximated iteratively until the value doesn't change (within the precision). And when you add imprecise things, the result is even more imprecise. So if you start with one pixel on the strokes you could have several pixels of error on the whole path. Of course, using a very good precision (0.001) is not innocuous, the algorithm iterates more and takes longer (though on modern machine you may hardly notice it) RE: length of a path - dinasset - 05-19-2017 Thanks Ofnuts. I didn't know what to put in that parameter, I'll change to 0.001 RE: length of a path - Ofnuts - 05-19-2017 Don't over do it, .001 requires roughly 2000x the computations of 1. .1 or .01 are likely enough. RE: length of a path - dinasset - 05-20-2017 Thanks, I'll do it. |