diff options
author | Thomas White <taw@physics.org> | 2022-07-09 22:15:38 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2022-07-09 22:22:42 +0200 |
commit | 274ebcd3c7a87524513f845cf533bd5b4d53ee16 (patch) | |
tree | 51674badd2459b9637b9be3cc920512a006ad8b7 /src | |
parent | 702ed5c0d3e96b9430b42a493ffce457bf0c76fb (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/starlet-fixture-display.c | 14 |
1 files 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); } |