Antkeeper  0.0.1
Public Types | Public Member Functions | List of all members
tween< T, S > Class Template Reference

Container which stores two states along with an interpolator, for quick and easy tween<T, S>ing. More...

#include <tween.hpp>

Public Types

typedef T value_type
 
typedef S scalar_type
 
typedef std::decay< std::function< value_type(const value_type &, const value_type &, scalar_type)> >::type interpolator_type
 

Public Member Functions

 tween (const value_type &state0, const value_type &state1, interpolator_type interpolator=tween< T, S >::interpolator_error)
 Creates a tween. More...
 
 tween (const value_type &value, interpolator_type interpolator=tween< T, S >::interpolator_error)
 Creates a tween. More...
 
 tween ()
 Creates a tween. More...
 
const value_typeoperator[] (int i) const
 Returns a reference to the specified tween state. More...
 
value_typeoperator[] (int i)
 S>::operator[](int) const More...
 
value_type operator[] (scalar_type a) const
 S>::interpolate(scalar_type) const More...
 
value_type interpolate (scalar_type a) const
 Returns an interpolated state between state 0 and state 1. More...
 
void set_interpolator (const interpolator_type &interpolator)
 Sets the function used to interpolate between states 0 and 1. More...
 
const interpolator_typeget_interpolator () const
 Returns the function used to interpolate between states 0 and 1. More...
 
void update ()
 Sets state 0 = state 1. More...
 
void swap ()
 Swaps state 0 and state 1. More...
 

Detailed Description

template<class T, class S = float>
class tween< T, S >

Container which stores two states along with an interpolator, for quick and easy tween<T, S>ing.

Template Parameters
TValue type.
SScalar type.

Definition at line 35 of file tween.hpp.

Member Typedef Documentation

◆ interpolator_type

template<class T , class S = float>
typedef std::decay<std::function<value_type(const value_type&, const value_type&, scalar_type)> >::type tween< T, S >::interpolator_type

Definition at line 42 of file tween.hpp.

◆ scalar_type

template<class T , class S = float>
typedef S tween< T, S >::scalar_type

Definition at line 41 of file tween.hpp.

◆ value_type

template<class T , class S = float>
typedef T tween< T, S >::value_type

Definition at line 40 of file tween.hpp.

Constructor & Destructor Documentation

◆ tween() [1/3]

template<class T , class S >
tween< T, S >::tween ( const value_type state0,
const value_type state1,
interpolator_type  interpolator = tween<T, S>::interpolator_error 
)

Creates a tween.

Parameters
state0Initial value of state 0.
state1Initial value of state 1.
interpolatorFunction used to interpolate between states 0 and 1.

Definition at line 134 of file tween.hpp.

◆ tween() [2/3]

template<class T , class S >
tween< T, S >::tween ( const value_type value,
interpolator_type  interpolator = tween<T, S>::interpolator_error 
)
explicit

Creates a tween.

Parameters
valueInitial value of states 0 and 1.
interpolatorFunction used to interpolate between states 0 and 1.

Definition at line 128 of file tween.hpp.

◆ tween() [3/3]

template<class T , class S >
tween< T, S >::tween

Creates a tween.

Definition at line 140 of file tween.hpp.

Member Function Documentation

◆ get_interpolator()

template<class T , class S >
const tween< T, S >::interpolator_type & tween< T, S >::get_interpolator
inline

Returns the function used to interpolate between states 0 and 1.

Definition at line 175 of file tween.hpp.

◆ interpolate()

template<class T , class S >
tween< T, S >::value_type tween< T, S >::interpolate ( scalar_type  a) const
inline

Returns an interpolated state between state 0 and state 1.

If no interpolator is set, state 1 will be returned.

Parameters
aInterpolation factor on [0.0, 1.0].
Returns
Interpolated state, or state 1 if no interpolator is set.

Definition at line 163 of file tween.hpp.

◆ operator[]() [1/3]

template<class T , class S >
tween< T, S >::value_type & tween< T, S >::operator[] ( int  i)
inline

S>::operator[](int) const

S>::operator[](int) const

Definition at line 151 of file tween.hpp.

◆ operator[]() [2/3]

template<class T , class S >
const tween< T, S >::value_type & tween< T, S >::operator[] ( int  i) const
inline

Returns a reference to the specified tween state.

Parameters
iIndex of a tween state. Should be either 0 or 1.
Returns
Reference to the specified tween state.

Definition at line 145 of file tween.hpp.

◆ operator[]() [3/3]

template<class T , class S >
tween< T, S >::value_type tween< T, S >::operator[] ( scalar_type  a) const
inline

S>::interpolate(scalar_type) const

S>::interpolate(scalar_type) const

Definition at line 157 of file tween.hpp.

◆ set_interpolator()

template<class T , class S >
void tween< T, S >::set_interpolator ( const interpolator_type interpolator)
inline

Sets the function used to interpolate between states 0 and 1.

Parameters
interpolatorInterpolator function.

Definition at line 169 of file tween.hpp.

◆ swap()

template<class T , class S >
void tween< T, S >::swap
inline

Swaps state 0 and state 1.

Definition at line 187 of file tween.hpp.

◆ update()

template<class T , class S >
void tween< T, S >::update
inline

Sets state 0 = state 1.

Definition at line 181 of file tween.hpp.


The documentation for this class was generated from the following file: