From c69a16ca6d267f77c87ca93b5446c69174222ff2 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 24 Sep 2021 17:09:55 -0700 Subject: [PATCH] Wrap around highlights to ensure distinguishing Bright colors are maxed out for highlighting. Modestly darkening them helps to distinguish them from their neighbors but keep the blue value to help "glow" the selection Fixes https://gitlab.com/kicad/code/kicad/issues/5560 --- common/render_settings.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/common/render_settings.cpp b/common/render_settings.cpp index d00c95aa8d..a69396ffd0 100644 --- a/common/render_settings.cpp +++ b/common/render_settings.cpp @@ -64,7 +64,19 @@ void RENDER_SETTINGS::update() // Linear brightening doesn't work well for colors near white double factor = ( m_selectFactor * 0.6 ) + pow( m_layerColors[i].GetBrightness(), 3 ); - m_layerColorsSel[i] = m_layerColors[i].Brightened( std::min( factor, 1.0 ) ); + factor = std::min( 1.0, factor ); + + m_layerColorsSel[i] = m_layerColors[i].Brightened( factor ); + + // If we are maxed out on brightening as a highlight, fallback to darkening but keep + // the blue that acts as a "glowing" color + if( std::fabs( m_layerColorsSel[i].GetBrightness() - m_layerColors[i].GetBrightness() ) + < 0.05 ) + { + m_layerColorsSel[i] = m_layerColors[i].Darkened( m_selectFactor * 0.4 ); + m_layerColorsSel[i].b = m_layerColors[i].b * ( 1.0 - factor ) + factor; + } + } }