Esempio n. 1
0
wxColor wxGradient::lerp(wxColor c1, wxColor c2, double value)
{
	unsigned char R = (1.0 - value)*c1.Red() + value*c2.Red();
	unsigned char G = (1.0 - value)*c1.Green() + value*c2.Green();
	unsigned char B = (1.0 - value)*c1.Blue() + value*c2.Blue();
	return wxColor(R,G,B);
}
Esempio n. 2
0
 String entityColorAsString(const wxColor& color, const Assets::ColorRange::Type colorRange) {
     StringStream result;
     if (colorRange == Assets::ColorRange::Byte) {
         result << int(color.Red()) << " " << int(color.Green()) << " " << int(color.Blue());
     } else if (colorRange == Assets::ColorRange::Float) {
         result << float(color.Red()) / 255.0f << " " << float(color.Green()) / 255.0f << " "<< float(color.Blue()) / 255.0f;
     }
     return result.str();
 }
Esempio n. 3
0
void Overlay::bg_color_updated(const wxColor& bg)
{
    if (0.299*bg.Red() + 0.587*bg.Green() + 0.114*bg.Blue() < 128)
        color_.Set(192, 192, 192);
    else
        color_.Set(64, 64, 64);
}
// StepColour() it a utility function that simply darkens
// or lightens a color, based on the specified percentage
static wxColor StepColour(const wxColor& c, int percent)
{
    int r = c.Red(), g = c.Green(), b = c.Blue();
    return wxColour((unsigned char)wxMin((r*percent)/100,255),
                    (unsigned char)wxMin((g*percent)/100,255),
                    (unsigned char)wxMin((b*percent)/100,255));
}
Esempio n. 5
0
wxBitmap ConvertTo24Bit( wxColor bgColor, wxBitmap front ) {
    if( front.GetDepth() == 24 ) return front;

    wxBitmap result( front.GetWidth(), front.GetHeight(), 24 );
    front.UseAlpha();

    wxImage im_front = front.ConvertToImage();
    wxImage im_result = result.ConvertToImage();

    unsigned char *presult = im_result.GetData();
    unsigned char *pfront = im_front.GetData();

    unsigned char *afront = NULL;
    if( im_front.HasAlpha() )
        afront = im_front.GetAlpha();

    for( int i = 0; i < result.GetWidth(); i++ ) {
        for( int j = 0; j < result.GetHeight(); j++ ) {

            double alphaF = (double) ( *afront++ ) / 256.0;
            unsigned char r = *pfront++ * alphaF + bgColor.Red() * ( 1.0 - alphaF );
            *presult++ = r;
            unsigned char g = *pfront++ * alphaF + bgColor.Green() * ( 1.0 - alphaF );
            *presult++ = g;
            unsigned char b = *pfront++ * alphaF + bgColor.Blue() * ( 1.0 - alphaF );
            *presult++ = b;
        }
    }

    result = wxBitmap( im_result );
    return result;
}
Esempio n. 6
0
static wxColor wxStepColour(const wxColor& c, int ialpha)
{
    if (ialpha == 100)
        return c;

    double r = c.Red(), g = c.Green(), b = c.Blue();
    double bg;

    // ialpha is 0..200 where 0 is completely black
    // and 200 is completely white and 100 is the same
    // convert that to normal alpha 0.0 - 1.0
    ialpha = wxMin(ialpha, 200);
    ialpha = wxMax(ialpha, 0);
    double alpha = ((double)(ialpha - 100.0))/100.0;

    if (ialpha > 100)
    {
        // blend with white
        bg = 255.0;
        alpha = 1.0 - alpha;  // 0 = transparent fg; 1 = opaque fg
    }
     else
    {
        // blend with black
        bg = 0.0;
        alpha = 1.0 + alpha;  // 0 = transparent fg; 1 = opaque fg
    }

    r = wxBlendColour(r, bg, alpha);
    g = wxBlendColour(g, bg, alpha);
    b = wxBlendColour(b, bg, alpha);

    return wxColour((unsigned char)r, (unsigned char)g, (unsigned char)b);
}
Esempio n. 7
0
	wxColor
	TextColorFromBG(const wxColor& bg)
	{
		int gray = 77 * bg.Red() + 151 * bg.Green() + 28 * bg.Blue();
		gray >>= 8;
		gray = gray < 128 ? 255 : 0;
		return wxColor(gray, gray, gray);
	}
