Avoid poor choices for point colors.
Also adjusts the point size to account for the fact that it now has a border.
This commit is contained in:
parent
92e97d1285
commit
6197717251
|
@ -503,6 +503,14 @@ const COLOR4D COLOR4D::BLACK( 0, 0, 0, 1 );
|
|||
const COLOR4D COLOR4D::CLEAR( 1, 0, 1, 0 );
|
||||
|
||||
|
||||
int COLOR4D::Distance( const COLOR4D& other ) const
|
||||
{
|
||||
return ( r - other.r ) * ( r - other.r )
|
||||
+ ( g - other.g ) * ( g - other.g )
|
||||
+ ( b - other.b ) * ( b - other.b );
|
||||
}
|
||||
|
||||
|
||||
EDA_COLOR_T COLOR4D::FindNearestLegacyColor( int aR, int aG, int aB )
|
||||
{
|
||||
EDA_COLOR_T candidate = EDA_COLOR_T::BLACK;
|
||||
|
|
|
@ -247,9 +247,24 @@ void EDIT_POINTS::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const
|
|||
auto gal = aView->GetGAL();
|
||||
|
||||
KIGFX::RENDER_SETTINGS* settings = aView->GetPainter()->GetSettings();
|
||||
KIGFX::COLOR4D drawColor = settings->GetLayerColor( LAYER_AUX_ITEMS );
|
||||
|
||||
// Don't assume LAYER_AUX_ITEMS is always a good choice. Compare with background.
|
||||
if( aView->GetGAL()->GetClearColor().Distance( drawColor ) < 0.5 )
|
||||
drawColor.Invert();
|
||||
|
||||
// Linear darkening doesn't fit well with human color perception, and there's no guarantee
|
||||
// that there's enough room for contrast either.
|
||||
KIGFX::COLOR4D bgColor;
|
||||
double brightness = drawColor.GetBrightness();
|
||||
|
||||
if( brightness > 0.5 )
|
||||
bgColor = drawColor.Darkened( 0.3 ).WithAlpha( 0.8 );
|
||||
else if( brightness > 0.2 )
|
||||
bgColor = drawColor.Darkened( 0.6 ).WithAlpha( 0.8 );
|
||||
else
|
||||
bgColor = drawColor.Brightened( 0.3 ).WithAlpha( 0.8 );
|
||||
|
||||
KIGFX::COLOR4D drawColor = settings->GetLayerColor( LAYER_AUX_ITEMS );
|
||||
KIGFX::COLOR4D bgColor = drawColor.Darkened( 0.3 ).WithAlpha( 0.8 );
|
||||
KIGFX::COLOR4D highlightColor = settings->GetLayerColor( LAYER_SELECT_OVERLAY );
|
||||
|
||||
gal->SetFillColor( drawColor );
|
||||
|
|
|
@ -357,6 +357,11 @@ public:
|
|||
*/
|
||||
void FromHSV( double aInH, double aInS, double aInV );
|
||||
|
||||
/**
|
||||
* Returns the distance (in RGB space) between two colors.
|
||||
*/
|
||||
int Distance( const COLOR4D& other ) const;
|
||||
|
||||
/**
|
||||
* Returns a legacy color ID that is closest to the given 8-bit RGB values.
|
||||
*/
|
||||
|
|
|
@ -183,7 +183,7 @@ public:
|
|||
}
|
||||
|
||||
///< Single point size in pixels
|
||||
static const int POINT_SIZE = 10;
|
||||
static const int POINT_SIZE = 8;
|
||||
|
||||
///< Border size when not hovering
|
||||
static const int BORDER_SIZE = 2;
|
||||
|
|
Loading…
Reference in New Issue