'Path' (entire path) vs. 'subpath' for markers on a start/end vertex of an open subpaths #759
Description
In [1], it is stated:
If the vertex is the start or end of an open subpath, then the marker is oriented in the path direction.
The question is whether the "path direction" here refers to the subpath or the entire path. It appears the result could differ depending on which it is.
Consider the following paths (see [2] for "live" demo):
M10,10v10 m10,0h100M10,40l90,10 m10,0M10,70h100 m10,10v-10M10,100 m10,10
All have multiple (two) subpaths. 1 through 3 all have non-zero length (but 2 has a zero length subpath). 4 is zero length.
For 1 and 3, is the orientation of a marker at the end of the first subpath the same or different? I.e it seems if the "entire path" is used then this ends up in the "segment boundary" case, while for the "subpath" interpretation it would hit the "distance is the length of the path" case.
In 2, since the marker at the end of the first subpath is at the same distance as the marker on the second subpath, if "path direction" is for the entire path, then these two markers would orient the same (using the orientation of the former). If "path direction" is for the subpath in question, they would orient differently.
I included 4 because it seems fairly clear cut (regardless of "entire path" vs "subpath" the path is zero length) - i.e it would end up in the case where the direction would be the "same direction as the positive x-axis". Both Gecko and Blink seems to infer direction based on the "invisible segments" between first the origin and then the points themselves.
Using the "subpath" interpretation seems the more natural to me, but I don't find it entirely clear that this is what the current spec formulation is trying to convey. Gecko seems to mostly follow that interpretation (see note about path 4 above). Blink is currently inferring orientations based on the "invisible segments" between subpaths in some cases which isn't really correct in any interpretation. (I was in the process of fixing some marker issues in Blink when I noticed this issue though, so expect Blink to change to something much closer to the Gecko behavior.)
[1] https://svgwg.org/svg2-draft/painting.html#RenderingMarkers
[2] https://jsfiddle.net/juh3amxc/3/
Activity
AmeliaBR commentedon Dec 3, 2019
To clarfiy: by "invisible segment", you're talking about the implicit close-path used in the fill area?
Or are you talking about the move-to segments?
fsoder commentedon Dec 3, 2019
The "invisible segments" would an imagined (invisible) line drawn from the last point in a subpath to the next move-to (point).
BigBadaboom commentedon Dec 3, 2019
The Path Directionality algorithm doesn't mention moves or subpaths. So "invisible segments" seem valid on that basis. But I agree with Fredrik that it seems a bit unnatural.
Doktorchen commentedon Dec 3, 2019
In the implementation notes (Version 1.1) it is explained, that the directionality is always derived from the subpath.
If this information is missing in the Version 2 draft, it should be added to avoid confusion or incompatibilities.
https://www.w3.org/TR/SVG11/implnote.html#PathElementImplementationNotes
fsoder commentedon Dec 4, 2019
I believe that that sections was supposed to be transplanted to the "Paths" chapter (which it has at least to some degree), but as @BigBadaboom notes, at least the "Path Directionality" section does not appear to use the term at all. Not mentioning it may be fine, if one were to consider it an algorithm of sorts and thus be able to invoke it with a subpath as the argument.
dalboris commentedon Dec 6, 2019
Just copying here what I wrote in #753 , since it applies to marker orientation as well and is very relevant to this thread too.
we could add the following style attribute to control whether the orientation of markers should take into account the "invisible segment" (= "imaginary straight line between subpaths") or not, as well as control the presence or absence of markers.
openpath: the whole path is treated as one open path for marker positioning, regardless of whether there are several subpaths, and whether these subpaths are open or closed. There is one marker-start at the first vertex of the path, one marker-end at the last vertex of the path, and one marker-mid on every other vertex. The orientation of a marker-mid at the start/end of a subpath takes into account the imaginary straight line between subpaths.
closedpath: the whole path is treated as one closed path for marker positioning, regardless of whether there are several subpaths, and whether these subpaths are open or closed. There are no marker-start or marker-end. There is one marker-mid at the first vertex of the path, no marker at all at the last vertex of the path, and one marker-mid on every other vertex. The orientation of a marker-mid at the start/end of a subpath takes into account the imaginary straight line between subpaths.
subpaths: markers are positioned on a per-subpath basis, taking into account whether each subpath is open or closed. That is, open subpaths are individually marked as per the openpath policy, and closed subpaths are individually marked as per the closedpath policy. The orientation of a marker at the start/end of a subpath ignores other subpaths.