コード例 #1
0
bool ColorIsLight( EDA_COLOR_T aColor )
{
    const StructColors &c = g_ColorRefs[ColorGetBase( aColor )];
    int r = c.m_Red;
    int g = c.m_Green;
    int b = c.m_Blue;
    return ((r * r) + (g * g) + (b * b)) > (128 * 128 * 3);
}
コード例 #2
0
EDA_COLOR_T ColorMix( EDA_COLOR_T aColor1, EDA_COLOR_T aColor2 )
{
    /* Memoization storage. This could be potentially called for each
     * color merge so a cache is useful (there are few colours anyway) */
    static EDA_COLOR_T mix_cache[NBCOLORS][NBCOLORS];

    // TODO how is alpha used? it's a mac only thing, I have no idea
    aColor1 = ColorGetBase( aColor1 );
    aColor2 = ColorGetBase( aColor2 );

    // First easy thing: a black gives always the other colour
    if( aColor1 == BLACK )
        return aColor2;

    if( aColor2 == BLACK)
        return aColor1;

    /* Now we are sure that black can't occur, so the rule is:
     * BLACK means not computed yet. If we're lucky we already have
     * an answer */
    EDA_COLOR_T candidate = mix_cache[aColor1][aColor2];

    if( candidate != BLACK )
        return candidate;

    // Blend the two colors (i.e. OR the RGB values)
    const StructColors &c1 = g_ColorRefs[aColor1];
    const StructColors &c2 = g_ColorRefs[aColor2];

    // Ask the palette for the nearest color to the mix
    wxColour mixed( c1.m_Red | c2.m_Red,
                    c1.m_Green | c2.m_Green,
                    c1.m_Blue | c2.m_Blue );
    candidate = ColorFindNearest( mixed );

    /* Here, BLACK is *not* a good answer, since it would recompute the next time.
     * Even theorically its not possible (with the current rules), but
     * maybe the metric will change in the future */
    if( candidate == BLACK )
        candidate = DARKDARKGRAY;

    // Store the result in the cache. The operation is commutative, too
    mix_cache[aColor1][aColor2] = candidate;
    mix_cache[aColor2][aColor1] = candidate;
    return candidate;
}
コード例 #3
0
void SetGLColor( EDA_COLOR_T color, double alpha )
{
    const StructColors &colordata = g_ColorRefs[ColorGetBase( color )];

    double red     = colordata.m_Red / 255.0;
    double blue    = colordata.m_Blue / 255.0;
    double green   = colordata.m_Green / 255.0;
    glColor4f( red, green, blue, alpha );
}
コード例 #4
0
SFVEC3F CINFO3D_VISU::GetColor( EDA_COLOR_T aColor ) const
{
    const StructColors &colordata = g_ColorRefs[ColorGetBase( aColor )];

    static const float inv_255 = 1.0f / 255.0f;

    const float red     = colordata.m_Red   * inv_255;
    const float green   = colordata.m_Green * inv_255;
    const float blue    = colordata.m_Blue  * inv_255;

    return SFVEC3F( red, green, blue );
}
コード例 #5
0
SFVEC3F CINFO3D_VISU::GetLayerColor( LAYER_ID aLayerId ) const
{
    wxASSERT( aLayerId < LAYER_ID_COUNT );

    const EDA_COLOR_T color = g_ColorsSettings.GetLayerColor( aLayerId );
    const StructColors &colordata = g_ColorRefs[ColorGetBase( color )];

    static const float inv_255 = 1.0f / 255.0f;

    const float red     = colordata.m_Red   * inv_255;
    const float green   = colordata.m_Green * inv_255;
    const float blue    = colordata.m_Blue  * inv_255;

    return SFVEC3F( red, green, blue );
}
コード例 #6
0
void EDA_MSG_PANEL::showItem( wxDC& aDC, const MSG_PANEL_ITEM& aItem )
{
    EDA_COLOR_T color = aItem.m_Color;

    if( color >= 0 )
    {
        color = ColorGetBase( color );
        aDC.SetTextForeground( MakeColour( color ) );
    }

    if( !aItem.m_UpperText.IsEmpty() )
    {
        aDC.DrawText( aItem.m_UpperText, aItem.m_X, aItem.m_UpperY );
    }

    if( !aItem.m_LowerText.IsEmpty() )
    {
        aDC.DrawText( aItem.m_LowerText, aItem.m_X, aItem.m_LowerY );
    }
}