コード例 #1
0
wxColour FRLayoutConfig::getReadonlyColour()
{
    static wxColour colourReadOnly;
    if (!colourReadOnly.IsOk())
    {
        // first try to compute a colour that is between "white" and "gray"
        // (but use the actual system colours instead of hard-coded values)
        wxColour clWnd(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
        int r1 = clWnd.Red(), g1 = clWnd.Green(), b1 = clWnd.Blue();
        wxColour clBtn = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE);
        int r2 = clBtn.Red(), g2 = clBtn.Green(), b2 = clBtn.Blue();
        int distance = abs(r1 - r2) + abs(g1 - g2) + abs(b1 - b2);
        if (distance >= 72)
        {
            // start at 50 %, and use progressively lighter colours for larger
            // distances between white and gray
            int scale = (distance >= 192) ? distance / 64 : 2;
            colourReadOnly.Set(r1 + (r2 - r1) / scale,
                g1 + (g2 - g1) / scale, b1 + (b2 - b1) / scale);
        }
        else
        {
            // wxSYS_COLOUR_WINDOW and wxSYS_COLOUR_BTNFACE are too similar
            // compute a darker shade of wxSYS_COLOUR_WINDOW
            RgbHsvConversion rgbhsv(clWnd);
            rgbhsv.setValue(std::max(0.0, rgbhsv.getValue() - 0.05));
            colourReadOnly = rgbhsv.getColour();
        }
    }
    return colourReadOnly;
}
コード例 #2
0
ファイル: RgbEffectscopy.cpp プロジェクト: JonB256/xLights
void RgbEffects::Get2ColorBlend(int coloridx1, int coloridx2, double ratio, wxColour &color)
{
    wxColour c1,c2;
    palette.GetColor(coloridx1,c1);
    palette.GetColor(coloridx2,c2);
    color.Set(ChannelBlend(c1.Red(),c2.Red(),ratio), ChannelBlend(c1.Green(),c2.Green(),ratio), ChannelBlend(c1.Blue(),c2.Blue(),ratio));
}
コード例 #3
0
ファイル: PixelBuffer.cpp プロジェクト: Materdaddy/xLights
void PixelBufferClass::Get2ColorBlend(int layer, int coloridx1, int coloridx2, double ratio, wxColour &color)
{
    wxColour c1,c2;
    palette[layer].GetColor(coloridx1,c1);
    palette[layer].GetColor(coloridx2,c2);
    color.Set(ChannelBlend(c1.Red(),c2.Red(),ratio), ChannelBlend(c1.Green(),c2.Green(),ratio), ChannelBlend(c1.Blue(),c2.Blue(),ratio));
}
コード例 #4
0
ファイル: pseudodc.cpp プロジェクト: goretkin/kwc-ros-pkg
//----------------------------------------------------------------------------
// Helper functions used for drawing greyed out versions of objects
//----------------------------------------------------------------------------
wxColour &MakeColourGrey(const wxColour &c)
{
    static wxColour rval;
    rval.Set(byte((230-c.Red())*0.7+c.Red()),
             byte((230-c.Green())*0.7+c.Green()),
             byte((230-c.Blue())*0.7+c.Blue()));
    return rval;
}
コード例 #5
0
ファイル: settings.cpp プロジェクト: MaartenBent/wxWidgets
static void bg(GtkStyleContext* sc, wxColour& color, int state = GTK_STATE_FLAG_NORMAL)
{
    GdkRGBA* rgba;
    cairo_pattern_t* pattern = NULL;
    gtk_style_context_set_state(sc, GtkStateFlags(state));
    gtk_style_context_get(sc, GtkStateFlags(state),
        "background-color", &rgba, "background-image", &pattern, NULL);
    color = wxColour(*rgba);
    gdk_rgba_free(rgba);

    // "background-image" takes precedence over "background-color".
    // If there is an image, try to get a color out of it.
    if (pattern)
    {
        if (cairo_pattern_get_type(pattern) == CAIRO_PATTERN_TYPE_SURFACE)
        {
            cairo_surface_t* surf;
            cairo_pattern_get_surface(pattern, &surf);
            if (cairo_surface_get_type(surf) == CAIRO_SURFACE_TYPE_IMAGE)
            {
                const guchar* data = cairo_image_surface_get_data(surf);
                const int stride = cairo_image_surface_get_stride(surf);
                // choose a pixel in the middle vertically,
                // images often have a vertical gradient
                const int i = stride * (cairo_image_surface_get_height(surf) / 2);
                const unsigned* p = reinterpret_cast<const unsigned*>(data + i);
                const unsigned pixel = *p;
                guchar r, g, b, a = 0xff;
                switch (cairo_image_surface_get_format(surf))
                {
                case CAIRO_FORMAT_ARGB32:
                    a = guchar(pixel >> 24);
                    // fallthrough
                case CAIRO_FORMAT_RGB24:
                    r = guchar(pixel >> 16);
                    g = guchar(pixel >> 8);
                    b = guchar(pixel);
                    break;
                default:
                    a = 0;
                    break;
                }
                if (a != 0)
                {
                    if (a != 0xff)
                    {
                        // un-premultiply
                        r = guchar((r * 0xff) / a);
                        g = guchar((g * 0xff) / a);
                        b = guchar((b * 0xff) / a);
                    }
                    color.Set(r, g, b, a);
                }
            }
        }
        cairo_pattern_destroy(pattern);
    }
コード例 #6
0
ファイル: colour.cpp プロジェクト: ahlekoofe/gamekit
template<> void wxStringReadValue(const wxString &s , wxColour &data )
{
    if ( !data.Set(s) )
    {
        wxLogError(_("String To Colour : Incorrect colour specification : %s"),
                   s.c_str() );
        data = wxNullColour;
    }
}
コード例 #7
0
ファイル: Colours.cpp プロジェクト: BBkBlade/e
bool ParseColourAlpha(const char* text, wxColour& colour, unsigned int& alpha) {
	if (!text) return false;

	size_t digits = strlen(text);
	if (digits != 7 && digits != 9) return false;
	if (text[0] != '#') return false;

	int red, green, blue;
	alpha = 0;
	sscanf(text, "#%2x%2x%2x%2x", &red, &green, &blue, &alpha);

	colour.Set(red, green, blue);
	return true;
}
コード例 #8
0
ファイル: GOrgueUtil.cpp プロジェクト: e9925248/grandorgue
bool parseColor(wxColour& result, wxString value)
{
	if (value.length() == 7 && value[0] == wxT('#'))
	{
		unsigned r = 0, g = 0, b = 0;

		if (wxT('0') <= value[1] && value[1] <= wxT('9'))
			r = r * 10 + (value[1] - wxT('0'));
		else if (wxT('A') <= value[1] && value[1] <= wxT('F'))
			r = r * 10 + (value[1] - wxT('A')) + 10;
		else
			return false;
		if (wxT('0') <= value[2] && value[2] <= wxT('9'))
			r = r * 10 + (value[2] - wxT('0'));
		else if (wxT('A') <= value[2] && value[2] <= wxT('F'))
			r = r * 10 + (value[2] - wxT('A')) + 10;
		else
			return false;

		if (wxT('0') <= value[3] && value[3] <= wxT('9'))
			g = g * 10 + (value[3] - wxT('0'));
		else if (wxT('A') <= value[3] && value[3] <= wxT('F'))
			g = g * 10 + (value[3] - wxT('A')) + 10;
		else
			return false;
		if (wxT('0') <= value[4] && value[4] <= wxT('9'))
			g = g * 10 + (value[4] - wxT('0'));
		else if (wxT('A') <= value[4] && value[4] <= wxT('F'))
			g = g * 10 + (value[4] - wxT('A')) + 10;
		else
			return false;

		if (wxT('0') <= value[5] && value[5] <= wxT('9'))
			b = b * 10 + (value[5] - wxT('0'));
		else if (wxT('A') <= value[5] && value[5] <= wxT('F'))
			b = b * 10 + (value[5] - wxT('A')) + 10;
		else
			return false;
		if (wxT('0') <= value[6] && value[6] <= wxT('9'))
			b = b * 10 + (value[6] - wxT('0'));
		else if (wxT('A') <= value[6] && value[6] <= wxT('F'))
			b = b * 10 + (value[6] - wxT('A')) + 10;
		else
			return false;

		result.Set(r, g, b);
		return true;
	}
	return false;
}
コード例 #9
0
ファイル: PixelBuffer.cpp プロジェクト: JonB256/xLights
void PixelBufferClass::GetMixedColor(wxCoord x, wxCoord y, wxColour& c)
{
    wxColour c0,c1;
    wxImage::HSVValue hsv,hsv0,hsv1;
    wxImage::RGBValue rgbVal;
    double emt, emtNot;
    int n =0; //increase to change the curve of the crossfade

    Effect[0].GetPixel(x,y,c0);
    Effect[1].GetPixel(x,y,c1);
    hsv0 = wxImage::RGBtoHSV( wxImage::RGBValue( c0.Red(), c0.Green(), c0.Blue()));
    hsv1 = wxImage::RGBtoHSV(wxImage::RGBValue( c1.Red(), c1.Green(), c1.Blue()));

    hsv0.value *= fadeFactor[0];
    hsv1.value *= fadeFactor[1];

    rgbVal = wxImage::HSVtoRGB(hsv0);
    c0.Set(rgbVal.red, rgbVal.green, rgbVal.blue);
    rgbVal = wxImage::HSVtoRGB(hsv1);
    c1.Set(rgbVal.red, rgbVal.green, rgbVal.blue);

    if (effectMixVaries) //vary mix threshold gradually during effect interval -DJ
        effectMixThreshold = Effect[0].GetEffectPeriodPosition();


    switch (MixType)
    {
    case Mix_Effect1:
    case Mix_Effect2:
        emt = effectMixThreshold;
        emtNot = 1-effectMixThreshold;
        emt = cos((M_PI/4)*(pow(2*emt-1,2*n+1)+1));
        emtNot = cos((M_PI/4)*(pow(2*emtNot-1,2*n+1)+1));

        if (MixType == Mix_Effect2)
        {
            c0.Set(c0.Red()*(emtNot) ,c0.Green()*(emtNot), c0.Blue()*(emtNot));
            c1.Set(c1.Red()*(emt) ,c1.Green()*(emt), c1.Blue()*(emt));
        }
        else
        {
            c0.Set(c0.Red()*(emt) ,c0.Green()*(emt), c0.Blue()*(emt));
            c1.Set(c1.Red()*(emtNot) ,c1.Green()*(emtNot), c1.Blue()*(emtNot));
        }
        c.Set(c0.Red()+c1.Red(), c0.Green()+c1.Green(), c0.Blue()+c1.Blue());
        break;
    case Mix_Mask1:
        // first masks second
        if (hsv0.value <= effectMixThreshold) // only if effect 1 is black
        {
            c=c1;  // then show the color of effect 2
        }
        else
        {
            c.Set(0);
        }
        break;
    case Mix_Mask2:
        // second masks first
        if (hsv1.value <= effectMixThreshold)
        {
            c=c0;
        }
        else
        {
            c.Set(0);
        }
        break;
    case Mix_Unmask1:
        // first unmasks second
        if (hsv0.value > effectMixThreshold) // if effect 1 is non black
        {

            hsv1.value = hsv0.value;
            rgbVal = wxImage::HSVtoRGB(hsv1);
            c.Set(rgbVal.red, rgbVal.green, rgbVal.blue);
        }
        else
        {
            c.Set(0);
        }
        break;
    case Mix_Unmask2:
        // second unmasks first
        if (hsv1.value > effectMixThreshold)  // if effect 2 is non black
        {
            hsv0.value = hsv1.value;
            rgbVal = wxImage::HSVtoRGB(hsv0);
            c.Set(rgbVal.red, rgbVal.green, rgbVal.blue);
        }
        else
        {
            c.Set(0);
        }
        break;
    case Mix_Layered:
        if (hsv1.value <= effectMixThreshold)
        {
            c=c0;
        }
        else
        {
            c=c1;
        }
        break;
    case Mix_Average:
        // only average when both colors are non-black
        if (c0.GetRGB() == 0)
        {
            c=c1;
        }
        else if (c1.GetRGB() == 0)
        {
            c=c0;
        }
        else
        {
            c.Set( (c0.Red()+c1.Red())/2, (c0.Green()+c1.Green())/2, (c0.Blue()+c1.Blue())/2 );
        }
        break;
    case Mix_BottomTop:
        c=y < BufferHt/2 ? c0 : c1;
        break;
    case Mix_LeftRight:
        c=x < BufferWi/2 ? c0 : c1;
        break;
    case Mix_1_reveals_2:
        c = hsv0.value > effectMixThreshold ? c0 : c1; // if effect 1 is non black
        break;
    case Mix_2_reveals_1:
        c = hsv1.value > effectMixThreshold ? c1 : c0; // if effect 2 is non black
        break;
    }
}
コード例 #10
0
/*! \brief Parse tree item text.
 *
 * \param aSource wxString
 * \param outLevel int&
 * \param outColour wxColour&
 * \param outBold bool&
 * \param outImage1 int&
 * \param outImage2 int&
 * \param outImage3 int&
 * \param outImage4 int&
 * \param outText wxString&
 * \return void
 *
 */
void wxsImageTreeEditorDlg::ParseTreeItem(wxString aSource, int &outLevel, wxColour &outColour, bool &outBold, int &outImage1, int &outImage2, int &outImage3, int &outImage4, wxString &outText)
{
    int         i, n;
    long        ll;
    wxString    ss, tt;

    // working copy
    ss = aSource;

    // the depth level
    outLevel = 1;
    i  = ss.Find(wxT(","));
    if(i != wxNOT_FOUND){
        tt = ss.Left(i);
        ss.erase(0, i + 1);
        if(tt.ToLong(&ll)) outLevel = ll;
    }

    // the color
    outColour.Set(wxT("?"));
    i  = ss.Find(wxT(","));
    if(i != wxNOT_FOUND){
        tt = ss.Left(i);
        ss.erase(0, i + 1);
        outColour.Set(tt);
    }

    // bold or normal text
    n = 0;
    i  = ss.Find(wxT(","));
    if(i != wxNOT_FOUND){
        tt = ss.Left(i);
        ss.erase(0, i + 1);
        if(tt.ToLong(&ll)){
            n = ll;
        }
    }
    outBold = (n != 0);

    // 4 image indices
    outImage1 = -1;
    i  = ss.Find(wxT(","));
    if(i != wxNOT_FOUND){
        tt = ss.Left(i);
        ss.erase(0, i + 1);
        if(tt.ToLong(&ll)){
            outImage1 = ll;
        }
    }

    outImage2 = -1;
    i  = ss.Find(wxT(","));
    if(i != wxNOT_FOUND){
        tt = ss.Left(i);
        ss.erase(0, i + 1);
        if(tt.ToLong(&ll)){
            outImage2 = ll;
        }
    }

    outImage3 = -1;
    i  = ss.Find(wxT(","));
    if(i != wxNOT_FOUND){
        tt = ss.Left(i);
        ss.erase(0, i + 1);
        if(tt.ToLong(&ll)){
            outImage3 = ll;
        }
    }

    outImage4 = -1;
    i  = ss.Find(wxT(","));
    if(i != wxNOT_FOUND){
        tt = ss.Left(i);
        ss.erase(0, i + 1);
        if(tt.ToLong(&ll)){
            outImage4 = ll;
        }
    }

    // everything else is the text
    ss.Trim(true);
    ss.Trim(false);
    outText = ss;
}
コード例 #11
0
void PreviewWindow::DrawPath(wxDC& dc)
{
	wxColour cw = cCWColour;
	wxColour ccw = cCCWColour;
	for_each(toDraw.begin(), toDraw.end(), [&](PathPartSimple p)
	{
		switch(p.type)
		{
			case LINE_NORMAL:
				{
					dc.SetPen(wxPen(normalColour, lineWidth, wxSOLID));
					p.start = TransformPoint(p.start);
					p.end = TransformPoint(p.end);
					dc.DrawLine(p.start.x, p.start.y, p.end.x, p.end.y);
				}
				break;
			case LINE_RAPID:
				{
					dc.SetPen(wxPen(rapidColour, lineWidth, wxLONG_DASH));
					p.start = TransformPoint(p.start);
					p.end = TransformPoint(p.end);
					dc.DrawLine(p.start.x, p.start.y, p.end.x, p.end.y);
				}
				break;
			case CIRCLE_CW:
				{
					
					cw.Set(255-cw.Red(), cw.Green(), cw.Blue());//Differes two circles
					dc.SetPen(wxPen(cw, lineWidth, wxSOLID));
					p.start = TransformPoint(p.start);
					p.end = TransformPoint(p.end);
					p.center = TransformPoint(p.center);
					dc.SetBrush(wxBrush(wxColour(), wxTRANSPARENT));
					Vector2D distance(p.start, p.end);
					if(distance.Length() < 2)
						break;
					distance = Vector2D(p.center, p.start);
					if(distance.Length() < 2)
						break;
					dc.DrawArc(p.start.x, p.start.y, p.end.x, p.end.y, p.center.x, p.center.y);
				}
				break;
			case CIRCLE_CCW:
				{
					ccw.Set(255-ccw.Red(), ccw.Green(), ccw.Blue());//Differes two circles
					dc.SetPen(wxPen(ccw, lineWidth, wxSOLID));
					p.start = TransformPoint(p.start);
					p.end = TransformPoint(p.end);
					p.center = TransformPoint(p.center);
					dc.SetBrush(wxBrush(wxColour(), wxTRANSPARENT));
					Vector2D distance(p.start, p.end);
					if(distance.Length() < 2)
						break;
					distance = Vector2D(p.center, p.start);
					if(distance.Length() < 2)
						break;
					dc.DrawArc(p.end.x, p.end.y, p.start.x, p.start.y, p.center.x, p.center.y);
				}
				break;
		}
	});

	for_each(offsetToDraw.begin(), offsetToDraw.end(), [&](PathPartSimple p)
	{
		dc.SetPen(wxPen(wxColor(255, 255, 255), lineWidth, wxSOLID));
		switch(p.type)
		{
			case LINE_NORMAL:
				{
					p.start = TransformPoint(p.start);
					p.end = TransformPoint(p.end);
					dc.DrawLine(p.start.x, p.start.y, p.end.x, p.end.y);
				}
				break;
			case LINE_RAPID:
				{
					dc.SetPen(wxPen(wxColor(255, 255, 255), lineWidth, wxDOT_DASH));
					p.start = TransformPoint(p.start);
					p.end = TransformPoint(p.end);
					dc.DrawLine(p.start.x, p.start.y, p.end.x, p.end.y);
				}
				break;
			case CIRCLE_CW:
			case OFFSET_CIRCLE_CW:
				{
					static wxColour c = cCWColour;
					c.Set(255-c.Red(), c.Green(), c.Blue());
					p.start = TransformPoint(p.start);
					p.end = TransformPoint(p.end);
					p.center = TransformPoint(p.center);
					dc.SetBrush(wxBrush(wxColour(), wxTRANSPARENT));
					Vector2D distance(p.start, p.end);
					if(distance.Length() < 2)
						break;
					distance = Vector2D(p.center, p.start);
					if(distance.Length() < 2)
						break;
					dc.DrawArc(p.start.x, p.start.y, p.end.x, p.end.y, p.center.x, p.center.y);
				}
				break;
			case CIRCLE_CCW:
			case OFFSET_CIRCLE_CCW:
				{
					static wxColour c = cCCWColour;
					c.Set(255-c.Red(), c.Green(), c.Blue());
					p.start = TransformPoint(p.start);
					p.end = TransformPoint(p.end);
					p.center = TransformPoint(p.center);
					dc.SetBrush(wxBrush(wxColour(), wxTRANSPARENT));
					Vector2D distance(p.start, p.end);
					if(distance.Length() < 2)
						break;
					distance = Vector2D(p.center, p.start);
					if(distance.Length() < 2)
						break;
					dc.DrawArc(p.end.x, p.end.y, p.start.x, p.start.y, p.center.x, p.center.y);
				}
				break;
		}
	});
}
コード例 #12
0
ファイル: assdraw_settings.cpp プロジェクト: Aegisub/assdraw
void ASSDrawFrame::wxColourSetAlpha(wxColour &colour, long alpha)
{
	colour.Set(colour.Red(), colour.Green(), colour.Blue(), alpha);
}
コード例 #13
0
bool SjSjScreen::Render(wxDC& dc, SjVisBg& bg, bool pleaseUpdateAll)
{
	// basic screen calculations
	wxSize      dcSize = dc.GetSize(); if( dcSize.y <= 0 ) return false;
	float       dcAspect = (float)dcSize.x / (float)dcSize.y;

	float       areaAspect = 300.0F / 216.0F; // for a good compatibility to CDG, use the same area and aspect

	long areaX, areaY, areaW, areaH;
	if( dcAspect > areaAspect )
	{
		// scale by height
		areaH = long( (float)dcSize.y * KARAOKE_RENDER_SHRINK );
		areaW = long( (float)areaH * areaAspect );
	}
	else
	{
		// scale by width
		areaW = long( (float)dcSize.x * KARAOKE_RENDER_SHRINK );
		areaH = long( (float)areaW / areaAspect );
	}

	// find center
	areaX = (dcSize.x - areaW) / 2;
	areaY = (dcSize.y - areaH) / 2;

	// done?
	unsigned long stayMs = SjTools::GetMsTicks()-m_startMs;
	if( m_done )
	{
		return false;
	}
	else if( m_stayMs!=0 && stayMs > m_stayMs)
	{
		dc.SetClippingRegion(areaX, areaY, areaW, areaH);
		bg.DrawBackground(dc);
		dc.DestroyClippingRegion();
		m_done = true;
		return false;
	}

	// update font?
	{
		wxCoord fontPixelH = areaH/9;
		if( fontPixelH != m_fontPixelH )
		{
			SjVisBg::SetFontPixelH(dc, m_font, fontPixelH);
			m_fontPixelH = fontPixelH;
			pleaseUpdateAll = true;
		}

		dc.SetFont(m_font);
	}

	// draw!
	dc.SetBackgroundMode(wxTRANSPARENT);

	for( int i = 0; i <= 1; i++ )
	{
		int offset = 0;
		if( i == 0 )
		{
			// draw black shadow
			if( !pleaseUpdateAll )
				continue;

			dc.SetTextForeground(*wxBLACK);
			offset = m_fontPixelH / 16;
			if( m_fontPixelH < 2 ) m_fontPixelH = 2;
		}
		else
		{
			// draw white fade
			long g = stayMs/4;
			if( g > 245 ) g = 245;
			m_colour.Set(g, g, g);
			dc.SetTextForeground(m_colour);
		}

		long x = areaX+areaW/2;
		long y = areaY+areaH/2-m_fontPixelH; if( m_line2.IsEmpty() ) y += m_fontPixelH/2;
		DrawCentered(dc, x+offset, y+offset, m_line1);
		y += m_fontPixelH;
		DrawCentered(dc, x+offset, y+offset, m_line2);
	}

	return true;
}