RFR: 8372203: Piecewise linear easing function [v4]
Kevin Rushforth
kcr at openjdk.org
Wed Nov 26 22:01:07 UTC 2025
On Tue, 25 Nov 2025 01:42:42 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 one additional commit since the last revision:
>
> rename LINEAR() to ofLinear()
The API and docs look good. I left a couple questions on the `ofLinear` method.
modules/javafx.graphics/src/main/java/javafx/animation/Interpolator.java line 105:
> 103: * the first or last control point is unspecified, it is set to 0 or 1, respectively.
> 104: *
> 105: * @param controlPoints the control points
Do the control points need to be sorted by their X values (excluding NaN)? The treatment of NaN values regarding of "neighboring control points" suggests that it should be in order for it to be sensible, but perhaps the algorithm doesn't require it?
modules/javafx.graphics/src/main/java/javafx/animation/Interpolator.java line 107:
> 105: * @param controlPoints the control points
> 106: * @throws NullPointerException if {@code controlPoints} is {@code null}
> 107: * @throws IllegalArgumentException if {@code controlPoints} is empty
Should it throw IAE if length < 2?
-------------
PR Review: https://git.openjdk.org/jfx/pull/1977#pullrequestreview-3512841991
PR Review Comment: https://git.openjdk.org/jfx/pull/1977#discussion_r2566572800
PR Review Comment: https://git.openjdk.org/jfx/pull/1977#discussion_r2566583991
More information about the openjfx-dev
mailing list