Yes, having a real hard time with the open paths; looks like there is bug in in Gimp.
If you are using 'gimp-vectors-bezier-stroke-lineto', be aware that it adds the line to the beginning of the stroke.
Exactly... this is something I don't understand... why is it working that way?
The reason it works that way is because the path is stored in a "linked list". This means that for each point in the path, there is a data object which contains not just the point's information (for example, its control handles and anchor coordinates) but also a pointer to the next point in the path. This way, the computer only has to remember the memory location of the most recently added point (for example, in a variable named "listhead"); it can retrieve other points by following the links from one point to the next.
Now when you add a new entry to linked list, you can either add it to the beginning of the list or to its end (well, you could
insert it to some arbitrary location in the list, but let's ignore that). To add an entry to beginning of a list, you just have to create a new object (by allocating some memory), set its pointer field to point to the original beginning of the list (the contents of "listhead"), and then update "listhead" to point to the new object.
However, to add a new entry to the end
of a list, you must first walk along the entire length of the list, following the link from the first point ("listhead") to the second, from the second to third,... until you reach the end of the list. You then can allocate some memory for a new object, set its pointer field to indicate "end of the list", and change the pointer field of the list's last object (the one you "walked" to) to point to the new object.
There are three main reasons that placing new entries at the beginning of a list is advantageous. First, it operates in fixed amount of time because regardless how long the list, it will always take the same number of steps to execute. Second, it takes less time since there is no need to visit every item in the list in order to reach the last one. And third, adding a new entry doesn't modify the existing list at all (this if often a useful feature, but doesn't really matter for GIMP paths).
One could overcome the first two limitations of appending to the end of a list by maintaining a second variable (for example, "listtail") which always points to the end of the list. But I'm guessing the GIMP developers just didn't feel it was worth implementing this functionality. The net result though, is that the most recently added point is always the "first" point in the path (the first point you added is the last point in the path).
Should I add the points directly?
I'm not quite sure what you mean, but if you are referring to using 'gimp-vectors-stroke-new-from-points' to create your new path all at once as opposed to iteratively (using "gimp-vectors-bezier-*" functions), the choice is yours. In my Platonic calendar Script-fu
, I chose to write a function that reverses the order of a path after it was created, but that was mainly because I had already implemented creating my paths before finding out some of them went in the wrong direction.