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
Next Next commit
Calculating progress & serialising linear-spline
  • Loading branch information
jakearchibald committed Jun 24, 2022
commit b4bad72badae2a40035e2b114324f5aa472fe109
108 changes: 107 additions & 1 deletion css-easing-2/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ Level: 2
Group: csswg
ED: https://drafts.csswg.org/css-easing/
TR: https://www.w3.org/TR/css-easing-2/
Editor: Jake Archibald, Google, jakearchibald@google.com, w3cid 76394
Editor: Brian Birtles, Mozilla https://www.mozilla.org/, bbirtles@mozilla.com, w3cid 43194
Editor: Dean Jackson, Apple Inc https://www.apple.com/, dino@apple.com, w3cid 42080
Editor: Matt Rakow, Microsoft, w3cid 62267
Former Editor: Shane Stephens, Google, shans@google.com, w3cid 47691
Markup Shorthands: markdown yes

Abstract: This CSS module describes a way for authors to define a transformation
that controls the rate of change of some value.
Expand Down Expand Up @@ -121,7 +123,6 @@ The syntax for specifying an [=easing function=] is as follows:
<<cubic-bezier-easing-function>> |
<<step-easing-function>></div>


<h3 id=the-linear-easing-function oldids=linear-timing-function-section>The linear easing function: ''linear''</h3>

The <dfn export lt="linear easing function|linear timing function">linear easing
Expand All @@ -132,6 +133,111 @@ meaning that its [=output progress value=] is equal to the
The syntax for the [=linear easing function=] is simply the
<dfn dfn-type=value for=easing-function>linear</dfn> keyword.

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

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 <dfn>linear spline easing point</dfn>
is a [=/struct=]
that has:

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

: <dfn>input</dfn>
:: A number or null

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

</dl>

<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>
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. If |point| is not the first [=list/item=] of |linearSplineEasingFunction|'s [=linear spline easing function/points=],
append "<code>, </code>" to |output|.

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

1. Append "`)`" to |output|.

1. Return |output|.

</section>

<section algorithm="to calculate linear spline output progress">

To <dfn export>calculate linear spline output progress</dfn>
for a given [=linear spline easing function=] |linearSplineEasingFunction|,
and an [=input progress value=] |inputProgress|,
perform the following.
It returns an [=output progress value=].

Note: TODO explain this with diagrams

1. Let |points| be |linearSplineEasingFunction|'s [=linear spline easing function/points=].

1. Let |pointAIndex| be the last [=list/item=] in |points| with an [=linear spline 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 spline easing point|point=] to compare to.

1. Let |pointA| be |points|[pointAIndex].

1. Let |pointB| be |points|[pointAIndex + 1].

1. If |pointA|'s [=linear spline easing point/input=] is equal to |pointB|'s [=linear spline easing point/input=],
return |pointB|'s [=linear spline easing point/output=].

1. Let |progressFromPointA| be |inputProgress| minus |pointA|'s [=linear spline easing point/input=].

1. Let |pointInputRange| be |pointB|'s [=linear spline easing point/input=] minus |pointA|'s [=linear spline easing point/input=].

1. Let |progressBetweenPoints| be |progressFromPointA| divided by |pointInputRange|.

1. Let |pointOutputRange| be |pointB|'s [=linear spline easing point/output=] minus |pointA|'s [=linear spline easing point/output=].

1. Let |outputFromLastPoint| be |progressBetweenPoints| multiplied by |pointOutputRange|.

1. Return |pointA|'s [=linear spline easing point/output=] plus |outputFromLastPoint|.

</section>

<h3 id=cubic-bezier-easing-functions oldids=cubic-bezier-timing-functions>Cubic
B&eacute;zier easing functions:
Expand Down