W3C

CSS Easing Functions Level 2

編集者草案

この日本語訳は非公式な文書です…
この文書についての詳細
索引など

要約

この CSS モジュールは、作者が,値の変化率を制御する変形を定義する仕方を述べる。 アニメーションに適用された場合、そのような変形を利用すれば,慣性などの物理的な現象を真似たり, ロボットの様にカクカク動くアニメーションを生産できる。 このレベル 2 は、 カスタムな easing 曲線用に,より洗練された関数を追加する。 This CSS module describes a way for authors to define a transformation that controls the rate of change of some value. Applied to animations, such transformations can be used to produce animations that mimic physical phenomena such as momentum or to cause the animation to move in discrete steps producing robot-like movement. Level 2 adds more sophisticated functions for custom easing curves.

CSS とは…

この文書の位置付け

これは、 編集者草案の公な複製です… 【以下、この節の内容は,CSS 日本語訳 共通ページこの文書についての詳細に移譲。】

1. 序論

この節は規範的ではない。This section is non-normative.

何らかの値の変化率を制御したいと欲されることは多い。 例えば、 要素を次第に勢いが増すよう加速して動かすことで,重さがあるような感覚を与えれる。 これを利用すれば、 直感的な UI 要素や,物理的に本物らしくふるまうアニメを生産できる。 また、 歯が常に同じ位置に現れるように回転する歯車など, 飛び飛びに動くアニメーションが欲されることも ときにはある。 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.

同様に,gradient 補間の変化率の制御を利用すれば、[ 面の凹凸を示唆する/縞模様の効果 ]など,種々の視覚的な効果を生産できる。 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 関数は、 入力進捗値から対応する出力進捗値を生産することにより, そのような値を変形する手段を供する。 Easing functions provide a means to transform such values by taking an input progress value and producing a corresponding transformed output progress value.

Example of an easing function that produces an ease-in effect.
ease-in 効果を生産する easing 関数の例。 この easing 関数は、 入力進捗値 0.7 に対しては,出力進捗 0.52 を生産する。 この easing 関数をアニメーションに適用すれば、 アニメーションは,最初は遅く, 徐々に速く進捗するようになる。 Example of an easing function that produces an ease-in effect. Given an input progress of 0.7, the easing function scales the value to produce an output progress of 0.52. Applying this easing function to an animation would cause it to progress more slowly at first but then gradually progress more quickly.

1.1. 値定義

【 この節の内容は、 CSS 日本語訳 共通ページに移譲。 】

2. easing 関数

easing 関数easing function【 “加減速” 関数】は、 入力進捗値から出力進捗値を生産する。 An easing function takes an input progress value and produces an output progress value.

【 この用語は、 計時関数( timing function )とも称される — 特に,アニメーションの文脈(各種アニメーション関連仕様など)においては。 】

easing 関数は、 純粋な関数でなければならない — すなわち、 同じ入力に対しては,常に同じ出力進捗値を生産する。 An easing function must be a pure function meaning that for a given set of inputs, it always produces the same output progress value.

入力進捗値input progress value ) は、 範囲 [−∞, ∞] に入る実数である。 値は,概して [0, 1] に入るが、 複数の easing 関数が連鎖される事例ではそうなるとは限らない。 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.

注記: 複数の easing 関数が連鎖される例は、 [WEB-ANIMATIONS] において生じる。 そこでは,あるアニメーション効果に指定された easing 関数の出力は、 ある keyframe 効果に属する いずれかの keyframe に指定された easing 関数への入力に渡され得る。 この局面においては、 そのような入力は,範囲 [0, 1] に入らないこともある。 An example of when easing functions are chained together occurs in Web Animations [WEB-ANIMATIONS] where the output of the easing function specified on an animation effect may become the input to an easing function specified on one of the keyframes of a keyframe effect. In this scenario, the input to the easing function on the keyframe effect may be outside the range [0, 1].

出力進捗値output progress value ) は、 範囲 [−∞, ∞] に入る実数である。 The output progress value is a real number in the range [-∞, ∞].

注記: CSS における実数の範囲は,理論的には無限であるが ( [CSS-VALUES-4] § 範囲の制約と範囲定義の記法 を見よ)、 UA は,巨大過ぎる実数を適度な範囲へ自動的に切り詰めることになる。 easing 関数が CSS 文脈の外側で利用される場合、[ 無限大になり得るもの (単に,浮動小数点数として格納された値が ごく巨大なために生産されるものも含む) を正しく取り扱うか,出力進捗値を切り詰める ]よう配慮する必要がある。 Note: While CSS numbers have a theoretically infinite range (see CSS Values 4 § 5.1 Range Restrictions and Range Definition Notation) UAs will automatically clamp enormous numbers to a reasonable range. If easing functions are used outside of the CSS context, care must be taken to either correctly handle potential infinities (including those produced by merely very large values stored in a floating point number), or clamp the output progress value.

