Skip to content

Commit

Permalink
Clamp input time duration rather than output alpha value
Browse files Browse the repository at this point in the history
  • Loading branch information
DanRStevens committed Mar 6, 2025
1 parent c6b441c commit aa5366a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions NAS2D/Renderer/Fade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ void Fade::update()
return;
}

const auto currentMilliseconds = mFadeTimer.elapsedTicks();
const auto step = static_cast<uint8_t>(std::clamp<unsigned int>(currentMilliseconds * 255u / mDuration.milliseconds, 0u, 255u));
const auto currentMilliseconds = std::min(mFadeTimer.elapsedTicks(), mDuration.milliseconds);
const auto step = static_cast<uint8_t>(currentMilliseconds * 255u / mDuration.milliseconds);
mFadeColor.alpha = (mDirection == FadeDirection::In) ? 255 - step : step;

if (currentMilliseconds >= mDuration.milliseconds)
Expand Down

0 comments on commit aa5366a

Please sign in to comment.