-
Notifications
You must be signed in to change notification settings - Fork 689
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
[css-values-4] How to interpolate <ratio>? #4953
Comments
I don't see why. For transforms, we “upgrade” values as needed for interpolation, in a way that's separate from how computed values work. So, without that objection, I'd definitely argue for scaling to a denominator over 1 before interpolating numerators. Or alternatively, scaling up to a lowest common multiple denominator, to avoid precision issues from decimals. E.g., 5/1→300/200 would be interpolated as 1000/200→300/200. But that should give the same results, minus precision issues, as 5/1→1.5/1 |
You forgot to animate the width of the 4th case. Here is the fixed showcase, also highlighting the start and end sizes: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/7976
Specifically, if I got it right, linearly interpolating However, it's not clear to me that we should try to get that behavior. If some author wants to get the same behavior as if the |
I don't find the linear interpolation necessary, but looking at the two examples, I do find it better-looking, at least when they're on the same scale. But the scale-dependence really bothers me on a spec level (it shouldn't matter!), and looks terrible in practice when the scales differ by a lot.
Ah you're right. That resolves my issue, then. Let's just specify behavior 2 (interpolate over the division result), then. |
It seems like it might be better to interpolate the logarithm of the division result, or perhaps some other function of the division result that would produce symmetric results between animation from |
@dbaron That is an excellent point: using division lets us avoid a scale-dependence (so going from Using the logarithm of the division, then, seems to make a lot of sense - it'll interpolate your examples by going from (wlog, using log2) It also means that going from So if nobody objects, I'll change to using the logarithm of the division result. |
So, the proposal is that the interpolation between two ratios
? Or equivalently,
Note that Also note that doing it linearly has the advantage that you can fix Example table:
So this would make it symmetric, seems good to me. |
One other possibility that I think might work better that logarithms and still have the desirable properties of avoiding scale-dependence and orientation-dependence is to instead use the function I(r) = r - 1, for r ≥ 1 since I think at least for Note that this is easily invertible: |
Figuring out which of these two is better may require constructing demos. Though it also might make the rules for |
Yeah, that's the point, it now acts identically whether you're going from "square" to "infinitely tall" as to "infinitely wide". That's nice!
I'll write a few. |
For ratios ≥ 1, this reduces to linear interpolation. So it still has the same problem: if you fix |
Yeah, considering that I think all of the solutions look worse than "interpolate the numerator and denominator separately", I don't think fine details in the interpolation will matter too much. But logarithmic scaling has really appealing mathematical properties. |
But there is a symmetry: the way it behaves when fixing |
Here, I've rendered some demos: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/8633 Logarithmic and dbaron's "inverted linear" are pretty close overall; I don't see a significant distinction between them. As such, I'm still leaning slightly towards logarithmic, as I think it has the better overall mathematical behavior. |
Actually if you try out more extreme ratios, like 1:1 transitioning to 10:1, I like log a lot better; linear and inverted-linear both spend most of their time in the high ratios, which are hard to tell apart, while log appears to have more even progress. Doing 1:1 transitioning to 1:10 (where "inverted linear" makes the height move linearly) it's more of a tossup; they're both clearly better than linear, but I'm not sure which I prefer between log and inverted-linear. So yeah, still supporting log, I think. |
Added option to fix height: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/8634 When fixing height and going from 1:1 to 1:10, I don't like dbaron's, it behaves like linear when fixing width. So I also lean towards log. |
Side note on process: "Editor Discretion" imho should only be used when
Otherwise, it should be Agenda+ and closed by CSSWG resolution in order to get consensus among all the people likely to care. |
The CSS Working Group just discussed
The full IRC log of that discussion<dael> Topic: [css-values-4] How to interpolate <ratio>?<dael> github: https://github.com//issues/4953 <dael> TabAtkins: Currently the value and units spec defines that ratios are interp by devide and interpolate the number. Bad. It's simple but has bad properties. Grossly asymmetrical between tall and wide. tall has 1-0 range and wide is 1-infinity <dael> TabAtkins: If going from 1-1 to 10-1 if it goes tall it spends most of it's time being close to square. Takes a long time to go 1 -> .1 But if you're going wide you're spending most of the time close to 10 <dael> TabAtkins: A much better way to preserve the symmetry is to take the log of the division results and interpolate that and exponent to get back to the ratio. Gives you idential behavior. Makes sure if you're going 2-1 that halfway is suqare <dael> TabAtkins: Suggestion for dbaron has other asymmetries. If you want details it's in the issue and oriol has examples of where the assymetry comes in <fantasai> oriol made demos at http://software.hixie.ch/utilities/js/live-dom-viewer/saved/8634 <dael> TabAtkins: Would like to transition ratios using log of result. I think this is fine for future uses. Produces pleasing visual transition. Symmetry should be good for all cases <florian> sounds good to me <dael> TabAtkins: Prep to resolve to use the log. Other thoughts we can go back to the issue <dael> astearns: Additional comments? <dael> astearns: Prop: Interpolate ratios using log <dael> RESOLVED: Interpolate ratios using log |
@tabatkins I think the formula needs to special-case Also, it may be useful to note that the formula can be simplified to |
Based on the discussion in w3c/csswg-drafts#4953 aspect ratios should be interpolated by the log of their value preserving the same visual speed whether they are wide or narrow. This patch adds a new interpolation type for aspect ratios and uses it for interpolating the CSS aspect-ratio property. Bug:1156160 Change-Id: I6cbff0abef54290de559a7625e24e3c4e1f1e0e9
Based on the discussion in w3c/csswg-drafts#4953 aspect ratios should be interpolated by the log of their value preserving the same visual speed whether they are wide or narrow. This patch adds a new interpolation type for aspect ratios and uses it for interpolating the CSS aspect-ratio property. Bug:1156160 Change-Id: I6cbff0abef54290de559a7625e24e3c4e1f1e0e9
Based on the discussion in w3c/csswg-drafts#4953 aspect ratios should be interpolated by the log of their value preserving the same visual speed whether they are wide or narrow. This patch adds a new interpolation type for aspect ratios and uses it for interpolating the CSS aspect-ratio property. Bug:1156160 Change-Id: I6cbff0abef54290de559a7625e24e3c4e1f1e0e9
Based on the discussion in w3c/csswg-drafts#4953 aspect ratios should be interpolated by the log of their value preserving the same visual speed whether they are wide or narrow. This patch adds a new interpolation type for aspect ratios and uses it for interpolating the CSS aspect-ratio property. Bug:1156160 Change-Id: I6cbff0abef54290de559a7625e24e3c4e1f1e0e9
Based on the discussion in w3c/csswg-drafts#4953 aspect ratios should be interpolated by the log of their value preserving the same visual speed whether they are wide or narrow. This patch adds a new interpolation type for aspect ratios and uses it for interpolating the CSS aspect-ratio property. Bug: 1156160 Change-Id: I6cbff0abef54290de559a7625e24e3c4e1f1e0e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586234 Reviewed-by: Kevin Ellis <kevers@chromium.org> Reviewed-by: Xida Chen <xidachen@chromium.org> Commit-Queue: Robert Flack <flackr@chromium.org> Cr-Commit-Position: refs/heads/master@{#846135}
Based on the discussion in w3c/csswg-drafts#4953 aspect ratios should be interpolated by the log of their value preserving the same visual speed whether they are wide or narrow. This patch adds a new interpolation type for aspect ratios and uses it for interpolating the CSS aspect-ratio property. Bug: 1156160 Change-Id: I6cbff0abef54290de559a7625e24e3c4e1f1e0e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586234 Reviewed-by: Kevin Ellis <kevers@chromium.org> Reviewed-by: Xida Chen <xidachen@chromium.org> Commit-Queue: Robert Flack <flackr@chromium.org> Cr-Commit-Position: refs/heads/master@{#846135}
Based on the discussion in w3c/csswg-drafts#4953 aspect ratios should be interpolated by the log of their value preserving the same visual speed whether they are wide or narrow. This patch adds a new interpolation type for aspect ratios and uses it for interpolating the CSS aspect-ratio property. Bug: 1156160 Change-Id: I6cbff0abef54290de559a7625e24e3c4e1f1e0e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586234 Reviewed-by: Kevin Ellis <kevers@chromium.org> Reviewed-by: Xida Chen <xidachen@chromium.org> Commit-Queue: Robert Flack <flackr@chromium.org> Cr-Commit-Position: refs/heads/master@{#846135}
…port., a=testonly Automatic update from web-platform-tests Implement aspect-ratio interpolation support. Based on the discussion in w3c/csswg-drafts#4953 aspect ratios should be interpolated by the log of their value preserving the same visual speed whether they are wide or narrow. This patch adds a new interpolation type for aspect ratios and uses it for interpolating the CSS aspect-ratio property. Bug: 1156160 Change-Id: I6cbff0abef54290de559a7625e24e3c4e1f1e0e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586234 Reviewed-by: Kevin Ellis <kevers@chromium.org> Reviewed-by: Xida Chen <xidachen@chromium.org> Commit-Queue: Robert Flack <flackr@chromium.org> Cr-Commit-Position: refs/heads/master@{#846135} -- wpt-commits: d4719bcb025560fe81b4b8dd737608cbe0d77030 wpt-pr: 26856
…port., a=testonly Automatic update from web-platform-tests Implement aspect-ratio interpolation support. Based on the discussion in w3c/csswg-drafts#4953 aspect ratios should be interpolated by the log of their value preserving the same visual speed whether they are wide or narrow. This patch adds a new interpolation type for aspect ratios and uses it for interpolating the CSS aspect-ratio property. Bug: 1156160 Change-Id: I6cbff0abef54290de559a7625e24e3c4e1f1e0e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586234 Reviewed-by: Kevin Ellis <keverschromium.org> Reviewed-by: Xida Chen <xidachenchromium.org> Commit-Queue: Robert Flack <flackrchromium.org> Cr-Commit-Position: refs/heads/master{#846135} -- wpt-commits: d4719bcb025560fe81b4b8dd737608cbe0d77030 wpt-pr: 26856 UltraBlame original commit: 375a9dea6eb7eddf08419c25b71de2d3aab97bdd
…port., a=testonly Automatic update from web-platform-tests Implement aspect-ratio interpolation support. Based on the discussion in w3c/csswg-drafts#4953 aspect ratios should be interpolated by the log of their value preserving the same visual speed whether they are wide or narrow. This patch adds a new interpolation type for aspect ratios and uses it for interpolating the CSS aspect-ratio property. Bug: 1156160 Change-Id: I6cbff0abef54290de559a7625e24e3c4e1f1e0e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586234 Reviewed-by: Kevin Ellis <keverschromium.org> Reviewed-by: Xida Chen <xidachenchromium.org> Commit-Queue: Robert Flack <flackrchromium.org> Cr-Commit-Position: refs/heads/master{#846135} -- wpt-commits: d4719bcb025560fe81b4b8dd737608cbe0d77030 wpt-pr: 26856 UltraBlame original commit: 375a9dea6eb7eddf08419c25b71de2d3aab97bdd
…port., a=testonly Automatic update from web-platform-tests Implement aspect-ratio interpolation support. Based on the discussion in w3c/csswg-drafts#4953 aspect ratios should be interpolated by the log of their value preserving the same visual speed whether they are wide or narrow. This patch adds a new interpolation type for aspect ratios and uses it for interpolating the CSS aspect-ratio property. Bug: 1156160 Change-Id: I6cbff0abef54290de559a7625e24e3c4e1f1e0e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586234 Reviewed-by: Kevin Ellis <keverschromium.org> Reviewed-by: Xida Chen <xidachenchromium.org> Commit-Queue: Robert Flack <flackrchromium.org> Cr-Commit-Position: refs/heads/master{#846135} -- wpt-commits: d4719bcb025560fe81b4b8dd737608cbe0d77030 wpt-pr: 26856 UltraBlame original commit: 375a9dea6eb7eddf08419c25b71de2d3aab97bdd
…port., a=testonly Automatic update from web-platform-tests Implement aspect-ratio interpolation support. Based on the discussion in w3c/csswg-drafts#4953 aspect ratios should be interpolated by the log of their value preserving the same visual speed whether they are wide or narrow. This patch adds a new interpolation type for aspect ratios and uses it for interpolating the CSS aspect-ratio property. Bug: 1156160 Change-Id: I6cbff0abef54290de559a7625e24e3c4e1f1e0e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586234 Reviewed-by: Kevin Ellis <kevers@chromium.org> Reviewed-by: Xida Chen <xidachen@chromium.org> Commit-Queue: Robert Flack <flackr@chromium.org> Cr-Commit-Position: refs/heads/master@{#846135} -- wpt-commits: d4719bcb025560fe81b4b8dd737608cbe0d77030 wpt-pr: 26856
Based on the discussion in w3c/csswg-drafts#4953 aspect ratios should be interpolated by the log of their value preserving the same visual speed whether they are wide or narrow. This patch adds a new interpolation type for aspect ratios and uses it for interpolating the CSS aspect-ratio property. Bug: 1156160 Change-Id: I6cbff0abef54290de559a7625e24e3c4e1f1e0e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586234 Reviewed-by: Kevin Ellis <kevers@chromium.org> Reviewed-by: Xida Chen <xidachen@chromium.org> Commit-Queue: Robert Flack <flackr@chromium.org> Cr-Commit-Position: refs/heads/master@{#846135} GitOrigin-RevId: 4d02791fc5a96532045066d58ea958aed1d5b524
I'm moving the definition of
<ratio>
over to V&U right now, per #4908, but I'm stuck on how ratios should interpolate (which is simply not defined right now in Sizing, the only place where a ratio is potentially interpolable).Two obvious answers:
X / 1
form.)Here's a test showing off the behaviors.
I think that, in general, I like "interpolate numerator and denominator separately" better. In particular, if the two ratios are on the same scale, the behavior ends up being identical to just interpolating the width and height independently.
Note, tho, the fourth box on that page - it's still interpolating between the same two ratios, but one ratio is expressed as
5/1
, and the other is300/200
. This gives a ridiculous result, that just happens to land on the exact right sizes at the beginning and end. This means that option 1 is scale-dependent, which is probably not a good thing to have!Further complications: if we go with "interpolate the divided result", that implies that the computed value has to be the divided result, I think? Which means that if you write
3/2
, we'll lose that information, and can only serialize it as1.5/1
, which seems bad.So I'm not sure. What does the group think? Option 1, with a warning that people probably want to ensure their numbers are on similar scales? (They usually will be.) Or Option 2, and bite the bullet on serialization?
The text was updated successfully, but these errors were encountered: