From 274ebcd3c7a87524513f845cf533bd5b4d53ee16 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sat, 9 Jul 2022 22:15:38 +0200 Subject: Fixture display: Avoid hard transition of intensity text colour The snap transition is bad, because it gives the impression that some kind of snap change has taken place in the lighting state. Since the background has to get lighter and the text darker, they have to cross over (making the text invisible) at some value. This is an attempt to make the crossover time as short as possible without any snap transition. --- src/starlet-fixture-display.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/starlet-fixture-display.c b/src/starlet-fixture-display.c index 48e2f15..0f41b88 100644 --- a/src/starlet-fixture-display.c +++ b/src/starlet-fixture-display.c @@ -166,17 +166,25 @@ static void draw_fixture(cairo_t *cr, /* Intensity */ if ( fix->intensity >= 0.0 ) { + const double gbw = 40.0; char tmp[32]; + double grey; snprintf(tmp, 32, "%.0f%%", fix->intensity); layout = pango_layout_new(pc); pango_layout_set_text(layout, tmp, -1); pango_layout_set_height(layout, lh*PANGO_SCALE); pango_layout_set_font_description(layout, fontdesc); - if ( fix->intensity < 50.0 ) { - cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); + + double gbl = 50.0 - gbw / 2.0; + if ( fix->intensity < gbl ) { + grey = 1.0; + } else if ( fix->intensity > 50.0 + gbw/2.0) { + grey = 0.0; } else { - cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); + grey = 1.0 - (fix->intensity - gbl) / gbw; } + cairo_set_source_rgb(cr, grey, grey, grey); + show_vertical_center_log(cr, layout, w*0.3, lh); g_object_unref(layout); } -- cgit v1.2.3