easing 関数には、 追加で 直前フラグ をとるものもある — それは、 真偽値であり,当の easing 【を利用するアニメーション】は[ まだ開始されてないか,逆行して完遂した ]ことを指示する。 (一部の easing 関数は、 所与の入力進捗値に対し可能な出力進捗値が複数あり得る — 一般に,それらのうち最後に指定された値が好まれるが、 このフラグは,代わりに[ 当の easing 関数のアニメーションが開始される前 ]において[ それらのうち最初に指定された値が好まれる ]ようにする。) Some types of easing functions also take an additional boolean before flag, which indicates the easing has not yet started, or is going in reverse and is past the finish. (Some easing functions can have multiple possible output progress values for a given input progress value, and generally favor the last one specified; this flag instead causes those easing functions to favor the first specified value before the animation has started.)

この仕様は、 いくつかの型の easing 関数を定義する。 This specification defines several types of easing functions:

easing 関数を指定するための構文は: The syntax for specifying an easing function is as follows:

<easing-function>
	= <linear-easing-function>
	| <cubic-bezier-easing-function>
	| <step-easing-function>

2.1. 線型 easing 関数: linear, linear()

線型 easing 関数linear easing function ) は、 その制御点リストを成す各制御点の合間を線形に補間する easing 関数である。 各 制御点control point )は、 2 個の実数 ( 入力, 出力 ) が成すペアであり, 入力が表現する入力進捗値出力が表現する出力進捗値へ結び付ける。 A linear easing function is an easing function that interpolates linearly between its control points. Each control point is a pair of numbers, associating an input progress value to an output progress value.

A linear curve used as an easing function.
線型 easing 関数 linear(0, .1 25%, .75 50%, 1) として利用される線型曲線【折れ線】。 曲線の形状は、 各制御点を順にたどる。 横軸は出力進捗値, 縦軸は出力進捗値linear(0, .1 25%, .75 50%, 1) The shape of the curve follows the control points. Input progress values serve as x values of the curve, whilst the y values are the output progress values.

線型 easing 関数の構文は: A linear easing function has the following syntax:

<linear-easing-function>
	= linear
	| <linear()>
<linear()>
	= linear( [ <number> && <percentage>{0,2} ]# )
linear
linear(0, 1) と等価になる。 Equivalent to linear(0, 1)
linear()
線型 easing 関数を指定する。 Specifies a linear easing function.

カンマで分離された各引数は、 指定された <percentage> の個数に応じて:

  • 0 個の場合 :1 個の制御点を指定する — その入力は、 初期時は null になるが, 構文解析の後に制御点リストを正準化することにより即時に正される。
  • 1 個の場合 :1 個の制御点を指定する — その入力は、 指定された <percentage> を 0 以上 1 以下の <number> に換算した結果になる。

    【 [ 0%100% ]が[ 0 / 1 ]に対応する。 構文においては値の範囲は特に制限されていないので、 0% 未満の値なども妥当になり, 0 に換算されることになる。 】

  • 2 個の場合 :2 個の制御点を — <percentage> ごとに,指定された順序で — 定義する。 それらの入力は、 前項と同様に決定される。

いずれの場合も、 制御点出力は, 指定された <number> に等しくなる。

線型 easing 関数制御点リスト †は、 これらの引数により定義される制御点たちが成す 指定された順序によるリストである。

【† この用語は、 他所を明確に述べるための,この訳による追加。 】

Each comma-separated argument specifies one or two control points, with an input progress value equal to the specified <percentage> (converted to a <number> between 0 and 1), and an output progress value equal to the specified <number>. When the argument has two <percentage>s, it defines two control points in the specified order, one per <percentage>.If an argument lacks a <percentage>, its input progress value is initially empty, but that is immediately corrected by linear() canonicalization after parsing.

制御点リストを正準化する アルゴリズムは、 所与の ( linear() 関数の制御点リスト 制御点リスト ) に対し: To canonicalize a linear() function’s control points, perform the following:

  1. IF制御点リスト[ 0 ] の入力 null ] :制御点リスト[ 0 ] の入力 ← 0 If the first control point lacks an input progress value, set its input progress value to 0.
  2. IF制御点リスト[ 制御点リストサイズ 1 ] の入力 null ] :制御点リスト[ 制御点リストサイズ 1 ] の入力 ← 1 If the last control point lacks an input progress value, set its input progress value to 1.
  3. 下限 :← 負な無限大
  4. 制御点リスト を成す ( 制御点 ) に対し:

    1. 入力 :← 制御点入力
    2. IF入力 null ] :CONTINUE
    3. 下限max( 入力, 下限 )
    4. 制御点入力下限
    If any control point has an input progress value that is less than the input progress value of any preceding control point, set its input progress value to the largest input progress value of any preceding control point.
  5. 【 この段は、[ 入力に null を伴う制御点 ]たちが成す連列に対し,それらの入力に[ 当の連列の前後の制御点入力から均等な間隔になるよう補間した結果 ]をあてがう。 原文の記述は,ここに述べた様な短いものだが、 この訳では,それを詳細な形にして述べる。 】

    1. 始端 :← null
    2. null 連列 :← 新たなリスト
    3. 制御点リスト を成す ( 制御点 ) に対し:

      1. 入力 :← 制御点入力
      2. IF入力 null ]:

        1. null 連列制御点付加する
        2. CONTINUE
      3. IF null 連列でない ]:

        1. Assert始端 null
        2. 間隔 :← ( 入力 始端 ) ÷ ( null 連列サイズ + 1 )
        3. null 連列 を成す ( 制御点 ) に対し:

          1. 始端 += 間隔
          2. 制御点入力始端
        4. null 連列空にする
      4. 始端入力
    4. Assert null 連列である
    If any control point still lacks an input progress value, then for each contiguous run of such control points, set their input progress values so that they are evenly spaced between the preceding and following control points with input progress values.

