exmorph v0.1.0 Exmorph.Strings
Summary
Functions
Takes two arguments, a tween string (for instance, the string passed to Exmorph’s ~t sigil) and an enumerable. Returns a string with all bindings (designated by wrapping the binding names in curly braces) replaced with the corresponding values within the enumerable
Parses a tween string. The string is broken up into two-word chunks which are converted to key value pairs within a map. This map is eventually merged with %Exmorph.Tween{}
Functions
Takes two arguments, a tween string (for instance, the string passed to Exmorph’s ~t sigil) and an enumerable. Returns a string with all bindings (designated by wrapping the binding names in curly braces) replaced with the corresponding values within the enumerable.
If any of the binding names within the string are missing a corresponding key value / pair within the enumerable, an exception is thrown.
Examples
iex> params = %{"start" => 25, "end" => 50, "duration" => 10}
iex> Exmorph.Strings.interpolate_bindings("from {start} to {end} over {duration}s", params)
"from 25 to 50 over 10s"
Parses a tween string. The string is broken up into two-word chunks which are converted to key value pairs within a map. This map is eventually merged with %Exmorph.Tween{}.
Examples
iex> Exmorph.Strings.parse("from 25 to 75 over 1s")
%{duration: 1000000000, from: 25, to: 75}
iex> Exmorph.Strings.parse("from 25 to 75 over 1.5s ease cubic_out")
%{duration: 1.5e9, easing: :cubic_out, from: 25, to: 75}