View Source WeightedRandom.CubicBezier (weighted_random v0.2.0)
Copied from https://github.com/bjunc/cubic-bezier/tree/master Unfortunately the build seems to be broken so I could not use it directly.
Summary
Functions
Given x
(a float between 0.0
and 1.0
), compute the y
.
Functions
Given x
(a float between 0.0
and 1.0
), compute the y
.
Either an easing atom or control points tuple can be provided.
Most common easing equations are support, but if an unsupported atom
is given, the control points for :linear
are returned.
See: https://gist.github.com/terkel/4377409
Options
duration
(integer) - can provide greater accuracy.
The default duration is 400 (ms), which is a common animation / transition duration.
Examples
iex> WeightedRandom.CubicBezier.solve(0.50, :ease_out_quad)
0.7713235628639843
iex> WeightedRandom.CubicBezier.solve(0.5, {0.250, 0.460, 0.450, 0.940})
0.7713235628639843
iex(1)> Enum.map([0.0, 0.25, 0.5, 0.75, 1.0], fn x ->
...(1)> {x, Float.round(WeightedRandom.CubicBezier.solve(x, :ease_out_quad), 3)}
...(1)> end)
[{0.0, 0.0}, {0.25, 0.453}, {0.5, 0.771}, {0.75, 0.936}, {1.0, 1.0}]