注記: 正準化後には、 どの制御点も,その入力は null 以外になり、 それらの入力は,リスト順に単調に非減少するようになる。 After canonicalization, every control point has an input progress value, and the input progress values are monotonically non-decreasing along the list.

注記: 直列化は,入力用の値が元々給されたか否かに依拠するので、 その情報は内部表現内に維持されるべきである。 直列化は、 2 個の制御点が[ 1 個の引数にて 2 個の百分率として指定されたか,別々な引数として指定されたか ]には依拠しない。 Note: Serialization relies on whether or not an input progress value was originally supplied, so that information should be retained in the internal representation. It does not rely on whether a pair of control points were specified as two percentages on a single argument or as separate arguments.

2.1.1. 直列化法

linear キーワードは、 それ自身に直列化される。 The linear keyword is serialized as itself.

線型 easing 関数を直列化する アルゴリズムは、 所与の ( 線型 easing 関数 関数 ) に対し: To serialize a linear() function:

  1. 引数群 :← « » ↓ Let s be the string "linear(".
  2. 関数【正準化済みな】制御点リストを成す ( 制御点 ) に対し :引数群 に次の結果を付加する制御点を直列化する( 制御点 ) Serialize each control point of the function,\
  3. 引数文字列 :← 引数群 を ", " で連結する concatenate the results using the separator ", ", and append the result to s.
  4. RETURN 次を順に連結する"linear(", 引数文字列, ")" Append ")" to s, and return it.

制御点を直列化する アルゴリズムは、 所与の ( 制御点 制御点 ) に対し: To serialize a linear() control point:

  1. 出力 :← 制御点出力<number> として直列化した結果 Let s be the serialization, as a <number>, of the control point’s output progress value.
  2. IF制御点入力用の値は元々は欠如していた 【正準化される前は null であった】 ] :RETURN 出力 If the control point originally lacked an input progress value, return s.
  3. RETURN 次を順に連結する出力, 1 個の U+0020 SPACE, 制御点入力<percentage> として直列化した結果 Otherwise, append " " (U+0020 SPACE) to s, then serialize the control point’s input progress value as a <percentage> and append it to s.Return s.

直列化されるとき、 元々 2 個の入力を伴って指定された引数は, 2 個の別々な制御点に転換され、 制御点たちの入力は厳密に昇順になる。 例えば: When serialized, control points originally specified with two input progress values are turned into two separate control points, and the input progress values are in strictly ascending order. For example:

  • linear(0, 0.25, 1)linear(0, 0.25, 1) として直列化される。 linear(0, 0.25, 1) serializes as linear(0, 0.25, 1)
  • linear(0 20%, 0.5 10%, 1)linear(0 20%, 0.5 20%, 1) として直列化される。 linear(0 20%, 0.5 10%, 1) serializes as linear(0 20%, 0.5 20%, 1)
  • linear(0, 0.25 25% 75%, 1)linear(0, 0.25 25%, 0.25 75%, 1) として直列化される。 linear(0, 0.25 25% 75%, 1) serializes as linear(0, 0.25 25%, 0.25 75%, 1)

2.1.2. 出力

