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()
Link to this type

easing_function_or_tuple()

View Source

Specs

easing_function_or_tuple() :: easing_function() | easing_tuple()

Specs

easing_tuple() :: {atom(), atom()}

Specs

easings() :: [float()]

Specs

range() :: %Easing.Range{first: number(), last: number(), step: number()}

Link to this section Functions

Specs

back_in(float()) :: float()

Back in easing function

Back in easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.back_in(0.1)
-0.014314220000000004

Specs

back_in_out(float()) :: float()

Back in-out easing function

Back in-out easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.back_in_out(0.1)
-0.037518552000000004

Specs

back_out(float()) :: float()

Back out easing function

Back out easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.back_out(0.1)
0.40882797999999987

Specs

bounce_in(float()) :: float()

Bounce in easing function

Bounce in easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.bounce_in(0.1)
0.01187500000000008

Specs

bounce_in_out(float()) :: float()

Bounce in-out easing function

Bounce in-out easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.bounce_in_out(0.1)
0.030000000000000027

Specs

bounce_out(float()) :: float()

Bounce out easing function

Bounce out easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.bounce_out(0.1)
0.07562500000000001

Specs

circular_in(float()) :: float()

Circular in easing function

Circular in easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.circular_in(0.1)
0.005012562893380035
Link to this function

circular_in_out(progress)

View Source

Specs

circular_in_out(float()) :: float()

Circular in-out easing function

Circular in-out easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.circular_in_out(0.1)
0.010102051443364402

Specs

circular_out(float()) :: float()

Circular out easing function

Circular out easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.circular_out(0.1)
0.4358898943540673

Specs

cubic_in(float()) :: float()

Cubic in easing function

Cubic in easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.cubic_in(0.1)
0.0010000000000000002

Specs

cubic_in_out(float()) :: float()

Cubic in-out easing function

Cubic in-out easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.cubic_in_out(0.1)
0.004000000000000001

Specs

cubic_out(float()) :: float()

Cubic out easing function

Cubic out easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.cubic_out(0.1)
0.2709999999999999

Specs

elastic_in(float()) :: float()

Elastic in easing function

Elastic in easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.elastic_in(0.1)
0.001953125
Link to this function

elastic_in_out(progress)

View Source

Specs

elastic_in_out(float()) :: float()

Elastic in-out easing function

Elastic in-out easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.elastic_in_out(0.1)
3.39156597005722e-4

Specs

elastic_out(float()) :: float()

Elastic out easing function

Elastic out easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.elastic_out(0.1)
1.25
Link to this function

exponential_in(progress)

View Source

Specs

exponential_in(float()) :: float()

Exponential in easing function

Exponential in easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.exponential_in(0.1)
0.001953125
Link to this function

exponential_in_out(progress)

View Source

Specs

exponential_in_out(float()) :: float()

Exponential in-out easing function

Exponential in-out easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.exponential_in_out(0.1)
0.001953125
Link to this function

exponential_out(progress)

View Source

Specs

exponential_out(float()) :: float()

Exponential out easing function

Exponential out easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.exponential_out(0.1)
0.5

Specs

linear_in(float()) :: float()

Linear in easing function

Example

iex> Easing.linear_in(0.1)
0.1

Specs

linear_in_out(float()) :: float()

Linear in-out easing function

Example

iex> Easing.linear_in_out(0.1)
0.1

Specs

linear_out(float()) :: float()

Linear out easing function

Example

iex> Easing.linear_out(0.1)
0.1

Specs

quadratic_in(float()) :: float()

Quadratic in easing function

Quadratic in easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.quadratic_in(0.1)
0.010000000000000002
Link to this function

quadratic_in_out(progress)

View Source

Specs

quadratic_in_out(float()) :: float()

Quadratic in-out easing function

Quadratic in-out easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.quadratic_in_out(0.1)
0.020000000000000004

Specs

quadratic_out(float()) :: float()

Quadratic out easing function

Quadratic out easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.quadratic_out(0.1)
0.18999999999999995

Specs

quartic_in(float()) :: float()

Quartic in easing function

Quartic in easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.quartic_in(0.1)
1.0000000000000002e-4
Link to this function

quartic_in_out(progress)

View Source

Specs

quartic_in_out(float()) :: float()

Quartic in-out easing function

Quartic in-out easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.quartic_in_out(0.1)
8.000000000000001e-4

Specs

quartic_out(float()) :: float()

Quartic out easing function

Quartic out easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.quartic_out(0.1)
0.3439

Specs

quintic_in(float()) :: float()

Quintic in easing function

Quintic in easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.quintic_in(0.1)
1.0000000000000003e-5
Link to this function

quintic_in_out(progress)

View Source

Specs

quintic_in_out(float()) :: float()

Quintic in-out easing function

Quintic in-out easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.quintic_in_out(0.1)
1.6000000000000004e-4

Specs

quintic_out(float()) :: float()

Quintic out easing function

Quintic out easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.quintic_out(0.1)
0.40950999999999993
Link to this function

run(easing_function, progress)

View Source

Specs

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 and 1 that represents the % of the animation state.
  • options: keyword list
    • round: true - will round the result up with a precision of 2

Specs

sine_in(float()) :: float()

Sine in easing function

Sine in easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.sine_in(0.1)
0.01231165940486223

Specs

sine_in_out(float()) :: float()

Sine in-out easing function

Sine in-out easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.sine_in_out(0.1)
0.024471741852423234

Specs

sine_out(float()) :: float()

Sine out easing function

Sine out easing visualizations created by Andrey Sitnik and Ivan Solovev

Example

iex> Easing.sine_out(0.1)
0.15643446504023087
Link to this function

stream(range, easing_function)

View Source

Specs

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

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]