Skip to content

Commit

Permalink
Animation.h:
Browse files Browse the repository at this point in the history
* Changing the nomenclature (variable renames) in animate().
  • Loading branch information
razterizer committed Nov 18, 2024
1 parent a353474 commit 6e380de
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Animation.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ struct TransitionAnimation
float ease_out_end_time_s = 0.f;

float animate(float time_s, float value_start, float value_stationary, float value_end,
std::function<float(float)>& ease_in_func, std::function<float(float)>& ease_out_func) const
std::function<float(float)>& ease_enter_func, std::function<float(float)>& ease_exit_func) const
{
float t_ease_in = math::value_to_param(time_s, ease_in_start_time_s, ease_in_end_time_s);
if (math::in_range<float>(t_ease_in, {}, 0.f, Range::FreeOpen))
float t_enter = math::value_to_param(time_s, ease_in_start_time_s, ease_in_end_time_s);
if (math::in_range<float>(t_enter, {}, 0.f, Range::FreeOpen))
return value_start;
if (math::in_range<float>(t_ease_in, 0.f, 1.f, Range::ClosedOpen))
return math::lerp(ease_in_func(t_ease_in), value_start, value_stationary);
float t_ease_out = math::value_to_param(time_s, ease_out_start_time_s, ease_out_end_time_s);
if (math::in_range<float>(t_ease_out, 0.f, 1.f, Range::ClosedOpen))
return math::lerp(ease_out_func(t_ease_out), value_stationary, value_end);
if (math::in_range<float>(t_ease_out, 1.f, {}, Range::ClosedFree))
if (math::in_range<float>(t_enter, 0.f, 1.f, Range::ClosedOpen))
return math::lerp(ease_enter_func(t_enter), value_start, value_stationary);
float t_exit = math::value_to_param(time_s, ease_out_start_time_s, ease_out_end_time_s);
if (math::in_range<float>(t_exit, 0.f, 1.f, Range::ClosedOpen))
return math::lerp(ease_exit_func(t_exit), value_stationary, value_end);
if (math::in_range<float>(t_exit, 1.f, {}, Range::ClosedFree))
return value_end;
return value_stationary;
}
Expand Down

0 comments on commit 6e380de

Please sign in to comment.