View Source Easing.Range (easing v0.3.1)

Range struct for Easing

This struct is basically a reimplementation of Elixir's Range struct but removing the limitations on only working with Integer constraints and steps

Link to this section Summary

Functions

Creates a new Easing.Range struct from a desired duration and target fps

Convenience function for creating a new Easing.Range struct

Returns the size of the Easing.Range

Link to this section Types

Specs

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

Link to this section Functions

Link to this function

calculate(duration_in_ms, fps)

View Source

Specs

calculate(integer(), integer()) :: range()

Creates a new Easing.Range struct from a desired duration and target fps

  • duration_in_ms - total duration of the animation, only accepts Integer
  • fps - target frames per second of the animation, only accepts Integer

Examples:

iex> Easing.Range.calculate(1000, 1)
%Easing.Range{first: 0, last: 1, step: 1.0}

Specs

new(number(), number(), number()) :: range()

Convenience function for creating a new Easing.Range struct

  • first: represents the starting % of the range. Value should be: value >= 0 and < 1
  • last: represents the ending % of the range. Value should be: value > 0 and <= 1
  • step: value representing what the incremental value is between first and last. Can represent

Specs

size(range()) :: integer()

Returns the size of the Easing.Range

Sizes are inclusive across a range. So a range from 0 - 1 with a step of 0.1 will have 11 values, not 10 because the 0 value is included in that result.

Examples:

iex> Easing.Range.calculate(1000, 60) |> Easing.Range.size()
61