Commit 861ea059 authored by Maciej Suminski's avatar Maciej Suminski

Different approach to coloring netname labels.

parent f4114d22
...@@ -82,9 +82,9 @@ public: ...@@ -82,9 +82,9 @@ public:
*/ */
COLOR4D& Highlight( double aFactor ) COLOR4D& Highlight( double aFactor )
{ {
r = (double) r * (1.0 - aFactor) + aFactor; r = r * ( 1.0 - aFactor ) + aFactor;
g = (double) g * (1.0 - aFactor) + aFactor; g = g * ( 1.0 - aFactor ) + aFactor;
b = (double) b * (1.0 - aFactor) + aFactor; b = b * ( 1.0 - aFactor ) + aFactor;
return *this; return *this;
} }
...@@ -97,9 +97,23 @@ public: ...@@ -97,9 +97,23 @@ public:
*/ */
COLOR4D& Darken( double aFactor ) COLOR4D& Darken( double aFactor )
{ {
r = (double) r * (1.0 - aFactor); r = r * ( 1.0 - aFactor );
g = (double) g * (1.0 - aFactor); g = g * ( 1.0 - aFactor );
b = (double) b * (1.0 - aFactor); b = b * ( 1.0 - aFactor );
return *this;
}
/**
* Function Invert
* Makes the color inverted, alpha remains the same.
* @return COLOR4D& Inverted color.
*/
COLOR4D& Invert()
{
r = ( 1.0 - r );
g = ( 1.0 - g );
b = ( 1.0 - b );
return *this; return *this;
} }
...@@ -112,9 +126,9 @@ public: ...@@ -112,9 +126,9 @@ public:
*/ */
COLOR4D Highlighted( double aFactor ) const COLOR4D Highlighted( double aFactor ) const
{ {
return COLOR4D( r * (1.0 - aFactor) + aFactor, return COLOR4D( r * ( 1.0 - aFactor ) + aFactor,
g * (1.0 - aFactor) + aFactor, g * ( 1.0 - aFactor ) + aFactor,
b * (1.0 - aFactor) + aFactor, b * ( 1.0 - aFactor ) + aFactor,
a ); a );
} }
...@@ -126,12 +140,22 @@ public: ...@@ -126,12 +140,22 @@ public:
*/ */
COLOR4D Darkened( double aFactor ) const COLOR4D Darkened( double aFactor ) const
{ {
return COLOR4D( r * (1.0 - aFactor), return COLOR4D( r * ( 1.0 - aFactor ),
g * (1.0 - aFactor), g * ( 1.0 - aFactor ),
b * (1.0 - aFactor), b * ( 1.0 - aFactor ),
a ); a );
} }
/**
* Function Inverted
* Returns an inverted color, alpha remains the same.
* @return COLOR4D& Inverted color.
*/
COLOR4D Inverted() const
{
return COLOR4D( 1.0 - r, 1.0 - g, 1.0 - b, a );
}
/** /**
* Function GetBrightness * Function GetBrightness
* Returns the brightness value of the color ranged from 0.0 to 1.0. * Returns the brightness value of the color ranged from 0.0 to 1.0.
......
...@@ -309,10 +309,12 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer ) ...@@ -309,10 +309,12 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
// Set a proper color for the label // Set a proper color for the label
color = getLayerColor( aTrack->GetLayer(), aTrack->GetNet(), color = getLayerColor( aTrack->GetLayer(), aTrack->GetNet(),
aTrack->ViewIsHighlighted() ); aTrack->ViewIsHighlighted() );
COLOR4D labelColor = getLayerColor( aLayer, 0, aTrack->ViewIsHighlighted() );
if( color.GetBrightness() > 0.5 ) if( color.GetBrightness() > 0.5 )
m_gal->SetStrokeColor( color.Darkened( 0.8 ) ); m_gal->SetStrokeColor( labelColor.Inverted() );
else else
m_gal->SetStrokeColor( color.Highlighted( 0.8 ) ); m_gal->SetStrokeColor( labelColor );
m_gal->SetLineWidth( width / 10.0 ); m_gal->SetLineWidth( width / 10.0 );
m_gal->SetBold( false ); m_gal->SetBold( false );
...@@ -447,11 +449,12 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) ...@@ -447,11 +449,12 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
// Set a proper color for the label // Set a proper color for the label
color = getLayerColor( aPad->GetParent()->GetLayer(), aPad->GetNet(), color = getLayerColor( aPad->GetParent()->GetLayer(), aPad->GetNet(),
aPad->ViewIsHighlighted() ); aPad->ViewIsHighlighted() );
COLOR4D labelColor = getLayerColor( aLayer, 0, aPad->ViewIsHighlighted() );
if( color.GetBrightness() > 0.5 ) if( color.GetBrightness() > 0.5 )
m_gal->SetStrokeColor( color.Darkened( 0.8 ) ); m_gal->SetStrokeColor( labelColor.Inverted() );
else else
m_gal->SetStrokeColor( color.Highlighted( 0.8 ) ); m_gal->SetStrokeColor( labelColor );
if( displayNetname && m_pcbSettings->m_padNumbers ) if( displayNetname && m_pcbSettings->m_padNumbers )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment