From c58b3ead6544df62c13e88aac6d32bbaf3ce0de7 Mon Sep 17 00:00:00 2001 From: Edgaru089 Date: Mon, 22 Apr 2024 05:49:53 +0800 Subject: [PATCH] Fix Textbox foreground color fading It now fades from background to white, instead of always fading from black to white. --- mapper_misc_render.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/mapper_misc_render.cpp b/mapper_misc_render.cpp index ebc3153..0821168 100644 --- a/mapper_misc_render.cpp +++ b/mapper_misc_render.cpp @@ -49,14 +49,15 @@ extern "C" void misc_render_Textbox(App *app, Entity *e, Vec2 entity_screen_pos, if (t->progress < EPS) return; - // Set the color - int rgb = (int)round(fminf(t->progress, 1.0f) * 255.0); - settextcolor(RGB(rgb, rgb, rgb)); - - // Fade the background from App background to Black + // This is the background int r = app->clear_color & 0xff; int g = (app->clear_color & 0xff00) >> 8; int b = (app->clear_color & 0xff0000) >> 16; + + // Fade foreground from App bg to White + settextcolor(RGB((int)roundf(r + (255 - r) * t->progress), (int)roundf(g + (255 - g) * t->progress), (int)roundf(b + (255 - b) * t->progress))); + + // Fade the background from App background to Black setbkcolor(RGB((int)roundf(r * (1.0f - t->progress)), (int)roundf(g * (1.0f - t->progress)), (int)roundf(b * (1.0f - t->progress))));