線型 easing 出力進捗を計算する アルゴリズムは、 所与の ( 線型 easing 関数 関数, 入力進捗値 入力進捗, 直前フラグ (省略時は false ) ) に対し,出力進捗値を返す: To calculate linear easing output progress for a given linear easing function func, an input progress value inputProgress, and an optional before flag (defaulting to false), perform the following. It returns an output progress value.

  1. 制御点リスト :← 関数【正準化済みな】制御点リスト Let points be func’s control points.
  2. 個数 :← 制御点リストサイズ
  3. Assert個数 1
  4. IF個数 1 ] :RETURN 制御点リスト[ 0 ] の出力 If points holds only a single item, return the output progress value of that item.
  5. IF直前フラグ true ]入力進捗 制御点リスト[ 0 ] の入力 ] :RETURN 制御点リスト[ 0 ] の出力 If inputProgress matches the input progress value of the first point in points, and the before flag is true, return the first point’s output progress value.
  6. A :← 制御点リスト を成す制御点のうち次を満たすものは[ 在るならば それらのうち最後のもの/ 無いならば ε ] :その入力 入力進捗
  7. B :← 制御点リスト を成す制御点のうち次を満たすものは[ 在るならば それらのうち最初のもの/ 無いならば ε ] :その入力 > 入力進捗
  8. IFA ε ]A入力 入力進捗 ] :RETURN A出力 If inputProgress matches the input progress value of at least one point in points, return the output progress value of the last such point.
  9. IFA ε ]:

    1. A制御点リスト[ 0 ]
    2. B制御点リスト[ 1 ]
    3. IFA入力 B入力 ] :RETURN A出力
    Otherwise, find two control points in points, A and B, which will be used for interpolation: • 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.
  10. ELSE IFB ε ]:

    1. A制御点リスト[ 個数 2 ]
    2. B制御点リスト[ 個数 1 ]
    3. IFA入力 B入力 ] :RETURN B出力
    • 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.
  11. RETURN A出力 + ( B出力 A出力 ) × ( ( 入力進捗 A入力 ) ÷ ( B入力 A入力 ) ) •↑↑ Otherwise, let A be the last control point whose input progress value is smaller than inputProgress, and let B be the first control point whose input progress value is larger than inputProgress.Linearly interpolate (or extrapolate) inputProgress along the line defined by A and B, and return the result.

2.1.3. 例

linear() 関数は、 各点の合間を線形に補間する easing 関数の定義を許容する。 linear() allows the definition of easing functions that interpolate linearly between a set of points.

例えば, linear(0, 0.25, 1) は、 まず 0 から 0.25 へ,そこから 1 へ線形に移動する easing 関数を生産する: For example, linear(0, 0.25, 1) produces an easing function that moves linearly from 0, to 0.25, then to 1:

easing 関数
linear
linear(0, .25, 1)
上の例 (素な linear は比較対照用)。 An example of the above, with a plain linear for contrast.

既定では、 明示的な “入力” を伴わない値は,両側のエントリの合間に均等に分布する。 入力値は <percentage> を利用して供せる。 By default, values are spread evenly between entries that don’t have an explicit "input". Input values can be provided using a <percentage>.

例えば, linear(0, 0.25 75%, 1) が生産する easing 関数は、 75% の時間を費やして 0 から .25 まで遷移してから, 残り 25% を費やして .25 から 1 まで遷移する: For example, linear(0, 0.25 75%, 1) produces the following easing function, which spends 75% of the time transitioning from 0 to .25, then the last 25% transitioning from .25 to 1:

easing 関数
linear
linear(0, .25 75%, 1)
上の例 (素な linear は比較対照用)。 An example of the above, with a plain linear for contrast.

1 個の出力用に 2 個の入力値が供された場合、 その結果は,同じ出力を伴う 2 個の点になる。 それは、 当の easing を 2 個の入力の合間で “静止させる”。 If two input values are provided for a single output, it results in two points with the same output, causing the easing to "pause" between the two inputs.

例えば, linear(0, 0.25 25% 75%, 1) は、 linear(0, 0.25 25%, 0.25 75%, 1) と等価になり, 次のような easing 関数を生産する: For example, linear(0, 0.25 25% 75%, 1) is equivalent to linear(0, 0.25 25%, 0.25 75%, 1), producing the following easing function:

easing 関数
linear
linear(0, 0.25 25% 75%, 1)
上の例 (素な linear は比較対照用)。 An example of the above, with a plain linear for contrast.

【補間時に】供された入力が【 0 以上 1 以下の】範囲に入らない場合、 最も近い 2 個の点を結ぶ軌道が継続される。 If the input is outside the range provided, the trajectory of the nearest two points is continued.

例えば、 前の例と同じ関数における暗黙的な値【図の破線】は: For example, here are the implicit values from the previous function:

linear() の代表的な利用は、 多数の点を供して曲線のように見せかけることである。 A typical use of linear() is to provide many points to create the illusion of a curve.

例えば、 linear() を利用して,再利用可能な “跳ね返り( --bounce )” easing 関数を作成することもできる: For example, here’s how linear() could be used to create a reusable "bounce" easing function:

:root {
  --bounce: linear(
    /* 
始端から 1 個目までの跳ね返り
Start to 1st bounce */
    0, 0.063, 0.25, 0.563, 1 36.4%,
    /* 
1 個目から 2 個目までの跳ね返り
1st to 2nd bounce */
    0.812, 0.75, 0.813, 1 72.7%,
    /* 
2 個目から 3 個目までの跳ね返り
2nd to 3rd bounce */
    0.953, 0.938, 0.953, 1 90.9%,
    /* 
3 個目から終端までの跳ね返り
3rd bounce to end */
    0.984, 1 100% 100%
  );
}

.example {
  animation-timing-function: var(--bounce);
}

この定義は、 1 100% 100% で終端するので,末尾に 2 個の点を作成する — その結果、 1 を超える入力に対する出力は,常に 1 になる The definition ends 1 100% 100% to create two final points, so inputs greater than 1 always output 1.

