Simple animation easing functions
Find a file
Renovate Bot c09b8c7b3b
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
chore(deps): update dependency credo to v1.7.6
2024-05-09 23:50:45 +12:00
config chore: migrate to local (#19) 2024-02-14 13:21:09 +13:00
lib Limit accuracy in tests to allow them to pass cross-platform. 2018-09-04 22:25:57 +12:00
test Initial release. 2017-02-17 11:40:56 +13:00
.drone.yml chore: fix docs release. 2024-03-14 19:21:59 +13:00
.formatter.exs Update dependencies and add CI setup. 2018-09-04 21:45:10 +12:00
.gitignore Initial release. 2017-02-17 11:40:56 +13:00
.tool-versions chore(deps): update dependency erlang to v26.2.5 2024-05-03 03:29:56 +12:00
CHANGELOG.md chore: release version v1.0.1 2024-02-23 09:57:32 +13:00
LICENSE.md chore!: Relicense to HL3-FULL. 2023-01-17 11:13:07 +13:00
mix.exs chore: release version v1.0.1 2024-02-23 09:57:32 +13:00
mix.lock chore(deps): update dependency credo to v1.7.6 2024-05-09 23:50:45 +12:00
README.md chore: fix typo in readme 2024-03-08 14:44:33 +13:00
renovate.json chore: Configure Renovate (#20) 2024-02-14 17:43:45 +13:00

Ease

Build Status Hex.pm Hippocratic License HL3-FULL

A generic implementation of standard easing functions for use in animation or robotics.

For examples of "standard" easing algorithms (in this case used in CSS animations) take a look at easings.net

Installation

Ease is available in Hex, the package can be installed by adding ease to your list of dependencies in mix.exs:

def deps do
  [
    {:ease, "~> 1.0.1"}
  ]
end

Documentation for the latest release can be found on HexDocs and for the main branch on docs.harton.nz.

Usage

You can use an easing function directly from within your own loop, provided that you can supply the four arguments needed;

  • current_time - the elapsed "time" in the loop, ie if your duration is ten, and you want to find the position for half way through the duration then you set it to 5. Units are arbitrary (steps, ms, whatever).
  • start_value - the initial value or position at current_time of zero.
  • change_in_value- how much the start_value should be changed by the end of the animation, ie the expected final value minus the start_value.
  • duration - the duration of the animation, in the same units as current_time.

Given a quadratic ease-in of 1..10, over 1 unit of time, where would we be when half-way through:

iex> Ease.ease_in_quad(0.5, 1, 10, 1)
3.25

Plot the {x, y} positions for a circular ease-in:

iex> ys = 1..10
...> xs = Ease.map(ys, :ease_in_circular)
...> Enum.zip(xs, ys)
[{1.0, 1}, {1.0557280900008417, 2}, {1.2250356126078779, 3},
 {1.5147186257614298, 4}, {1.9377422517014504, 5}, {2.5166852264521173, 6},
 {3.291796067500631, 7}, {4.34314575050762, 8}, {5.876894374382339, 9},
 {10.0, 10}]

Github Mirror

This repository is mirrored on Github from it's primary location on my Forgejo instance. Feel free to raise issues and open PRs on Github.

License

This software is licensed under the terms of the HL3-FULL, see the LICENSE.md file included with this package for the terms.

This license actively proscribes this software being used by and for some industries, countries and activities. If your usage of this software doesn't comply with the terms of this license, then contact me with the details of your use-case to organise the purchase of a license - the cost of which may include a donation to a suitable charity or NGO.