mirror of https://github.com/procxx/kepka.git
Change direction of infinite radial animation.
This commit is contained in:
parent
aa00f9bd34
commit
7b3c452316
|
@ -197,8 +197,8 @@ void InfiniteRadialAnimation::draw(
|
||||||
|
|
||||||
RadialState InfiniteRadialAnimation::computeState() {
|
RadialState InfiniteRadialAnimation::computeState() {
|
||||||
const auto now = crl::now();
|
const auto now = crl::now();
|
||||||
const auto linear = int(((now * FullArcLength) / _st.linearPeriod)
|
const auto linear = FullArcLength
|
||||||
% FullArcLength);
|
- int(((now * FullArcLength) / _st.linearPeriod) % FullArcLength);
|
||||||
if (!_workStarted || (_workFinished && _workFinished <= now)) {
|
if (!_workStarted || (_workFinished && _workFinished <= now)) {
|
||||||
const auto shown = 0.;
|
const auto shown = 0.;
|
||||||
_animation.stop();
|
_animation.stop();
|
||||||
|
@ -223,7 +223,7 @@ RadialState InfiniteRadialAnimation::computeState() {
|
||||||
anim::sineInOut(1., snap(shown, 0., 1.)));
|
anim::sineInOut(1., snap(shown, 0., 1.)));
|
||||||
return {
|
return {
|
||||||
shown,
|
shown,
|
||||||
linear + (FullArcLength - length),
|
linear,
|
||||||
length };
|
length };
|
||||||
} else if (!_workFinished || now <= _workFinished - _st.sineDuration) {
|
} else if (!_workFinished || now <= _workFinished - _st.sineDuration) {
|
||||||
// _workStared .. _workFinished - _st.sineDuration
|
// _workStared .. _workFinished - _st.sineDuration
|
||||||
|
@ -235,28 +235,29 @@ RadialState InfiniteRadialAnimation::computeState() {
|
||||||
- _st.sineShift
|
- _st.sineShift
|
||||||
- _st.sineDuration;
|
- _st.sineDuration;
|
||||||
const auto basic = int((linear
|
const auto basic = int((linear
|
||||||
+ (FullArcLength - min)
|
+ min
|
||||||
+ cycles * (max - min)) % FullArcLength);
|
+ (cycles * (FullArcLength + min - max))) % FullArcLength);
|
||||||
if (relative <= smallDuration) {
|
if (relative <= smallDuration) {
|
||||||
// localZero .. growStart
|
// localZero .. growStart
|
||||||
return {
|
return {
|
||||||
shown,
|
shown,
|
||||||
basic,
|
basic - min,
|
||||||
min };
|
min };
|
||||||
} else if (relative <= smallDuration + _st.sineDuration) {
|
} else if (relative <= smallDuration + _st.sineDuration) {
|
||||||
// growStart .. growEnd
|
// growStart .. growEnd
|
||||||
const auto growLinear = (relative - smallDuration) /
|
const auto growLinear = (relative - smallDuration) /
|
||||||
float64(_st.sineDuration);
|
float64(_st.sineDuration);
|
||||||
const auto growProgress = anim::sineInOut(1., growLinear);
|
const auto growProgress = anim::sineInOut(1., growLinear);
|
||||||
|
const auto length = anim::interpolate(min, max, growProgress);
|
||||||
return {
|
return {
|
||||||
shown,
|
shown,
|
||||||
basic,
|
basic - length,
|
||||||
anim::interpolate(min, max, growProgress) };
|
length };
|
||||||
} else if (relative <= _st.sinePeriod - _st.sineDuration) {
|
} else if (relative <= _st.sinePeriod - _st.sineDuration) {
|
||||||
// growEnd .. shrinkStart
|
// growEnd .. shrinkStart
|
||||||
return {
|
return {
|
||||||
shown,
|
shown,
|
||||||
basic,
|
basic - max,
|
||||||
max };
|
max };
|
||||||
} else {
|
} else {
|
||||||
// shrinkStart .. shrinkEnd
|
// shrinkStart .. shrinkEnd
|
||||||
|
@ -270,7 +271,7 @@ RadialState InfiniteRadialAnimation::computeState() {
|
||||||
shrinkProgress);
|
shrinkProgress);
|
||||||
return {
|
return {
|
||||||
shown,
|
shown,
|
||||||
basic + shrink,
|
basic - max,
|
||||||
max - shrink }; // interpolate(max, min, shrinkProgress)
|
max - shrink }; // interpolate(max, min, shrinkProgress)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -279,15 +280,15 @@ RadialState InfiniteRadialAnimation::computeState() {
|
||||||
/ float64(_st.sineDuration);
|
/ float64(_st.sineDuration);
|
||||||
const auto cycles = (_workFinished - _workStarted) / _st.sinePeriod;
|
const auto cycles = (_workFinished - _workStarted) / _st.sinePeriod;
|
||||||
const auto basic = int((linear
|
const auto basic = int((linear
|
||||||
+ (FullArcLength - min)
|
+ min
|
||||||
+ cycles * (max - min)) % FullArcLength);
|
+ cycles * (FullArcLength + min - max)) % FullArcLength);
|
||||||
const auto length = anim::interpolate(
|
const auto length = anim::interpolate(
|
||||||
min,
|
min,
|
||||||
FullArcLength,
|
FullArcLength,
|
||||||
anim::sineInOut(1., snap(hidden, 0., 1.)));
|
anim::sineInOut(1., snap(hidden, 0., 1.)));
|
||||||
return {
|
return {
|
||||||
1. - hidden,
|
1. - hidden,
|
||||||
basic,
|
basic - length,
|
||||||
length };
|
length };
|
||||||
}
|
}
|
||||||
//const auto frontPeriods = time / st.sinePeriod;
|
//const auto frontPeriods = time / st.sinePeriod;
|
||||||
|
|
Loading…
Reference in New Issue