15 return std::max(
std::min( max, x ), min );
22 x =
clamp( ( x - min ), 0.0, 1.0 );
26 x =
clamp( ( x - min ) / ( max - min ), 0.0, 1.0 );
29 return x * x * ( 3 - 2 *
x );
42 animated(
T def, std::chrono::system_clock::duration duration = std::chrono::milliseconds( 200 ) )
43 : _duration( duration )
64 auto duration_ms = std::chrono::duration_cast< std::chrono::microseconds >(
_duration ).
count();
65 auto t = (float)ms / duration_ms;
67 return static_cast< T >( _old * ( 1.f -
t ) + _new *
t );
69 operator T()
const {
return get(); }
float smoothstep(float x, float min, float max)
animated(T def, std::chrono::system_clock::duration duration=std::chrono::milliseconds(200))
std::chrono::system_clock::time_point _last_update
float clamp(float x, float min, float max)
std::chrono::system_clock::duration _duration
animated & operator=(const T &other)