From 899944e5719926e57f5eac2e99480ce81884329c Mon Sep 17 00:00:00 2001 From: IoIxD Date: Fri, 17 Oct 2025 00:51:26 +0000 Subject: [PATCH] color the text in the color wheel's color box such that it's readable no matter the background git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@388 b9cfdab3-6d41-4d17-bbe4-086880011989 --- examples/color_picker.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/examples/color_picker.c b/examples/color_picker.c index a6b8837..5ca17ef 100644 --- a/examples/color_picker.c +++ b/examples/color_picker.c @@ -66,6 +66,7 @@ typedef struct { double value; unsigned char* color_wheel_image_data; unsigned char* color_display_image_data; + MwPoint point; } color_wheel; void color_wheel_wheel_image_update(color_wheel* wheel) { @@ -138,8 +139,17 @@ static void color_wheel_click(MwWidget handle, void* user, void* call) { (void)a; hexColor = malloc(8); + char* fgColor = malloc(8); snprintf(hexColor, 8, "#%02X%02X%02X", r, g, b); + + int fr = r > 128 ? 0 : 255; + int fg = g > 128 ? 0 : 255; + int fb = b > 128 ? 0 : 255; + + snprintf(fgColor, 8, "#%02X%02X%02X", fr, fg, fb); MwSetText(wheel->color_display, MwNbackground, hexColor); + MwSetText(wheel->color_display_text, MwNforeground, fgColor); + MwSetText(wheel->color_display_text, MwNbackground, hexColor); MwSetText(wheel->color_display_text, MwNtext, hexColor); free(hexColor);