RFR: 8372203: Piecewise linear easing function
Andy Goryachev
angorya at openjdk.org
Fri Nov 21 22:00:19 UTC 2025
On Wed, 19 Nov 2025 21:36:36 GMT, Michael Strauß <mstrauss at openjdk.org> wrote:
> Implementation of the [linear](https://www.w3.org/TR/css-easing-2/#the-linear-easing-function) easing function, which is now widely supported by all browsers, but still missing in JavaFX.
>
> It allows developers to approximate arbitrary easing functions with linear segments:
>
>
> linear(
> /* Start to 1st bounce */
> 0, 0.063, 0.25, 0.563, 1 36.4%,
> /* 1st to 2nd bounce */
> 0.812, 0.75, 0.813, 1 72.7%,
> /* 2nd to 3rd bounce */
> 0.953, 0.938, 0.953, 1 90.9%,
> /* 3rd bounce to end */
> 0.984, 1 100% 100%
> )
>
>
> <img src="https://github.com/user-attachments/assets/73aac0d4-0185-47c5-8791-bdb247eb69c8" width="400"/>
Could you provide an example (in the JBS maybe) of a CSS that illustrates the usage? Or maybe add an example to the javadoc?
modules/javafx.graphics/src/main/java/com/sun/scenario/animation/LinearInterpolator.java line 76:
> 74: // Ensure that the input progress value of each control point is greater than or equal to the
> 75: // input progress values of all preceding control points (monotonically non-decreasing).
> 76: double largestX = controlPoints[0];
Question: what happens when a esquence is specified which is somehow invalid? Will it throw an exception, write to stderr, or silently ignore?
(I can't think of an invalid sequence, maybe `0, 0 0% 0%, 0 -10%, NaN` ?)
modules/javafx.graphics/src/main/java/com/sun/scenario/animation/LinearInterpolator.java line 198:
> 196:
> 197: // Linearly interpolate (or extrapolate) along the segment (ax, ay) -> (bx, by).
> 198: if (ax == bx) {
FP alert: is it possible for `ax != bx` yet the result of division on L203 to produce an infinity?
modules/javafx.graphics/src/test/java/test/com/sun/scenario/animation/LinearInterpolatorTest.java line 41:
> 39: try {
> 40: Field f = LinearInterpolator.class.getDeclaredField("controlPoints");
> 41: f.setAccessible(true);
should an Accessor be used instead?
-------------
PR Review: https://git.openjdk.org/jfx/pull/1977#pullrequestreview-3494451006
PR Review Comment: https://git.openjdk.org/jfx/pull/1977#discussion_r2551033935
PR Review Comment: https://git.openjdk.org/jfx/pull/1977#discussion_r2551042657
PR Review Comment: https://git.openjdk.org/jfx/pull/1977#discussion_r2551048049
More information about the openjfx-dev
mailing list