Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b4bad72
Calculating progress & serialising linear-spline
jakearchibald Jun 24, 2022
1c326ef
Define function creation
jakearchibald Jun 24, 2022
1e5b11d
Update largest number when inferring 0 for the first item
jakearchibald Jun 24, 2022
a4c01be
Simplify serialisation
jakearchibald Jun 27, 2022
8276f40
Spec tidy up
jakearchibald Jun 27, 2022
0e5043f
Connecting parsing and serialising
jakearchibald Jun 27, 2022
f621932
Fix indenting
jakearchibald Jun 27, 2022
ef29eae
Dark mode figures
jakearchibald Jul 6, 2022
2739467
Merge remote-tracking branch 'origin/main' into css-easing-2-linear-s…
jakearchibald Jul 6, 2022
05473a9
Markdown headings
jakearchibald Jul 6, 2022
f3c7508
Switch back to linear()
jakearchibald Jul 6, 2022
973a84a
Missed a few old spline references
jakearchibald Jul 7, 2022
c6fe005
Examples
jakearchibald Jul 8, 2022
c51794a
Existing examples are good enough IMO
jakearchibald Jul 8, 2022
8e38422
Forgot to specify 'index'
jakearchibald Jul 8, 2022
8fbc910
Missing comma
jakearchibald Jul 8, 2022
5221e11
Adding serialization examples
jakearchibald Jul 10, 2022
589a383
Be more specific about the linear keyword
jakearchibald Jul 10, 2022
ce4c5d1
A little more specific about the serialization of linear()
jakearchibald Jul 11, 2022
932ce07
Apply suggestions from code review
jakearchibald Jul 12, 2022
a509029
Fixes following review
jakearchibald Jul 12, 2022
d75bd5c
Clarify note
jakearchibald Jul 12, 2022
bdbb745
Make all graphs transparent
jakearchibald Jul 17, 2022
17e0ad3
One more
jakearchibald Jul 17, 2022
8ee8bf2
Move examples after normative text
jakearchibald Jul 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify serialisation
  • Loading branch information
jakearchibald committed Jun 27, 2022
commit a4c01bef820f492721c7200f1861ebf6aad28e0d
182 changes: 80 additions & 102 deletions css-easing-2/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -135,26 +135,27 @@ The syntax for the [=linear easing function=] is simply the

<h3 id=the-linear-spline-easing-function>The linear spline easing function: ''linear-spline()''</h3>

<dfn function lt="linear-spline()">linear-spline(<<linear-spline-stop-list>>)</dfn>

<pre class="prod">
<dfn>&lt;linear-spline-stop-list></dfn> = [ <<linear-spline-stop>> ]#
<dfn>&lt;linear-spline-stop></dfn> = <<number>> && <<linear-spline-stop-length>>?
<dfn>&lt;linear-spline-stop-length></dfn> = <<percentage>>{1,2}
</pre>

''linear-spline()'' is parsed into a [=linear spline easing function=]
by calling [=create a linear easing function=],
passing in its <<linear-spline-stop-list>>.
There must be at least two <<linear-spline-stop>>s.

A <dfn export>linear spline easing function</dfn>
is an easing function
that interpolates linearly
between its [=linear spline easing function/points=].

A [=linear spline easing function=] has:

<dl dfn-for="linear spline easing function">

: <dfn>points</dfn>
:: a [=/list=] of [=linear spline easing points=].
Initially a new empty [=/list=].

: <dfn>serializable points</dfn>
:: a [=/list=] of [=linear spline easing points=].
Initially a new empty [=/list=].

Note: This is only used for producing a computed value.

</dl>
A [=linear spline easing function=] has <dfn for="linear spline easing function">points</dfn>,
a [=/list=] of [=linear spline easing points=].
Initially a new empty [=/list=].

A <dfn>linear spline easing point</dfn>
is a [=/struct=]
Expand All @@ -165,20 +166,79 @@ that has:
: <dfn>input</dfn>
:: A number or null

Note: This is only null during [=create a linear easing function=].

: <dfn>output</dfn>
:: A number

</dl>

<section algorithm="to create a linear easing function">

To <dfn>create a linear easing function</dfn>
from a <<linear-spline-stop-list>> |stopList|,
perform the following.
It returns a [=linear spline easing function=].

1. Let |function| be a new [=linear spline easing function=].

1. Let |largestInput| be negative infinity.

1. For each |stop| in |stopList|:

1. Let |point| be a new [=linear spline easing point=]
with its [=linear spline easing point/output=] set to |stop|'s <<number>> as a number.

1. [=list/Append=] |point| to |function|'s [=linear spline easing function/points=].

1. If |stop| has a <<linear-spline-stop-length>>, then:

1. Set |point|'s [=linear spline easing point/input=] to whichever is greater:
|stop|'s <<linear-spline-stop-length>>'s first <<percentage>> as a number,
or |largestInput|.

1. Set |largestInput| to |point|'s [=linear spline easing point/input=].

1. If |stop|'s <<linear-spline-stop-length>> has a second <<percentage>>, then:

1. Let |extraPoint| be a new [=linear spline easing point=]
with its [=linear spline easing point/output=] set to |stop|'s <<number>> as a number.

1. [=list/Append=] |extraPoint| to |function|'s [=linear spline easing function/points=].

1. Set |extraPoint|'s [=linear spline easing point/input=] to whichever is greater:
|stop|'s <<linear-spline-stop-length>>'s second <<percentage>> as a number,
or |largestInput|.

1. Set |largestInput| to |extraPoint|'s [=linear spline easing point/input=].

1. Otherwise, if |stop| is the first [=list/item=] in |stopList|, then:

1. Set |point|'s [=linear spline easing point/input=] to 0.

1. Set |largestInput| to |point|'s [=linear spline easing point/input=].