easing 関数
linear
linear(...)
上の例 (素な linear は比較対照用)。 An example of the above, with a plain linear for contrast.

より遅いアニメーションには,もっと滑らかな結果が必要になろうが、 利用する点を増やすことで作成できる。 More points could be used to create a smoother result, which may be needed for slower animations.

2.2. 3 次ベジェ easing 関数: ease, ease-in, ease-out, ease-in-out, cubic-bezier()()

3 次ベジェ easing 関数cubic Bézier easing function )は、 easing 関数であり, 2 個の制御点により定義される[ 3 次多項式による曲線 ]を利用して 0 から 1 へ滑らかに補間する。 この曲線は、 これらの制御点に近付くが,実際には(通例的に)達しない。 (3 次ベジェの両 “端点” は、[ ( 0, 0 ) / ( 1, 1 ) ]に固定される。) A cubic Bézier easing function is an easing function that interpolates smoothly from 0 to 1 using a cubic polynomial, influenced by two control points that the curve will approach but (usually) not actually reach. (The "endpoints" of the cubic Bézier are fixed at (0,0) and (1,1), respectively.)

A cubic Bezier curve used as an easing function.
easing 関数として利用される 3 次ベジェ曲線。 曲線の形状は、 制御点(図の P1, P2 )の所在により決定される。 横軸は出力進捗値, 縦軸は出力進捗値A cubic Bezier curve used as an easing function.The shape of the curve is determined by the location of the control points P1 and P2. Input progress values serve as x values of the curve, whilst the y values are the output progress values.

3 次ベジェ easing 関数の構文は: A cubic Bézier easing function has the following syntax:

<cubic-bezier-easing-function>
	= ease
	| ease-in
	| ease-out
	| ease-in-out
	| <cubic-bezier()>
