Skip to content

Commit

Permalink
[component/tgui] minor tweak in vsf_tgui_sv_color_mix
Browse files Browse the repository at this point in the history
  • Loading branch information
versaloon committed Nov 14, 2024
1 parent f059487 commit ec11ef4
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions source/component/ui/tgui/view/simple_view/vsf_tgui_sv_color.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,23 @@ declare_class(vsf_tgui_t)

vsf_tgui_sv_color_t vsf_tgui_sv_color_mix(vsf_tgui_sv_color_t color_0, vsf_tgui_sv_color_t color_1, uint_fast8_t mix)
{
vsf_tgui_sv_color_t result;

#if VSF_TGUI_CFG_COLOR_MODE == VSF_TGUI_COLOR_ARGB_8888
result.value = ((((color_0.value >> 8) & 0x00FF00FF) * mix) & 0xFF00FF00)
color_0.value = ((((color_0.value >> 8) & 0x00FF00FF) * mix) & 0xFF00FF00)
+ ((((color_0.value & 0x00FF00FF) * mix) >> 8) & 0x00FF00FF);
mix = ~mix;
result.value += ((((color_1.value >> 8) & 0x00FF00FF) * mix) & 0xFF00FF00)
color_0.value += ((((color_1.value >> 8) & 0x00FF00FF) * mix) & 0xFF00FF00)
+ ((((color_1.value & 0x00FF00FF) * mix) >> 8) & 0x00FF00FF);
#else
result.red = ((uint32_t)color_0.red * mix + (uint32_t)color_1.red * (255 - mix)) / 255;
result.green = ((uint32_t)color_0.green * mix + (uint32_t)color_1.green * (255 - mix)) / 255;
result.blue = ((uint32_t)color_0.blue * mix + (uint32_t)color_1.blue * (255 - mix)) / 255;
color_0.red = ((uint32_t)color_0.red * mix + (uint32_t)color_1.red * (255 - mix)) / 255;
color_0.green = ((uint32_t)color_0.green * mix + (uint32_t)color_1.green * (255 - mix)) / 255;
color_0.blue = ((uint32_t)color_0.blue * mix + (uint32_t)color_1.blue * (255 - mix)) / 255;
#endif

#if VSF_TGUI_SV_CFG_COLOR_HAS_ALPHA == ENABLED
result.alpha = 0xFF;
color_0.alpha = 0xFF;
#endif

return result;
return color_0;
}

#if VSF_TGUI_CFG_COLOR_MODE != VSF_TGUI_COLOR_ARGB_8888
Expand Down

0 comments on commit ec11ef4

Please sign in to comment.