doodle.interact.animation

Type members

Classlikes

sealed
trait Interpolation[A]

An Interpolation represents a range of values between a starting and ending value. The interpolation is also optionally transformed by an easing function. The starting value is mapped to 0.0 and the ending value to 1.0. When a number of steps is specified the interpolation is transformed into a transducer, which may be run or composed with other transducers.

An Interpolation represents a range of values between a starting and ending value. The interpolation is also optionally transformed by an easing function. The starting value is mapped to 0.0 and the ending value to 1.0. When a number of steps is specified the interpolation is transformed into a transducer, which may be run or composed with other transducers.

Interpolations may be transformed by map and product (functor and semigroupal) to construct more complex interpolations.

The differences between an interpolation and a transducer are as follows:

  • An interpolation specifies a start and end value. When a number of steps is given it becomes a transducer. When interpolations are combined in parallel, with product, they always take the same amount of time when converted to a transducer. Transducers combined in parallel may take differing amounts of time.

  • A transducer can represent arbitrary FSMs, while an interpolation moves from start to end value.

  • Transducers can be run. Interpolations must be transformed to transducers to run.

Companion
object
Companion
class
trait Interpolator[A]

An interpolator constructs a transducer from a starting value, a stopping value, and the number of elements or steps to produce between these values.

An interpolator constructs a transducer from a starting value, a stopping value, and the number of elements or steps to produce between these values.

Companion
object
Companion
class
trait Transducer[Output]

A Transducer represents an animation that starts in some initial state and proceeds through various states until it stops. For example, a square might move from an x position of 0 to an x position of 100 in increments of 10. The states then become 0, 10, 20, ..., 100.

A Transducer represents an animation that starts in some initial state and proceeds through various states until it stops. For example, a square might move from an x position of 0 to an x position of 100 in increments of 10. The states then become 0, 10, 20, ..., 100.

More abstractly, a transducer is a finite state machine with an additional set of output values, so that each state is associated with some output value. Continuing the example of the moving square, the states are the x position and the output is the square at the given position (for some fixed y coordinate).

Transducers should be treated like half open intervals, which means they should generate the inital state but avoid generating a stopping state when possible (for example, when combined in sequence with another transducer).

Transducers have several type classes instances:

  • Traverse
  • Applicative
  • Monoid, corresponding to sequential composition (++)

The majority of the API is provided by the Cats methods defined on these type classes, so import cats.implicits._ to get a richer API (e.g. toList, filter, etc.)

There is another possible monoid, which corresponds to parallel composition (and), if there is a monoid on the type A. Taken with ++ this makes Transducers a Rig or Semiring (depending on how one defines these terms; they are not always defined in the same way).

Companion
object
object Transducer
Companion
class