<cubic-bezier()>
	= cubic-bezier( [ <number [0,1]>, <number> ]#{2} )

各種 値の意味は: The meaning of each value is as follows:

ease-in
関数は、 遅く滑らかに開始して,ほぼ線型な曲線で終端点へ速く近付く。
cubic-bezier(0.42, 0, 1, 1) と等価になる。 A function that starts slowly and smoothly, then quickly approaches the endpoint with an almost linear curve. Equivalent to cubic-bezier(0.42, 0, 1, 1).
ease-out
関数は、 ほぼ線型な曲線で速く開始して, 遅く滑らかに終端点へ近付く。
cubic-bezier(0, 0, 0.58, 1) と等価になる。 A function that starts quickly with an almost linear curve, then slowly and smoothly approaches the endpoint. Equivalent to cubic-bezier(0, 0, 0.58, 1).
ease-in-out
関数は、 遅く滑らかに開始して, 途中を速く辿って, 遅く滑らかに終了する。
cubic-bezier(0.42, 0, 0.58, 1) と等価になる。 A function that starts and ends slowly and smoothly, quickly traversing the middle part. Equivalent to cubic-bezier(0.42, 0, 0.58, 1).
ease
ease-in-out に類似するが、 それより速く開始して遅く完遂する。
cubic-bezier(0.25, 0.1, 0.25, 1) と等価になる。 Similar to ease-in-out, but with a quicker start and a slower finish. Equivalent to cubic-bezier(0.25, 0.1, 0.25, 1).
cubic-bezier( x1, y1, x2, y2 )
3 次ベジェ easing 関数を指定する。 引数 x1, y1 は、 制御点 P1 を指定する。 引数 x2, y2 は、 制御点 P2 を指定する。 Specifies a cubic Bézier easing function. The x1 and y1 arguments specify the P1 control point, and x2 and y2 arguments specify the P2 control point.
x1, x2 は、 どちらも範囲 [0, 1] に入らなければならない — さもなければ、 当の関数は無効になる。 Both x values must be in the range [0, 1] or the definition is invalid.
3 次ベジェ曲線についての詳細 Details on cubic Bézier curves

これは、 入力進捗値を[ 3 次ベジェ曲線をパラメタ化するためによく利用される t ]として利用する (出力として二次元な点を生産する)ことはなく, グラフの x 値として利用する (出力として y 値を生産する)ことに注意。 このことは、 問われるのは[ 曲線に沿った速度ではなく,曲線の形状に限られる ]ことを意味する。 例えば, cubic-bezier(0, 0, 0, 0)cubic-bezier(1, 1, 1, 1) は、 正確に同じ(線型)easing を生産する — 前者の速度は[ t の 3 乗 ]曲線に従うが、 後者は[ t の ( 1 ÷ 3 ) 乗 ]曲線に従う【?】Note that this does not use the input progress value as the "t" value commonly used to parametrize cubic Bézier curves (producing a 2d point as the output), but rather uses it as the "x" value on the graph (producing a y value as the output). This means that only the shape of the curve matters, not the velocity along that curve. For example, cubic-bezier(0, 0, 0, 0) and cubic-bezier(1, 1, 1, 1) produce exactly the same (linear) easing, despite the first’s velocity following a t3 curve, while the second follows a t1/3 curve.

3 次ベジェ曲線は、 一般には,ループを成し得る — すなわち,同じ x 値に複数の y 値が対応し得る。 制御点に対し課される制約( x 値は範囲 [0, 1] に入る)は,これを防止するので、 結果の easing 関数は,きちんと定義されるようになる。 In general, cubic Bézier curves can have loops: places where a single x value is associated with multiple y values. The restriction placed on the control points (that their x values be in the [0,1] range) prevent this, so the resulting easing function is well-defined.

上に挙げたキーワード値を下の例で示す: The keyword values listed above are illustrated below.

The easing functions produced by keyword values.
3 次ベジェ easing 関数用の各キーワード値により生産される,easing 関数。 The easing functions produced by each of the cubic Bézier easing function keyword values.
easing 関数
linear
ease-in
ease-out
ease-in-out
ease
上の各 easing 関数 の動作においては、 各円形の left プロパティに対し, 3 秒間のアニメーションが適用される (比較対照用に linear も供される)。 The above easing functions in action, each applied to a 3s animation of the circles' left property. A linear easing is provided for contrast.

2.2.1. 直列化法

次に挙げるキーワードは、 それ自身に直列化される :ease-in, ease-out, ease-in-out, ease The ease-in, ease-out, ease-in-out, and ease keywords serialize as themselves.

3 次ベジェ easing 関数を直列化する アルゴリズムは、 所与の ( 3 次ベジェ easing 関数 関数 ) に対し: To serialize a cubic-bezier() function:

  1. 引数文字列 :← 次を順に ", " で連結する関数 の[ 1 個目, 2 個目, 3 個目, 4 個目 ]の引数を <number> として直列化した結果 ↓ Let s be the string "cubic-bezier(".Serialize the function’s four arguments as <number>s, concatenate the results using the separator ", ", and append the result to s.
  2. RETURN 次を順に連結する"cubic-bezier(", 引数文字列, ")" Append ")" to s, and return it.

2.2.2. 出力

3 次ベジェ easing 出力進捗を計算する アルゴリズムは、 所与の ( 3 次ベジェ easing 関数 関数, 入力進捗値 入力進捗 ) に対し,出力進捗値を返す: To calculate cubic Bézier easing output progress for a given cubic Bézier easing function func and an input progress value inputProgress, perform the following. It returns an output progress value.

  1. p0 :← 点 ( 0, 0 ) Let p0 be the point (0,0),\
  2. p1 :← 関数 の ( 1 個目の引数, 2 個目の引数 ) により与えられる点 p1 be the point given by func’s first two arguments,\
  3. p2 :← 関数 の ( 3 個目の引数, 4 個目の引数 ) により与えられる点 p2 be the point given by func’s second two arguments,\
  4. p3 :← 点 ( 1, 1 ) and p3 be the point (1,1).
  5. IF[ 0 入力進捗入力進捗 1 ] :RETURN [ 端点 p0, p3, 制御点 p1, p2 ]により定義される 3 次ベジェ曲線において, x 値 入力進捗 に対応する y 値 If inputProgress is within the range [0,1] (inclusive), return the y value corresponding to inputProgress as an x value for the cubic Bézier curve defined as having p0 and p3 as endpoints, and p1 and p2 as control points.

    ベジェ曲線の評価を受け持つ資料は、 [FUND-COMP-GRAPHICS] など,数多くある。 The evaluation of this curve is covered in many sources, such as [FUND-COMP-GRAPHICS].

    他の場合、 ベジェ曲線は,端点における接線を利用して無限に延伸される。 この接線は、 以下に従って得られる 2 個の点 t1, t2 を通過する直線として定義される。 Otherwise, the curve is extended infinitely, using the tangent of the curve at the endpoints. This tangent is defined as the line between two points,\

  6. ( t1, t2 ) :← ( ε, ε ) t1 and t2.
  7. IF入力進捗 < 0 ]: • If inputProgress is less than 0,\

    1. t1p0 let t1 be p0.
    2. IFp1 の x 値 > 0 ] :t2p1 • If the x value of p1 is greater than 0, let t2 be p1.
    3. ELSE IFp2 の x 値 > 0 ] :t2p2 • Otherwise, if the x value of p2 is greater than 0, let t2 be p2.
    4. ELSERETURN 0 • Otherwise, return 0.
  8. ELSE入力進捗 > 1 ): • If inputProgress is greater than 1,\

    1. t2p3 let t2 be p3.
    2. IFp2 の x 値 < 1 ] :t1p2 • If the x value of p2 is less than 1, let t1 be p2.
    3. ELSE IFp1 の x 値 < 1 ] :t1p1 • Otherwise, if the x value of p1 is less than 1, let t1 be p1.
    4. ELSERETURN 1 • Otherwise, return 1.
  9. RETURN t1, t2 を通過する直線において,x 値 入力進捗 に対応する y 値 Return the y value corresponding to inputProgress as an x value for the line passing through t1 and t2.

2.3. 階段 easing 関数: step-start, step-end, steps()()

