Proposals/Path data turtle graphics proposal

It is not trivial to author paths where a specific angle is needed between two adjacent path segments; the author must use trigonometry to compute the desired endpoint of the second path segment. This is not terribly difficult, but if the author wishes to animate the angle between the path segments using declarative animation, then this can only be done by specifying many points for the second path segment over the course of the animation, rather than a single angle value.

with as many animation values as desired to make the endpoint of the second path segment trace out a smooth arc.

Better would be if the angle between the two arc segments could be animated directly.

An initial proposal

At each point in the path, there is a current rotation, which starts off as 0deg. Like SVG transforms, 0deg is horizontal along the positive x axis and 90deg is vertical along the positive y axis. The current rotation for existing (SVG 1.1) path commands is already described for use by orient="auto" markers.

We introduce some new path commands:

R <angle> -- sets the current rotation to the given angle

r <angle> -- sets the current rotation the current rotation plus the given angle

f <length> or F <length> -- straight line from the current point, using the current rotation angle, for the given length

What about other path commands?

If a straight line current-rotation-aware path command is useful, then it seems that the other commands (move, curve, arc) would be too. But do we really want to duplicate all of those commands? Instead, we could consider introducing a modifier that causes the segment to be rotated around the current position by the current rotation.

So n alternative proposal:

We still introduce R and r to change the current rotation.

We introduce a prefix modifier ~ (character subject to bikeshedding) that causes the following command to be rotated.

Thus, to get a straight line forward segment like the f proposal, you would write ~h.

Here, ~h wouldn't be a distinct path command from h. Instead we introduce a Boolean flag on SVGPathSeg (or perhaps each individual interface where ~ is sensible?) that indicates whether the segment is rotated:

interface SVGPathSeg {
...
readonly attribute boolean rotated;
};

Here is a second example.

Without a rotate command, you would need to write the animation like so: