本文整理汇总了C++中COLOR4D::Inverted方法的典型用法代码示例。如果您正苦于以下问题:C++ COLOR4D::Inverted方法的具体用法?C++ COLOR4D::Inverted怎么用?C++ COLOR4D::Inverted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类COLOR4D
的用法示例。
在下文中一共展示了COLOR4D::Inverted方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ImportLegacyColors
void PCB_RENDER_SETTINGS::ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSettings )
{
// Init board layers colors:
for( int i = 0; i < PCB_LAYER_ID_COUNT; i++ )
{
m_layerColors[i] = aSettings->GetLayerColor( i );
// Guard: if the alpah channel is too small, the layer is not visible.
// clamp it to 0.2
if( m_layerColors[i].a < 0.2 )
m_layerColors[i].a = 0.2;
}
// Init specific graphic layers colors:
for( int i = GAL_LAYER_ID_START; i < GAL_LAYER_ID_END; i++ )
m_layerColors[i] = aSettings->GetItemColor( i );
// Default colors for specific layers (not really board layers).
m_layerColors[LAYER_VIAS_HOLES] = COLOR4D( 0.5, 0.4, 0.0, 0.8 );
m_layerColors[LAYER_PADS_PLATEDHOLES] = aSettings->GetItemColor( LAYER_PCB_BACKGROUND );
m_layerColors[LAYER_PADS_NETNAMES] = COLOR4D( 1.0, 1.0, 1.0, 0.9 );
m_layerColors[LAYER_PAD_FR_NETNAMES] = COLOR4D( 1.0, 1.0, 1.0, 0.9 );
m_layerColors[LAYER_PAD_BK_NETNAMES] = COLOR4D( 1.0, 1.0, 1.0, 0.9 );
m_layerColors[LAYER_DRC] = COLOR4D( 1.0, 0.0, 0.0, 0.8 );
// LAYER_PADS_TH, LAYER_NON_PLATEDHOLES, LAYER_ANCHOR ,LAYER_RATSNEST,
// LAYER_VIA_THROUGH, LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA
// are initialized from aSettings
// These colors are not actually used. Set just in case...
m_layerColors[LAYER_MOD_TEXT_FR] = m_layerColors[F_SilkS];
m_layerColors[LAYER_MOD_TEXT_BK] = m_layerColors[B_SilkS];
// Netnames for copper layers
for( LSEQ cu = LSET::AllCuMask().CuStack(); cu; ++cu )
{
const COLOR4D lightLabel( 0.8, 0.8, 0.8, 0.7 );
const COLOR4D darkLabel = lightLabel.Inverted();
PCB_LAYER_ID layer = *cu;
if( m_layerColors[layer].GetBrightness() > 0.5 )
m_layerColors[GetNetnameLayer( layer )] = darkLabel;
else
m_layerColors[GetNetnameLayer( layer )] = lightLabel;
}
SetBackgroundColor ( aSettings->GetItemColor( LAYER_PCB_BACKGROUND ) );
update();
}
示例2: draw
void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer )
{
VECTOR2D size;
VECTOR2D position( aPad->GetPosition() );
PAD_SHAPE_T shape;
double m, n;
double orientation = aPad->GetOrientation();
wxString buffer;
// Draw description layer
if( IsNetnameLayer( aLayer ) )
{
// Is anything that we can display enabled?
if( m_pcbSettings.m_netNamesOnPads || m_pcbSettings.m_padNumbers )
{
// Min char count to calculate string size
const int MIN_CHAR_COUNT = 3;
bool displayNetname = ( m_pcbSettings.m_netNamesOnPads &&
!aPad->GetNetname().empty() );
VECTOR2D padsize = VECTOR2D( aPad->GetSize() );
double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE;
double size = padsize.y;
// Keep the size ratio for the font, but make it smaller
if( padsize.x < padsize.y )
{
orientation += 900.0;
size = padsize.x;
EXCHG( padsize.x, padsize.y );
}
else if( padsize.x == padsize.y )
{
// If the text is displayed on a symmetrical pad, do not rotate it
orientation = 0.0;
}
// Font size limits
if( size > maxSize )
size = maxSize;
m_gal->Save();
m_gal->Translate( position );
// do not display descriptions upside down
NORMALIZE_ANGLE_90( orientation );
m_gal->Rotate( -orientation * M_PI / 1800.0 );
// Default font settings
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
m_gal->SetBold( false );
m_gal->SetItalic( false );
m_gal->SetMirrored( false );
// Set a proper color for the label
const COLOR4D& color = m_pcbSettings.GetColor( aPad, aPad->GetLayer() );
COLOR4D labelColor = m_pcbSettings.GetColor( NULL, aLayer );
if( color.GetBrightness() > 0.5 )
m_gal->SetStrokeColor( labelColor.Inverted() );
else
m_gal->SetStrokeColor( labelColor );
VECTOR2D textpos( 0.0, 0.0);
// Divide the space, to display both pad numbers and netnames
// and set the Y text position to display 2 lines
if( displayNetname && m_pcbSettings.m_padNumbers )
{
size = size / 2.0;
textpos.y = size / 2.0;
}
if( displayNetname )
{
// calculate the size of net name text:
double tsize = padsize.x / aPad->GetShortNetname().Length();
tsize = std::min( tsize, size );
// Use a smaller text size to handle interline, pen size..
tsize *= 0.7;
VECTOR2D namesize( tsize, tsize );
m_gal->SetGlyphSize( namesize );
m_gal->SetLineWidth( namesize.x / 12.0 );
m_gal->StrokeText( aPad->GetShortNetname(), textpos, 0.0 );
}
if( m_pcbSettings.m_padNumbers )
{
textpos.y = -textpos.y;
aPad->StringPadName( buffer );
int len = buffer.Length();
double tsize = padsize.x / std::max( len, MIN_CHAR_COUNT );
tsize = std::min( tsize, size );
// Use a smaller text size to handle interline, pen size..
tsize *= 0.7;
tsize = std::min( tsize, size );
VECTOR2D numsize( tsize, tsize );
m_gal->SetGlyphSize( numsize );
//.........这里部分代码省略.........