On 10-09-12 17:19, Krzysztof KosiĆski wrote:
2012/9/10 Jasper van de Gronde <th.v.d.gronde@...528...>:
Not really, the way 'z' is interpreted now, Inkscape either has to rely on exact(!) coincidence of the start and end node to hide the fact that there really is another segment, or now and then show an, that users cannot get rid of (and complicates selecting nodes and so on).
I previously wrote this in an accidentally off-list response: the workaround to this problem is to always write out the moveto command that starts a new subpath and the last point of the last segment in absolute coordinates. This way the start and end nodes will always coincide exactly.
There are more esoteric things that can cause slight numerical problems, but that suggestion would indeed solve the vast majority of cases. If anyone wants to beat me to it, in src/svg/path-string.h, around line 133 you should change the closePath method to this:
PathString &closePath() { commonbase += _abs_state.str; _abs_state.str.clear(); _rel_state = _abs_state; _abs_state.appendOp('Z'); _rel_state.appendOp('z'); _rel_state.switches++; _current_point = _initial_point; return *this; }
The path string code basically always tries using both relative and absolute coordinates, and the above says that if we close the path, that we always want to use absolute coordinates for the previous segment. This is obviously suboptimal, but only impacts closed (sub)paths, and is still optimal within the constraint of wanting the last segment before the close path command to use absolute coordinates.
But still, the point is that SVG does have somewhat the ambition of being an "editable" format, thus making it highly desirable to not force such hacks on to an editor.
A better solution would be to allow 'z' not only as a segment, but also in place of the last coordinate. For example: d="M 1,1 ... C 4,3 2,2 z" would be equivalent to "M 1,1 ... C 4,3 2,2 1,1 z".
Indeed. Or, alternatively, one could regard z as being a "lineto" with an implicit end coordinate, and then add similar commands (w, x, y, for example) corresponding to quadratic, cubic and elliptic segments.