Closed ewilligers closed 6 years ago
In the very early days of SVG, I briefly argued that paths should all be non-uniform rational basis splines (NURBS) because that would give us two desirable properties - perspective transforms on the points were the same as perspective transforms on the curves, and two NURBS of arbitrary length could be smoothly interpolated. The downside being that everything, even a line segment, is expressed as a curve. At the time we had only affine transformations, and the early drafts of SVG only allowed animation via script, so compatibility with the cubic and quadratic beziers universally used in industry-standard applications won the day. Probably the right decision at the time, but here we are trying so solve the arbitrary lath interpolation problem a couple of decades later.
I agree that when comparing two d
attrs for interpolatability, we should unify exact equivalents (Q & T, C & S, H & L & V) and not unify approximate equivalents (A and QTCS and R). The easiest way to do that is to define a canonical form of a d
attr. The promotions you mention all seem reasonable to me; do they then get reflected back into the DOM or are this hidden, animation-time changes only?
Animation of offset-path sounds great. Happy to see this.
Also glad to see you will contribute tests to WPT for those changes - please let me know if you need a review.
The Working Group just discussed offset-path strings
, and agreed to the following resolutions:
RESOLVED: Computed-value normalize case of path commands (to the absolute version).
RESOLVED: Figure out details on normalizing similar commands into more general ones.
B should be preserved, I think. Animating between B 0 H 100
and B 90 H 100
gives dramatically different results if you do or don't normalize away the Bs. If you keep the Bs, you get a circular sweep, with a length-100 line turning thru 90 degrees. If you normalize them away (to L 100 0
and L 0 100
, I think), you get a line where the endpoint goes straight from the start to finish, and the line changes length from 100 to ~71 back to 100 at the end.
In real-world use-cases, B is extraordinarily useful for rotating a path - rather than screwing around with transforms, you can just define the path once, then prepend a B to put it at the angle you want. This also helps a lot when a particular path segment uses easy-to-define numbers when axis-aligned, but requires trig to figure out the endpoints when rotated - instead, just do it axis-aligned and prepend a B. In both of these situations, normalizing away the B would look pretty bad.
This is shipping in Chrome 64.
SVG Background
Spec:
SMIL implementations have ignored case when comparing path data commands, but have treated H/L/V as distinct line commands, Q/T as distinct quadratic Bezier types and C/S as distinct cubic Bezier types.
Blink shipped CSS animation of the 'd' presentation attribute with this same behavior. The shipped syntax is
none | path(<string>)
which matches offset-path and matched the spec at the time of implementation (but not shipping as I didn't realize the spec was being changed - SVG #320).offset-path
The motion-path property: was not animatable, but the offset-path property is animatable, and Blink would like to ship animation (Intent).
More general interpolation
During the Intent conversation, there were suggestions for more general interpolation, between the different line commands, and between lines and splines. There was also the suggestion that the serialization format be specified. I brought this conversation across to SVG #321 and consensus has been reached.
The outcome: animation will be supported between lines and splines, but not between arcs and other command types. Quadratic splines will be promoted as needed to cubic splines. Lines will be promoted as needed to quadratic and cubic splines.
Blink will contribute web platform tests for offset-path path string animation and ray animation. (Tests for animation of the other offset properties have already been contributed. Implementation of basic shapes has begun in a polyfill but not yet in Blink.)
Blink's implementation of SMIL path animation won't change at this time.
However, 'd' presentation attribute animation will change: the CSS path animation implementation will be common for d and offset-path.
Serialization format
The serialization format will use absolute commands: e.g. nothing lowercase, no B (bearing) commands. Thus serialized paths for 'offset-path' and 'd' will contain only M Z L Q C A commands. (There may also be R (Catmull-Rom curve) commands if they can't be losslessly converted to cubic Beziers. Note that B and R are being mentioned for spec completeness, they are not implemented in Blink.)
SVG #320 remains open.
Shipping
This change is expected to ship in Chrome 64.
Blink implementation of offset-position, offset-anchor and ray path is in progress, not ready to ship.