Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define path interpolation when relative and absolute segment types are used. #947

Open
emilio opened this issue Jun 21, 2024 · 4 comments
Open

Comments

@emilio
Copy link

emilio commented Jun 21, 2024

https://svgwg.org/svg2-draft/paths.html says how to interpolate paths:

For animation, two d property values can only be interpolated smoothly when the path data strings contain have the same structure, (i.e. exactly the same number and types of path data commands which are in the same order). If an animation is specified and the lists of path data commands do not have the same structure, then the values must be interpolated using the discrete animation type.

However browsers support interpolating relative with non-relative paths, and currently behavior diverges across browsers...

https://wpt.fyi/results/svg/animations/animate-path-animation-Mm-Aa-Z.tentative.html?label=experimental&label=master&aligned

What is the correct behavior? Should paths always be normalized (absolutized) before interpolation? Or should paths try to preserve relativeness, and if so what's the right way to deal with mismatches?

@Doktorchen
Copy link

Hmmm, both the SVG 1.1 recommendation and the 2.0 draft define for relative and absolute only two letters for the same command to destinguish between relative and absolute.
And it is mentioned explicitely, which (absolute) points is meant, if relative coordinates are used.
Therefore obviously one has always to interpolate between the given points, not the given numbers, without taking into account, what they mean.

But I agree, that it is better to note this explicitely to avoid confusion between different implementations.

@emilio
Copy link
Author

emilio commented Jun 22, 2024

And it is mentioned explicitely, which (absolute) points is meant, if relative coordinates are used.

Therefore obviously one has always to interpolate between the given points, not the given numbers, without taking into account, what they mean.

Sure, but the point is that there are two ways to represent the same point, so you can interpolate the same points and give two different answers which are both correct, right? So it's not so much about confusion but undefinedness in the spec...

@Doktorchen
Copy link

It is a simple addition of coordinates as operation, affine, therefore no problem, same result.
This is because ab = a(b+c-c) = a(b+c) -ac = ab + ac -ac = ab, with a scalar and b, c vectors. Effectively a(t), t time represents some animate animation interpolations, acting always on the complete path in a d attribute.

Just to have some pastime, I created a simple example using two paths with M,C and m,c and the same graphical result - interpolates in the same way.
Even the third path with MC in the path d attribute and m,c in the animate values does not result in a different animation, as expected (in firefox and vivaldi).

This would be different, if one tries to interpolate between absolute and relative coordinates, all points just need the same coordinate system (origin) to get it right.

@emilio
Copy link
Author

emilio commented Jun 24, 2024

It is a simple addition of coordinates as operation, affine, therefore no problem, same result.

Same result, but since the difference is observable via DOM APIs it should be defined to avoid gratuitous behaviour differences between browsers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants