Fix some jerky animations on emscripten

This commit is contained in:
Tamás Bálint Misius
2025-02-01 19:02:54 +01:00
parent b131567345
commit 22a68d257f
4 changed files with 5 additions and 5 deletions

View File

@@ -116,7 +116,7 @@ void Button::Draw(const Point& screenPos)
bgColour = Appearance.BackgroundInactive;
if (Appearance.BackgroundPulse)
{
backgroundColour.Alpha = uint8_t(backgroundColour.Alpha * ((std::sin(Engine::Ref().LastTick() / 1000.f * std::numbers::pi_v<float> * 2.f) + 1.f) / 2.f));
backgroundColour.Alpha = uint8_t(backgroundColour.Alpha * ((std::sin(Engine::Ref().LastTick() / 1000 * std::numbers::pi * 2) + 1) / 2));
}
g->BlendFilledRect(RectSized(Position + Vec2{ 1, 1 }, Size - Vec2{ 2, 2 }), backgroundColour);
if(Appearance.Border == 1)

View File

@@ -76,5 +76,5 @@ void ProgressBar::Draw(const Point &screenPos)
void ProgressBar::Tick()
{
intermediatePos = std::fmod(ui::Engine::Ref().LastTick() * 0.06f, 100.f);
intermediatePos = float(std::fmod(ui::Engine::Ref().LastTick() * 0.06, 100.0));
}

View File

@@ -16,8 +16,8 @@ void Spinner::Draw(const Point& screenPos)
int baseY = screenPos.Y+(Size.Y/2);
int lineInner = (Size.X/2);
int lineOuter = (Size.X/2)+3;
auto cValue = std::floor(ui::Engine::Ref().LastTick() * 0.015f) * 0.25f;
for(float t = 0.0f; t < 6.0f; t+=0.25f)
auto cValue = std::floor(ui::Engine::Ref().LastTick() * 0.015) * 0.25;
for(double t = 0.0; t < 6.0; t+=0.25)
{
g->DrawLine(
{ int(baseX+(std::sin(cValue+t)*lineInner)), int(baseY+(std::cos(cValue+t)*lineInner)) },

View File

@@ -79,7 +79,7 @@ void TaskWindow::NotifyProgress(Task * task)
void TaskWindow::OnTick()
{
intermediatePos = std::fmod(ui::Engine::Ref().LastTick() * 0.06f, 100.f);
intermediatePos = float(std::fmod(ui::Engine::Ref().LastTick() * 0.06, 100.0));
task->Poll();
if (done)
Exit();