exmorph v1.0.2 Exmorph

Summary

Functions

Alias for Exmorph.tween/1

Returns an %Exmorph.Tween{}, decoding the attributes for the tween from the provided string (see Exmorph.Strings.parse/1)

Returns the current value for an %Exmorph.Tween{}, using the current time to determine how much time has elasped since the tween’s started_at time. Optionally, a time tuple (as in, one that would be parsed with Exmorph.Time) can be passed as the second argument. This will return the value as it would exist after that amount of time had elapsed

Functions

sigil_t(string, opts)

Alias for Exmorph.tween/1.

tween(string)

Returns an %Exmorph.Tween{}, decoding the attributes for the tween from the provided string (see Exmorph.Strings.parse/1).

tween_value(tween)

Returns the current value for an %Exmorph.Tween{}, using the current time to determine how much time has elasped since the tween’s started_at time. Optionally, a time tuple (as in, one that would be parsed with Exmorph.Time) can be passed as the second argument. This will return the value as it would exist after that amount of time had elapsed.

If the time elapsed exceeds the duration of the tween, the tween’s to (final) value is returned.

Examples

iex> Exmorph.tween("from 0 to 100 over 10s") |> Exmorph.tween_value() |> round
0

iex> Exmorph.tween("from 0 to 100 over 10s") |> Exmorph.tween_value({4, :seconds}) |> round
40

iex> Exmorph.tween("from 0 to 100 over 10s") |> Exmorph.tween_value({20, :seconds}) |> round
100
tween_value(tween, time)