diff options
| author | Tim Redfern <tim@getdrop.com> | 2018-01-11 23:45:52 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@getdrop.com> | 2018-01-11 23:45:52 +0000 |
| commit | 532f8719ab63be9f5e9d98e15bc5fb2d081b98b3 (patch) | |
| tree | 54d35f440c9f4d5d78b4d3662f9dbbe404cc1282 | |
| parent | 9f1fdb2fa8fa09dbd990b33379db98762f3856ce (diff) | |
easing
| -rw-r--r-- | gui/src/chainImage.cpp | 24 | ||||
| -rw-r--r-- | gui/src/chainImage.h | 4 |
2 files changed, 27 insertions, 1 deletions
diff --git a/gui/src/chainImage.cpp b/gui/src/chainImage.cpp index d362b0c..9ff4fc5 100644 --- a/gui/src/chainImage.cpp +++ b/gui/src/chainImage.cpp @@ -253,7 +253,29 @@ float chainImage::getRotation(){ return getLinkRot()+(transitionInterpolated*link->getLinkRot()); */ - return ofxeasing::map_clamp(transition, 0, 1, getLinkRot(), getLinkRot()+link->getLinkRot(), ofxeasing::cubic::easeInOut); + ofxeasing::function easing; + + bool start_turning=(sgn(getLinkRot()-linked->getLinkRot())!=sgn(link->getLinkRot()-getLinkRot())); + bool end_turning=(sgn(link->getLinkRot()-getLinkRot())!=sgn(link->link->getLinkRot()-link->getLinkRot())); + + if (start_turning){ + if (end_turning){ + easing=ofxeasing::cubic::easeInOut; + } + else { + easing=ofxeasing::cubic::easeIn; + } + } + else { + if (end_turning){ + easing=ofxeasing::cubic::easeOut; + } + else { + easing=ofxeasing::linear::easeOut; + } + } + + return ofxeasing::map_clamp(transition, 0, 1, getLinkRot(), getLinkRot()+link->getLinkRot(), easing); }; diff --git a/gui/src/chainImage.h b/gui/src/chainImage.h index 034d0a4..78b4eaf 100644 --- a/gui/src/chainImage.h +++ b/gui/src/chainImage.h @@ -24,6 +24,10 @@ //so annoying 1: menubar //so annoying 2: dialogue stops screen +template <typename T> int sgn(T val) { + return (T(0) < val) - (val < T(0)); +} + class chainImage : public ofImage{ |
