On Mon, 24 Nov 2025 22:01:35 GMT, Andy Goryachev <[email protected]> wrote:
>> Michael Strauß has updated the pull request incrementally with two
>> additional commits since the last revision:
>>
>> - numeric overflow to infinity
>> - refactor tests
>
> 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?
I've found that the algorithm in the
[specification](https://www.w3.org/TR/css-easing-2/#linear-easing-function-output)
is quite a bit simpler, and it passes all tests, so I've changed the
implementation to match this algorithm. It's also exactly what is implemented
by
[Chromium](https://github.com/chromium/chromium/blob/dcad42a0d6d442653bbaef4d11fb08e71d19a879/ui/gfx/animation/keyframe/timing_function.cc#L187).
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1977#discussion_r2558240434