View Source Easing (easing v0.3.1)
Easing function calculations
Cribbed from: https://easings.net/
Link to this section Summary
Functions
Back in easing function
Back in-out easing function
Back out easing function
Bounce in easing function
Bounce in-out easing function
Bounce out easing function
Circular in easing function
Circular in-out easing function
Circular out easing function
Cubic in easing function
Cubic in-out easing function
Cubic out easing function
Elastic in easing function
Elastic in-out easing function
Elastic out easing function
Exponential in easing function
Exponential in-out easing function
Exponential out easing function
Linear in easing function
Linear in-out easing function
Linear out easing function
Quadratic in easing function
Quadratic in-out easing function
Quadratic out easing function
Quartic in easing function
Quartic in-out easing function
Quartic out easing function
Quintic in easing function
Quintic in-out easing function
Quintic out easing function
Easing calculation. Take a tupal of atoms {direction, type}
and the progress is a value
between 0 - 1 that represents the animation progress. (0 = beginning, 1 = end)
Sine in easing function
Sine in-out easing function
Sine out easing function
Generates a stream of animation frame values.
Generates a list of animation frame values.
Link to this section Types
Specs
easing_function() :: function()
Specs
easing_function_or_tuple() :: easing_function() | easing_tuple()
Specs
Specs
easings() :: [float()]
Specs
Link to this section Functions
Specs
Back in easing function
Example
iex> Easing.back_in(0.1)
-0.014314220000000004
Specs
Back in-out easing function
Example
iex> Easing.back_in_out(0.1)
-0.037518552000000004
Specs
Back out easing function
Example
iex> Easing.back_out(0.1)
0.40882797999999987
Specs
Bounce in easing function
Example
iex> Easing.bounce_in(0.1)
0.01187500000000008
Specs
Bounce in-out easing function
Example
iex> Easing.bounce_in_out(0.1)
0.030000000000000027
Specs
Bounce out easing function
Example
iex> Easing.bounce_out(0.1)
0.07562500000000001
Specs
Circular in easing function
Example
iex> Easing.circular_in(0.1)
0.005012562893380035
Specs
Circular in-out easing function
Example
iex> Easing.circular_in_out(0.1)
0.010102051443364402
Specs
Circular out easing function
Example
iex> Easing.circular_out(0.1)
0.4358898943540673
Specs
Cubic in easing function
Example
iex> Easing.cubic_in(0.1)
0.0010000000000000002
Specs
Cubic in-out easing function
Example
iex> Easing.cubic_in_out(0.1)
0.004000000000000001
Specs
Cubic out easing function
Example
iex> Easing.cubic_out(0.1)
0.2709999999999999
Specs
Elastic in easing function
Example
iex> Easing.elastic_in(0.1)
0.001953125
Specs
Elastic in-out easing function
Example
iex> Easing.elastic_in_out(0.1)
3.39156597005722e-4
Specs
Elastic out easing function
Example
iex> Easing.elastic_out(0.1)
1.25
Specs
Exponential in easing function
Example
iex> Easing.exponential_in(0.1)
0.001953125
Specs
Exponential in-out easing function
Example
iex> Easing.exponential_in_out(0.1)
0.001953125
Specs
Exponential out easing function
Example
iex> Easing.exponential_out(0.1)
0.5
Specs
Linear in easing function
Example
iex> Easing.linear_in(0.1)
0.1
Specs
Linear in-out easing function
Example
iex> Easing.linear_in_out(0.1)
0.1
Specs
Linear out easing function
Example
iex> Easing.linear_out(0.1)
0.1
Specs
Quadratic in easing function
Example
iex> Easing.quadratic_in(0.1)
0.010000000000000002
Specs
Quadratic in-out easing function
Example
iex> Easing.quadratic_in_out(0.1)
0.020000000000000004
Specs
Quadratic out easing function
Example
iex> Easing.quadratic_out(0.1)
0.18999999999999995
Specs
Quartic in easing function
Example
iex> Easing.quartic_in(0.1)
1.0000000000000002e-4
Specs
Quartic in-out easing function
Example
iex> Easing.quartic_in_out(0.1)
8.000000000000001e-4
Specs
Quartic out easing function
Example
iex> Easing.quartic_out(0.1)
0.3439
Specs
Quintic in easing function
Example
iex> Easing.quintic_in(0.1)
1.0000000000000003e-5
Specs
Quintic in-out easing function
Example
iex> Easing.quintic_in_out(0.1)
1.6000000000000004e-4
Specs
Quintic out easing function
Example
iex> Easing.quintic_out(0.1)
0.40950999999999993
Specs
run(easing_function_or_tuple(), float()) :: float()
Easing calculation. Take a tupal of atoms {direction, type}
and the progress is a value
between 0 - 1 that represents the animation progress. (0 = beginning, 1 = end)
- directions:
:in
,:out
, and:in_out
- types:
:sine
,:quadratic
,:cubic
,:quartic
,:quintic
, :exponential
,:circular
,:back
,:elastic
,:bounce
- progress: value between
0
and1
that represents the % of the animation state. - options: keyword list
- round:
true
- will round the result up with a precision of 2
- round:
Specs
Sine in easing function
Example
iex> Easing.sine_in(0.1)
0.01231165940486223
Specs
Sine in-out easing function
Example
iex> Easing.sine_in_out(0.1)
0.024471741852423234
Specs
Sine out easing function
Example
iex> Easing.sine_out(0.1)
0.15643446504023087
Specs
stream(range(), easing_function_or_tuple()) :: Enumerable.t()
Generates a stream of animation frame values.
A Range
is used for the range
argument. See the example
Examples:
iex> Easing.stream(%Easing.Range{first: 0, last: 1, step: 0.1}, &Easing.sine_in(&1)) |> Enum.to_list()
[0.0, 0.01231165940486223, 0.04894348370484647, 0.10899347581163221, 0.19098300562505255, 0.2928932188134524, 0.41221474770752675, 0.5460095002604533, 0.6909830056250525, 0.8435655349597688, 1.0]
iex> Easing.stream(%Easing.Range{first: 0, last: 0.5, step: 0.1}, {:bounce, :in_out}) |> Enum.to_list()
[0.0, 0.030000000000000027, 0.11375000000000002, 0.04499999999999993, 0.3487500000000001, 0.5]
Specs
to_list(range(), easing_function_or_tuple()) :: easings()
Generates a list of animation frame values.
A Range
is used for the range
argument. See the example
Examples:
iex> Easing.to_list(%Easing.Range{first: 0, last: 1, step: 0.1}, &Easing.sine_in(&1))
[0.0, 0.01231165940486223, 0.04894348370484647, 0.10899347581163221, 0.19098300562505255, 0.2928932188134524, 0.41221474770752675, 0.5460095002604533, 0.6909830056250525, 0.8435655349597688, 1.0]
iex> Easing.to_list(%Easing.Range{first: 0, last: 0.5, step: 0.1}, {:bounce, :in_out})
[0.0, 0.030000000000000027, 0.11375000000000002, 0.04499999999999993, 0.3487500000000001, 0.5]