From 22a68d257fd0128226c69458a56b5dc5d4ec2395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20B=C3=A1lint=20Misius?= Date: Sat, 1 Feb 2025 19:02:54 +0100 Subject: [PATCH] Fix some jerky animations on emscripten --- src/gui/interface/Button.cpp | 2 +- src/gui/interface/ProgressBar.cpp | 2 +- src/gui/interface/Spinner.cpp | 4 ++-- src/tasks/TaskWindow.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gui/interface/Button.cpp b/src/gui/interface/Button.cpp index 5392cfff6..64eb9c61f 100644 --- a/src/gui/interface/Button.cpp +++ b/src/gui/interface/Button.cpp @@ -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 * 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) diff --git a/src/gui/interface/ProgressBar.cpp b/src/gui/interface/ProgressBar.cpp index 982c00536..a7ffee431 100644 --- a/src/gui/interface/ProgressBar.cpp +++ b/src/gui/interface/ProgressBar.cpp @@ -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)); } diff --git a/src/gui/interface/Spinner.cpp b/src/gui/interface/Spinner.cpp index 9d5f1b933..a8d45c93c 100644 --- a/src/gui/interface/Spinner.cpp +++ b/src/gui/interface/Spinner.cpp @@ -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)) }, diff --git a/src/tasks/TaskWindow.cpp b/src/tasks/TaskWindow.cpp index b0fc63c9b..fc2d7d9be 100644 --- a/src/tasks/TaskWindow.cpp +++ b/src/tasks/TaskWindow.cpp @@ -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();