階段 easing 関数step easing function ) は、 入力区間 [0, 1] を指定された個数の区間に等分して, それら各区間の中では出力を一定に保つ easing 関数である。 それは、 段数 , 段位置 で定義される。 その構文は: A step easing function is an easing function that divides the input time into a specified number of intervals that are equal in length, and holds the output steady within each of those intervals. It is defined by a number of steps, and a step position. It has the following syntax:

<step-easing-function>
	= step-start
	| step-end
	| <steps()>
<steps()>
	= steps( <integer>, <step-position>? )
<step-position>
	= jump-start
	| jump-end
	| jump-none
	| jump-both
	| start
	| end

各種 値の意味は: The meaning of each value is as follows:

step-start
easing 区間の始端にて,開始時の値から終了時の値へ跳ね上がる。 Jumps from the starting to the ending value at the start of the easing interval.
steps(1, start) に算出される。 Computes to steps(1, start)
step-end
easing 区間の終端にて,開始時の値から終了時の値へ跳ね上がる。 Jumps from the starting to the ending value at the end of the easing interval.
steps(1, end) に算出される。 Computes to steps(1, end)
Example step easing keywords.
階段 easing 関数の各種キーワード値の例。 Example step easing function keyword values.
steps()
1 個目の引数 <integer> は、 段数を指定する。 入力区間 [0, 1] は,この段数で等分され、 各区間の中では,出力進捗値は一定になる。 出力進捗値は、 <step-position> に指定されたキーワード — 省略された場合の既定は end — に則って決定される。 Divides the input interval into a number of equal steps specified by the <integer>. Within each interval, the output progress value is constant, and is determined according to the <step-position> keyword. If omitted, the <step-position> keyword defaults to end.
<integer> は、 <step-position> に応じて[ jump-none ならば 2 以上/ 他の場合は 1 以上 ]でなければならない — さもなければ,当の関数は無効になる。 If the <step-position> is jump-none, the <integer> must be at least 2, or the function is invalid. Otherwise, the <integer> must be at least 1, or the function is invalid.

2 個目の引数 <step-position> は、 次に挙げるキーワードをとる — それは、 段位置を指定する: The <step-position> keywords are:

jump-start
最初の区間における出力進捗値は ( 1 ÷ 段数 ) になる。 The first interval has an output progress value of 1/steps,\
区間どうしの段差は ( 1 ÷ 段数 ) になる。 and subsequent intervals rise by 1/steps.
(始端にて “跳ね上がる” 。 0 を返す段は無い。) (It "jumps at the start", with no step returning 0.)
jump-end
最初の区間における出力進捗値は 0 になる。 The first interval has an output progress value of 0,\
区間どうしの段差は ( 1 ÷ 段数 ) になる。 and subsequent intervals rise by 1/steps.
(終端にて “跳ね上がる” 。 1 を返す段は無い。) (It "jumps at the end", with no step returning 1.)
jump-none
最初の区間における出力進捗値は 0 になる。 The first interval has an output progress value of 0,\
区間どうしの段差は ( 1 ÷ ( 段数 1 ) ) になる。 and subsequent intervals rise by 1/(steps-1).
(始端, 終端にて “跳ね上がる” ことはない。 0 を返す段, 1 を返す段はどちらもある。) (It "never jumps", with steps returning both 0 and 1.)
jump-both
最初の区間における出力進捗値は ( 1 ÷ ( 段数 + 1 ) ) になる。 The first interval has an output progress value of 1/(steps+1),\
区間どうしの段差は ( 1 ÷ ( 段数 + 1 ) ) になる。 and subsequent intervals rise by 1/(steps+1).
(始端, 終端にて “跳ね上がる” 。 0 を返す段, 1 を返す段はどちらも無い。) (It "jumps at both ends", with no steps returning 0 or 1.)
start
jump-start としてふるまう。 Behaves as jump-start.
end
jump-end としてふるまう。 Behaves as jump-end.

これらの jump-* キーワード値を以下に図示する: The jump-* keywords values are illustrated below:

Example step easing functions.
階段 easing 関数の例。 Example step easing functions.
easing 関数
linear
steps(3, jump-start)
steps(3, jump-end)
steps(3, jump-none)
steps(3, jump-both)
比較用に linear の動作も供される。 各 steps(3, ...) 関数は、 アニメーションを 3 個の[ 出力が一定な期間 ]に等分する — それらは、 段差および[ 最初/最後 ]の期間における出力が[ 0 / 1 ]になるか否かに関して相違する。 The above easing functions in action, with a linear provided for comparison. Each steps(3, ...) function divides the animation into three constant periods; they differ only on what the value is within each period.

2.3.1. 直列化法

他の easing 関数用のキーワードとは違って、[ step-startstep-end ]は,それ自身として直列化しないこと — それらは、 代わりに[ "steps(1, start)" / "steps(1)" ]として直列化される。 Unlike the other easing function keywords, step-start and step-end do not serialize as themselves. Instead, they serialize as "steps(1, start)" and "steps(1)", respectively.