Esempio n. 8
0
wxColor CodeEdit::GetInverse(const wxColor& color)
{

    unsigned char r = color.Red();
    unsigned char g = color.Green();
    unsigned char b = color.Blue();

    return wxColor( r ^ 0xFF, g ^ 0xFF, b ^ 0xFF );

}
Esempio n. 9
0
wxImage zen::createImageFromText(const wxString& text, const wxFont& font, const wxColor& col)
{
    //wxDC::DrawLabel() doesn't respect alpha channel => calculate alpha values manually:

    if (text.empty())
        return wxImage();

    wxBitmap newBitmap(getTextExtent(text, font)); //seems we don't need to pass 24-bit depth here even for high-contrast color schemes
    {
        wxMemoryDC dc(newBitmap);
        dc.SetBackground(*wxWHITE_BRUSH);
        dc.Clear();

        dc.SetTextForeground(*wxBLACK); //for use in calcAlphaForBlackWhiteImage
        dc.SetTextBackground(*wxWHITE); //
        dc.SetFont(font);

        //assert(!contains(text, L"&")); //accelerator keys not supported here; see also getTextExtent()
        wxString textFmt = replaceCpy(text, L"&", L"", false);

        //for some reason wxDC::DrawText messes up "weak" bidi characters even when wxLayout_RightToLeft is set! (--> arrows in hebrew/arabic)
        //=> use mark characters instead:
        const wchar_t rtlMark = L'\u200F';
        if (wxTheApp->GetLayoutDirection() == wxLayout_RightToLeft)
            textFmt = rtlMark + textFmt + rtlMark;

        dc.DrawText(textFmt, wxPoint());
    }

    wxImage output(newBitmap.ConvertToImage());
    output.SetAlpha();

    //calculate alpha channel
    calcAlphaForBlackWhiteImage(output);

    //apply actual text color
    unsigned char* dataPtr = output.GetData();
    const int pixelCount = output.GetWidth() * output.GetHeight();
    for (int i = 0; i < pixelCount; ++ i)
    {
        *dataPtr++ = col.Red();
        *dataPtr++ = col.Green();
        *dataPtr++ = col.Blue();
    }
    return output;
}
void MadHighlightingDialog::SetPanelBC(const wxColor &color)
{
    if(color==wxNullColour)
    {
        WxStaticTextBCName->SetLabel(wxT("(Automatic)"));
        WxPanelBC->SetBackgroundColour(WxListCtrlBC->GetItemBackgroundColour(0));
        WxPanelBC->ClearBackground();
    }
    else
    {
        wxString cname=wxTheColourDatabase->FindName(color);
        if(cname.IsEmpty())
        {
            cname.Printf(wxT("#%02X%02X%02X"), color.Red(), color.Green(), color.Blue());
        }
        WxStaticTextBCName->SetLabel(cname);
        WxPanelBC->SetBackgroundColour(color);
        WxPanelBC->ClearBackground();
    }
}
Esempio n. 11
0
PMSColor::PMSColor(wxColor col)
    :  blue{col.Blue()}, green{col.Green()}, red{col.Red()}, alpha{col.Alpha()}
{
}
Esempio n. 12
0
wxColor CamArtProvider::LightenColour(const wxColor& c, INT32 amount)
{
    INT32 r = 255-c.Red(), g = 255-c.Green(), b = 255-c.Blue();
    return wxColour(255-(r*amount)/100, 255-(g*amount)/100, 255-(b*amount)/100);
}
Esempio n. 13
0
wxColor CamArtProvider::DarkenColour(const wxColor& c, INT32 amount)
{
    INT32 r = c.Red(), g = c.Green(), b = c.Blue();
    return wxColour((r*amount)/100, (g*amount)/100, (b*amount)/100);
}
static wxColour TransparentColor(wxColor c)
{
    return wxColor(c.Red(), c.Green(), c.Blue(), c.Alpha()*7/24);
}