1. Introduction
This section is not normative.
It is often desirable to control the rate at which some value changes. For example, gradually increasing the speed at which an element moves can give the element a sense of weight as it appears to gather momentum. This can be used to produce intuitive user interface elements or convincing cartoon props that behave like their physical counterparts. Alternatively, it is sometimes desirable for animation to move forwards in distinct steps such as a segmented wheel that rotates such that the segments always appear in the same position.
Similarly, controlling the rate of change of gradient interpolation can be used to produce different visual effects such as suggesting a concave or convex surface, or producing a striped effect.
Easing functions provide a means to transform such values by taking an input progress value and producing a corresponding transformed output progress value.
2. Easing functions
An easing function takes an input progress value and produces an output progress value.
An easing function must be a pure function meaning that for a given set of inputs, it always produces the same output progress value.
The input progress value is a real number in the range [∞, ∞]. Typically, the input progress value is in the range [0, 1] but this may not be the case when easing functions are chained together.
The output progress value is a real number in the range [∞, ∞].
Some types of easing functions also take an additional boolean before flag input which is defined subsequently.
This specification defines four types of easing functions whose definitions follow.
The syntax for specifying an easing function is as follows:
2.1. The linear easing function: linear
The linear easing function is an identity function meaning that its output progress value is equal to the input progress value for all inputs.
The syntax for the linear easing function is simply the linear keyword.
2.2. Cubic Bézier easing functions: ease, easein, easeout, easeinout, cubicbezier()
A cubic Bézier easing function is a type of easing function defined by four real numbers that specify the two control points, P1 and P2, of a cubic Bézier curve whose end points P0 and P3 are fixed at (0, 0) and (1, 1) respectively. The x coordinates of P1 and P2 are restricted to the range [0, 1].
A cubic Bézier easing function has the following syntax (using notation from [CSS3VAL]):
The meaning of each value is as follows:
 ease

Equivalent to cubicbezier(0.25, 0.1, 0.25, 1).
 easein

Equivalent to cubicbezier(0.42, 0, 1, 1).
 easeout

Equivalent to cubicbezier(0, 0, 0.58, 1).
 easeinout

Equivalent to cubicbezier(0.42, 0, 0.58, 1).
 cubicbezier(<number>, <number>, <number>, <number>)

Specifies a cubic Bézier easing function. The four numbers specify points P1 and P2 of the curve as (x1, y1, x2, y2). Both x values must be in the range [0, 1] or the definition is invalid.
The keyword values listed above are illustrated below.
2.2.1. Output of a cubic bézier easing function
The mapping from input progress to output progress is performed by determining the corresponding y value (output progress value) for a given x value (input progress value). The evaluation of this curve is covered in many sources such as [FUNDCOMPGRAPHICS].
For input progress values outside the range [0, 1], the curve is extended infinitely using tangent of the curve at the closest endpoint as follows:

For input progress values less than zero,

If the x value of P1 is greater than zero, use a straight line that passes through P1 and P0 as the tangent.

Otherwise, if the x value of P2 is greater than zero, use a straight line that passes through P2 and P0 as the tangent.

Otherwise, let the output progress value be zero for all input progress values in the range [∞, 0).


For input progress values greater than one,

If the x value of P2 is less than one, use a straight line that passes through P2 and P3 as the tangent.

Otherwise, if the x value of P1 is less than one, use a straight line that passes through P1 and P3 as the tangent.

Otherwise, let the output progress value be one for all input progress values in the range (1, ∞].

2.3. Step easing functions: stepstart, stepend, steps()
A step easing function is a type of easing function that divides the input time into a specified number of intervals that are equal in length. It is defined by a number of steps, and a step position. It has following syntax:
<stepposition> = jumpstart  jumpend  jumpnone  jumpboth  start  end
The meaning of each value is as follows:
 stepstart

Computes to steps(1, start)
 stepend

Computes to steps(1, end)
 steps(<integer>[, <stepposition> ]?)

The first parameter specifies the number of intervals in the function. It must be a positive integer greater than 0 unless the second parameter is jumpnone in which case it must be a positive integer greater than 1.
The second parameter, which is optional, specifies the step position using one of the following values:
 jumpstart

