From 01aaed54d69c1333d82adaed87497ca029262ef1 Mon Sep 17 00:00:00 2001 From: iota97 Date: Wed, 8 Sep 2021 15:03:32 +0200 Subject: [PATCH 1/2] Wave animation --- Core/ConfigValues.h | 1 + UI/GameSettingsScreen.cpp | 2 +- UI/MiscScreens.cpp | 29 +++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Core/ConfigValues.h b/Core/ConfigValues.h index debeee4808f9..f6e7558ed10e 100644 --- a/Core/ConfigValues.h +++ b/Core/ConfigValues.h @@ -128,4 +128,5 @@ enum class BackgroundAnimation { OFF = 0, FLOATING_SYMBOLS = 1, RECENT_GAMES = 2, + WAVE = 3, }; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 8240e451374e..3d2b64b6176e 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -880,7 +880,7 @@ void GameSettingsScreen::CreateViews() { if (backgroundChoice_ != nullptr) { backgroundChoice_->OnClick.Handle(this, &GameSettingsScreen::OnChangeBackground); } - static const char *backgroundAnimations[] = { "No animation", "Floating symbols", "Recent games" }; + static const char *backgroundAnimations[] = { "No animation", "Floating symbols", "Recent games", "Waves" }; systemSettings->Add(new PopupMultiChoice(&g_Config.iBackgroundAnimation, sy->T("UI background animation"), backgroundAnimations, 0, ARRAY_SIZE(backgroundAnimations), sy->GetName(), screenManager())); systemSettings->Add(new ItemHeader(sy->T("Help the PPSSPP team"))); diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index 485613e4eb03..d2b10236211a 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -79,6 +79,32 @@ class Animation { virtual void Draw(UIContext &dc, double t, float alpha) = 0; }; +class WaveAnimation : public Animation { +public: + void Draw(UIContext &dc, double t, float alpha) override { + const uint32_t color = 0x30FFFFFF; + const float speed = 1.0; + + Bounds bounds = dc.GetBounds(); + dc.Flush(); + dc.BeginNoTex(); + + t *= speed; + for (int x = 0; x < bounds.w; ++x) { + float i = x * 1280/bounds.w; + + float wave0 = sin(i*0.005+t*0.8)*0.05 + sin(i*0.002+t*0.25)*0.02 + sin(i*0.001+t*0.3)*0.03 + 0.625; + dc.Draw()->RectVGradient(x, wave0*bounds.h, pixel_in_dps_x, (1.0-wave0)*bounds.h, color, 0x00000000); + + float wave1 = sin(i*0.0044+t*0.4)*0.07 + sin(i*0.003+t*0.1)*0.02 + sin(i*0.001+t*0.3)*0.01 + 0.625; + dc.Draw()->RectVGradient(x, wave1*bounds.h, pixel_in_dps_x, (1.0-wave1)*bounds.h, color, 0x00000000); + } + + dc.Flush(); + dc.Begin(); + } +}; + class FloatingSymbolsAnimation : public Animation { public: ~FloatingSymbolsAnimation() override {} @@ -236,6 +262,9 @@ void DrawBackground(UIContext &dc, float alpha) { case BackgroundAnimation::RECENT_GAMES: g_Animation.reset(new RecentGamesAnimation()); break; + case BackgroundAnimation::WAVE: + g_Animation.reset(new WaveAnimation()); + break; default: g_Animation.reset(nullptr); } From 79b10c4d53e91e1d212c72d2c0cfe21615dc5440 Mon Sep 17 00:00:00 2001 From: iota97 Date: Wed, 8 Sep 2021 16:36:57 +0200 Subject: [PATCH 2/2] Add some antialiasing --- UI/MiscScreens.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index d2b10236211a..5e5c5d907169 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -82,7 +82,7 @@ class Animation { class WaveAnimation : public Animation { public: void Draw(UIContext &dc, double t, float alpha) override { - const uint32_t color = 0x30FFFFFF; + const uint32_t color = colorAlpha(0xFFFFFFFF, alpha * 0.2f); const float speed = 1.0; Bounds bounds = dc.GetBounds(); @@ -94,10 +94,13 @@ class WaveAnimation : public Animation { float i = x * 1280/bounds.w; float wave0 = sin(i*0.005+t*0.8)*0.05 + sin(i*0.002+t*0.25)*0.02 + sin(i*0.001+t*0.3)*0.03 + 0.625; - dc.Draw()->RectVGradient(x, wave0*bounds.h, pixel_in_dps_x, (1.0-wave0)*bounds.h, color, 0x00000000); - float wave1 = sin(i*0.0044+t*0.4)*0.07 + sin(i*0.003+t*0.1)*0.02 + sin(i*0.001+t*0.3)*0.01 + 0.625; + dc.Draw()->RectVGradient(x, wave0*bounds.h, pixel_in_dps_x, (1.0-wave0)*bounds.h, color, 0x00000000); dc.Draw()->RectVGradient(x, wave1*bounds.h, pixel_in_dps_x, (1.0-wave1)*bounds.h, color, 0x00000000); + + // Add some "antialiasing" + dc.Draw()->RectVGradient(x, wave0*bounds.h-3*pixel_in_dps_y, pixel_in_dps_x, 3*pixel_in_dps_y, 0x00000000, color); + dc.Draw()->RectVGradient(x, wave1*bounds.h-3*pixel_in_dps_y, pixel_in_dps_x, 3*pixel_in_dps_y, 0x00000000, color); } dc.Flush();