RFR: 8372203: Piecewise linear easing function [v2]
Andy Goryachev
angorya at openjdk.org
Mon Nov 24 22:09:25 UTC 2025
On Sat, 22 Nov 2025 10:06:56 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"/>
>
> Michael Strauß has updated the pull request incrementally with two additional commits since the last revision:
>
> - numeric overflow to infinity
> - refactor tests
Looks good, left a couple of suggestions.
Used .button selector with transition in the monkey tester, with hilarious results.
modules/javafx.graphics/src/main/java/com/sun/scenario/animation/LinearInterpolator.java line 202:
> 200: }
> 201:
> 202: // Linearly interpolate (or extrapolate) along the segment (ax, ay) -> (bx, by).
Alternative proposal: instead of introducing infinities, we probably should just arrive at the end-of-segment value when the ax ~= bx, something like this:
// Linearly interpolate (or extrapolate) along the segment (ax, ay) -> (bx, by).
if (isNear(ax, bx)) {
// Degenerate segment; just treat as a step.
return ay;
}
where isNear is Math.abs(ax - bx) < SMALL_CONSTANT
(can be inline), unless the value of SMALL_CONSTANT depends on the interval.
what do you think?
modules/javafx.graphics/src/main/java/javafx/animation/Interpolator.java line 111:
> 109: * @since 26
> 110: */
> 111: public static Interpolator LINEAR(Point2D... controlPoints) {
as you pointed out earlier, it's probably better to name this method ofLinear() since it is not a final constant.
-------------
PR Review: https://git.openjdk.org/jfx/pull/1977#pullrequestreview-3502390939
PR Review Comment: https://git.openjdk.org/jfx/pull/1977#discussion_r2557849902
PR Review Comment: https://git.openjdk.org/jfx/pull/1977#discussion_r2557853499
More information about the openjfx-dev
mailing list