The first rise occurs at input progress value of 0.
 jumpend

The last rise occurs at input progress value of 1.
 jumpnone

All rises occur within the range (0, 1).
 jumpboth

The first rise occurs at input progress value of 0 and the last rise occurs at input progress value of 1.
 start

Behaves as jumpstart.
 end

Behaves as jumpend.
If the second parameter is omitted, the value end is assumed.
These values are illustrated below:
2.3.1. Output of a step easing function
At the exact point where a step occurs, the result of the function is conceptually the top of the step. However, an additional before flag passed as input to the step easing function, if true, will cause the result of the function to correspond to the bottom of the step at the step point.
As an example of how the before flag affects the behavior of this function, consider an animation with a step easing function whose step position is start and which has a positive delay and backwards fill.
For example, using CSS animation:
animation: moveRight 5s 1s steps(5, start);
During the delay phase, the input progress value will be zero but if the before flag is set to indicate that the animation has yet to reach its animation interval, the easing function will produce zero as its output progress value, i.e. the bottom of the first step.
At the exact moment when the animation interval begins, the input progress value will still be zero, but the before flag will not be set and hence the result of the easing function will correspond to the top of the first step.
For the purposes of calculating the output progress value, the step position start is considered equivalent to jumpstart. Likewise end is considered equivalent to jumpend. As a result, the following algorithm does not make explicit reference to start or end.
Note: User agents must still differentiate between jumpstart and start for the purpose of serialization (see § 2.4 Serialization).
The output progress value is calculated from the input progress value and before flag as follows:

Calculate the current step as
floor(input progress value × steps)
. 
If the step position property is one of:
increment current step by one.

If both of the following conditions are true:

the before flag is set, and

input progress value × steps mod 1 equals zero (that is, if input progress value × steps is integral), then
decrement current step by one.


If input progress value ≥ 0 and current step < 0, let current step be zero.

Calculate jumps based on the step position as follows:

If input progress value ≤ 1 and current step > jumps, let current step be jumps.
Steps 4 and 6 in this procedure ensure that given an input progress value in the range [0, 1], a step easing function does not produce an output progress value outside that range.
For example, although mathematically we might expect that a step easing function with a step position of jumpstart would step up (i.e. beyond 1) when the input progress value is 1, intuitively, when we apply such an easing function to a forwardsfilling animation, we expect it to produce an output progress value of 1 as the animation fills forwards.
A similar situation arises for a step easing function with a step position of jumpend when applied to an animation during its delay phase.

The output progress value is
current step / jumps
.
2.4. Serialization
Easing functions are serialized using the common serialization patterns defined in [CSSOM] with the following additional requirements:

The keyword values ease, linear, easein, easeout, and easeinout are serialized asis, that is, they are not converted to the equivalent cubicbezier() function before serializing.

Step easing functions, whether they are specified using the steps() function or either of the stepstart or stepend keywords, are serialized as follows:

If the step position is jumpend or end, serialize as steps(<integer>).

Otherwise, serialize as steps(<integer>, <stepposition>).

3. Privacy and Security Considerations
This specification does not directly introduce any new capabilities to the Web platform but rather provides common definitions that may be referenced by other specifications. As a result, it does not introduce any new privacy and security concerns.
Specifications referencing the features defined in this specification should consider that while easing functions most commonly take an input progress value in the range [0,1] and produce an output progress value in the range [0, 1], this is not always the case. Applications of easing functions should define the behavior for inputs and outputs outside this range to ensure they do not introduce new security considerations.
4. Changes since last publication
The following changes have been made since the 9 October 2018 Working Draft:

Reworded specification to refer to “easing functions” rather than “timing functions” and use more general language that does not assume these functions are only applied to animations.
5. Acknowledgements
This specification is based on the CSS Transitions specification edited by L. David Baron, Dean Jackson, David Hyatt, and Chris Marrin. The editors would also like to thank Douglas Stockwell, Steve Block, Tab Atkins, Rachel Nabors, Martin Pitt, and the Animation at Work slack community for their feedback and contributions.