From da21a5a971c2dfa3fdd729c4f799908253bb3873 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 22 May 2019 01:45:52 +0300 Subject: [PATCH] Turn interpolation action mode into an enum This makes it clearer what kind of interpolation is used and allows adding other types in the future. --- source/action.cpp | 6 +++--- source/action.h | 10 ++++++++-- source/colorfade.cpp | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/source/action.cpp b/source/action.cpp index b7cf082..f67bb28 100644 --- a/source/action.cpp +++ b/source/action.cpp @@ -1,7 +1,7 @@ #include "action.h" -InterpolationAction::InterpolationAction(bool h): - hermite(h), +InterpolationAction::InterpolationAction(Mode m): + mode(m), start_beat(0), duration(0) { } @@ -19,7 +19,7 @@ void InterpolationAction::tick(float b, float d) { float t = (b-start_beat)/duration; float dt = d/duration; - if(hermite) + if(mode==HERMITE) { dt = t-dt; t = (3-2*t)*t*t; diff --git a/source/action.h b/source/action.h index 9988854..980b038 100644 --- a/source/action.h +++ b/source/action.h @@ -17,11 +17,17 @@ public: class InterpolationAction: public Action { protected: - bool hermite; + enum Mode + { + LINEAR, + HERMITE + }; + + Mode mode; float start_beat; float duration; - InterpolationAction(bool = false); + InterpolationAction(Mode = LINEAR); public: virtual void start(float, float); diff --git a/source/colorfade.cpp b/source/colorfade.cpp index 30d9658..edfd1e0 100644 --- a/source/colorfade.cpp +++ b/source/colorfade.cpp @@ -3,7 +3,7 @@ using namespace Msp; ColorFadeAction::ColorFadeAction(const GL::Color &c): - InterpolationAction(true), + InterpolationAction(HERMITE), end_color(c) { } -- 2.43.0