階段 easing 関数を直列化する アルゴリズムは、 所与の ( 階段 easing 関数 関数 ) に対し: To serialize a steps() functions:

  1. 段位置文字列 :← 空文字列
  2. IF関数段位置 { end, jump-end } ] :段位置文字列 ← 次を順に連結する", ", 関数段位置をキーワードとして直列化した結果
  3. RETURN 次を順に連結する"steps(", 関数段数を直列化した結果, 段位置文字列, ")" Let s be the string "steps(".Serialize the function’s steps, and append it to s.If the function’s step position is end or jump-end, append ")" to s and return s.Otherwise, append ", " to s. Serialize the step position as a keyword, and append the result to s. Append ")" to s. Return s.

2.3.2. 出力

階段 easing 出力進捗を計算する アルゴリズムは、 所与の ( 階段 easing 関数 関数, 入力進捗値 入力進捗, 直前フラグ (省略時は false ) ) に対し,出力進捗値を返す: To calculate step easing output progress for a given step easing function func, an input progress value inputProgress, and an optional before flag (defaulting to false), perform the following. It returns an output progress value.

  1. IF直前フラグ true ] :RETURN 0 If the before flag is true, return 0.
  2. 段数 :← 関数段数 Let steps be func’s steps,\
  3. 段位置 :← 関数段位置 and position be func’s step position.
  4. IF入力進捗 < 0 ] :RETURN 0
  5. IF入力進捗 1 ] :RETURN 1
  6. 区間 :← 次を満たす最大な整数 :区間 < 入力進捗 × 段数

    注記: 言い換えれば、 区間と区間の境目は,後にある区間に属する。

    Divide the interval [-∞, ∞] into several segments, each with an associated value, as follows: • ↑ [-∞, 0) has the value 0. • ↑ [1, ∞] has the value 1. • [0, 1) is divided into steps half-open intervals, [0, ...) to [..., 1)\ ↓ with their values assigned as defined for the position (see <step-position>).Note: In other words, at the boundary between intervals, the associated value is the higher value.
  7. RETURN ( 段位置 に応じて定義される最初の区間における出力進捗値 ) + ( 段位置 に応じて定義される段差 ) × 区間 Return the associated value for the interval that inputProgress is in.

2.4. 直列化

easing 関数は、 [CSSOM] に定義される共通な直列化パタンに加えて, 次の追加の要件を利用して直列化される: Easing functions are serialized using the common serialization patterns defined in [CSSOM] with the following additional requirements:

  • 次に挙げるキーワード値は、 同じ文字列に直列化する :ease, linear, ease-in, ease-out, ease-in-out

    これらは、 等価な[ cubic-bezier()linear() ]関数には変換されない

    The keyword values ease, linear, ease-in, ease-out, and ease-in-out are serialized as-is, that is, they are not converted to the equivalent cubic-bezier() or linear() function before serializing.
  • 階段 easing 関数[ steps() 関数 / step-startstep-end ]は、 段位置に応じて,次の形に直列化する: Step easing functions, whether they are specified using the steps() function or either of the step-start or step-end keywords, are serialized as follows:

    • jump-endend ならば :steps(<integer>) If the step position is jump-end or end, serialize as steps(<integer>).
    • 他の場合は :steps(<integer>, <step-position>) Otherwise, serialize as steps(<integer>, <step-position>).
  • linear() を介して作成された線型 easing 関数 関数 は、 次の結果に直列化される :線型 easing 関数を直列化する( 関数 ) A linear easing function created via linear() is serialized by getting its serialized computed value.

プライバシーの考慮点

この仕様に対し報告された,新たなプライバシーの考慮点は、無い。 No new privacy considerations have been reported on this specification.

この仕様は、 他の仕様から参照できる共通な定義を供するものであり, Web プラットフォームに新たな能力を直に導入することはない。 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.

セキュリティの考慮点

easing 関数は、 大概は[ 範囲 [0, 1] に入る入力進捗値をとり, 範囲 [0, 1] に入る出力進捗値を生産する ]が,常にそうなるとは限らない。 この仕様に定義される特能を参照している仕様は、 そのことを考慮するべきである — easing 関数の応用は、[ 入力や出力がこの範囲に入らないときのふるまい ]を定義して,[ 新たなセキュリティ考慮点を導入しない ]ことを確保するべきである。 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.

変更点

2024年 8月 28日 作業草案 からの変更点 3.1. Changes since the FPWD of 28 August 2024
【 変更点はあるが,まだ述べられていない。 】
レベル 1 からの追加 3.2. Additions Since Level 1
linear() 関数を追加した。 Added linear() function.

謝辞

この仕様は、 次に挙げる各氏により編集された CSS Transitions 仕様に基づいている :L. David Baron, Dean Jackson, David Hyatt, Chris Marrin 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\ … for their feedback and contributions.

Douglas Stockwell, Steve Block, Tab Atkins, Rachel Nabors, Martin Pitt, Animation at Work slack scommunity