1. Otherwise, if |stop| is the last [=list/item=] in |stopList|,
then set |point|'s [=linear spline easing point/input=] to whichever is greater:
1 or |largestInput|.

1. For runs of [=list/items=] in |function|'s [=linear spline easing function/points=] that have a null [=linear spline easing point/input=],
assign a number to the [=linear spline easing point/input=] by linearly interpolating between the closest previous and next [=linear spline easing function/points=]
that have a non-null [=linear spline easing point/input=].

1. Return |function|.

</section>

<section algorithm="linear spline easing function">

To get a [=linear spline easing function=]'s (|linearSplineEasingFunction|) <dfn for="linear spline easing function" export>computed value</dfn>
To get a [=linear spline easing function=]'s (|linearSplineEasingFunction|) <dfn for="linear spline easing function" export>serialized computed value</dfn>
perform the following.
It returns a [=string=].

1. Let |output| be "`linear-spline(`".

1. [=list/For each=] |point| in |linearSplineEasingFunction|'s [=linear spline easing function/serializable points=]:
1. [=list/For each=] |point| in |linearSplineEasingFunction|'s [=linear spline easing function/points=]:

1. If |point| is not the first [=list/item=] of |linearSplineEasingFunction|'s [=linear spline easing function/points=],
append "<code>, </code>" to |output|.
Expand All @@ -187,8 +247,9 @@ It returns a [=string=].
as a <<number>>,
to |output|.

1. If |point|'s [=linear spline easing point/input=] is not null, append "<code> </code>"
followed by the computed value of |point|'s [=linear spline easing point/input=],
1. Append "<code> </code>" to |output|.

1. Append the computed value of |point|'s [=linear spline easing point/input=],
as a <<percentage>>
to |output|.

Expand Down Expand Up @@ -239,89 +300,6 @@ Note: TODO explain this with diagrams

</section>

<dfn function lt="linear-spline()">linear-spline(<<linear-spline-stop-list>>)</dfn>

<pre class="prod">
<dfn>&lt;linear-spline-stop-list></dfn> = [ <<linear-spline-stop>> ]#
<dfn>&lt;linear-spline-stop></dfn> = <<number>> && <<linear-spline-stop-length>>?
<dfn>&lt;linear-spline-stop-length></dfn> = <<percentage>>{1,2}
</pre>

<section algorithm="to create a linear easing function">

To <dfn>create a linear easing function</dfn>
from a <<linear-spline-stop-list>> |stopList|,
perform the following.
It returns a [=linear spline easing function=].

1. Let |function| be a new [=linear spline easing function=].

1. Let |largestInput| be negative infinity.

1. For each |stop| in |stopList|:

1. Let |point| be a new [=linear spline easing point=].

1. Let |serializablePoint| be a new [=linear spline easing point=].

1. [=list/Append=] |point| to |function|'s [=linear spline easing function/points=].

1. [=list/Append=] |serializablePoint| to |function|'s [=linear spline easing function/serializable points=].

1. Set |point|'s [=linear spline easing point/output=] to |stop|'s <<number>> as a number.

1. Set |serializablePoint|'s [=linear spline easing point/output=] to |stop|'s <<number>> as a number.

1. If |stop| has a <<linear-spline-stop-length>>, then:

1. Set |point|'s [=linear spline easing point/input=] to whichever is greater:
|stop|'s <<linear-spline-stop-length>>'s first <<percentage>> as a number,
or |largestInput|.

1. Set |largestInput| to |point|'s [=linear spline easing point/input=].

1. Set |serializablePoint|'s [=linear spline easing point/input=] to <<linear-spline-stop-length>>'s first <<percentage>> as a number.

1. If |stop|'s <<linear-spline-stop-length>> has a second <<percentage>>, then:

1. Let |extraPoint| be a new [=linear spline easing point=].

1. Let |extraSerializablePoint| be a new [=linear spline easing point=].

1. [=list/Append=] |extraPoint| to |function|'s [=linear spline easing function/points=].

1. [=list/Append=] |extraSerializablePoint| to |function|'s [=linear spline easing function/serializable points=].

1. Set |extraPoint|'s [=linear spline easing point/output=] to |stop|'s <<number>>.

1. Set |extraSerializablePoint|'s [=linear spline easing point/output=] to |stop|'s <<number>>.

1. Set |extraPoint|'s [=linear spline easing point/input=] to whichever is greater:
|stop|'s <<linear-spline-stop-length>>'s second <<percentage>> as a number,
or |largestInput|.

1. Set |largestInput| to |extraPoint|'s [=linear spline easing point/input=].

1. Set |extraSerializablePoint|'s [=linear spline easing point/input=] to <<linear-spline-stop-length>>'s second <<percentage>> as a number.

1. Otherwise, if |stop| is the first [=list/item=] in |stopList|, then:

1. Set |point|'s [=linear spline easing point/input=] to 0.

1. Set |largestInput| to |point|'s [=linear spline easing point/input=].

1. Otherwise, if |stop| is the last [=list/item=] in |stopList|,
then set |point|'s [=linear spline easing point/input=] to whichever is greater:
1 or |largestInput|.

1. For runs of [=list/items=] in |function|'s [=linear spline easing function/points=] that have a null [=linear spline easing point/input=],
assign a number to the [=linear spline easing point/input=] by linearly interpolating between the closest previous and next [=linear spline easing function/points=]
that have a non-null [=linear spline easing point/input=].

1. Return |function|.

</section>

<h3 id=cubic-bezier-easing-functions oldids=cubic-bezier-timing-functions>Cubic
B&eacute;zier easing functions:
''ease'', ''ease-in'', ''ease-out'', ''ease-in-out'', ''cubic-bezier()''</h3>
Expand Down