When serialized,
- [=control points=] originally specified with two [=input progress values=]
- are turned into two separate [=control points=],
+ [=linear()/control points=] originally specified with two [=input progress values=]
+ are turned into two separate [=linear()/control points=],
and the [=input progress values=] are in strictly ascending order.
For example:
@@ -283,48 +283,55 @@ Serializing
Output
-
-
-To calculate linear easing output progress
-for a given [=linear easing function=] |linearEasingFunction|,
-and an [=input progress value=] |inputProgress|,
-perform the following.
-It returns an [=output progress value=].
-
-1. Let |points| be |linearEasingFunction|'s [=linear easing function/points=].
-
-1. Let |pointAIndex| be index of the last [=list/item=] in |points|
- with an [=linear easing point/input=] less than or equal to |inputProgress|,
- or 0 if there is no match.
-
-1. If |pointAIndex| is equal to |points| [=list/size=] minus 1,
- decrement |pointAIndex| by 1.
-
- Note: This ensures we have a "next" [=linear easing point|point=] to compare to.
-
-1. Let |pointA| be |points|[pointAIndex].
-
-1. Let |pointB| be |points|[pointAIndex + 1].
-
-1. If |pointA|'s [=linear easing point/input=] is equal to |pointB|'s [=linear easing point/input=],
- return |pointB|'s [=linear easing point/output=].
-
-1. Let |progressFromPointA| be |inputProgress| minus |pointA|'s [=linear easing point/input=].
-
-1. Let |pointInputRange| be |pointB|'s [=linear easing point/input=] minus |pointA|'s [=linear easing point/input=].
-
-1. Let |progressBetweenPoints| be |progressFromPointA| divided by |pointInputRange|.
-
-1. Let |pointOutputRange| be |pointB|'s [=linear easing point/output=] minus |pointA|'s [=linear easing point/output=].
-
-1. Let |outputFromLastPoint| be |progressBetweenPoints| multiplied by |pointOutputRange|.
+
-1. Return |pointA|'s [=linear easing point/output=] plus |outputFromLastPoint|.
+ To calculate linear easing output progress
+ for a given [=linear easing function=] |func|,
+ and an [=input progress value=] |inputProgress|,
+ perform the following.
+ It returns an [=output progress value=].
+
+ 1. Let |points| be |func|'s [=linear()/control points=].
+
+ 2. If |points| holds only a single item,
+ return the [=output progress value=]
+ of that item.
+
+ 3. If at least one of |points| has an [=input progress value=]
+ matching |inputProgress|,
+ return the largest [=output progress value=] from among them.
+
+ 4. Otherwise, find two [=linear()/control points=],
+ |A| and |B|,
+ which will be used for interpolation:
+
+ 1. If |inputProgress| is smaller
+ than any [=input progress value=] in |points|,
+ let |A| and |B| be the first two items in |points|.
+ If |A| and |B| have the same [=input progress value=],
+ return |A|'s [=output progress value=].
+
+ 2. Otherwise, if |inputProgress| is larger
+ than any [=input progress value=] in |points|,
+ let |A| and |B| be the last two items in |points|.
+ If |A| and |B| have the same [=input progress value=],
+ return |B|'s [=output progress value=].
+
+ 3. Otherwise, let |A| be the [=linear()/control point=]
+ with the largest [=output progress value=]
+ whose [=input progress value=] is smaller than |inputProgress|,
+ and let |B| be the [=linear()/control point=]
+ with the smallest [=output progress value=]
+ whose [=input progress value=] is larger than |inputProgress|.
+
+ 5. Linearly interpolate (or extrapolate) |inputProgress|
+ along the line defined by |A| and |B|,
+ and return the result.
+
linear-timing-functions-output.html
-
Examples