wxImage ReplaceChannelStatusColour( wxBitmap img, const wxColour& colour ) { wxImage ret = img.ConvertToImage(); wxImage::HSVValue origcolour = wxImage::RGBtoHSV( wxImage::RGBValue( colour.Red(), colour.Green(), colour.Blue() ) ); double bright = origcolour.value - 0.1*origcolour.value; bright = LSL::Util::Clamp( bright, 0.0, 1.0 ); wxImage::HSVValue hsvdarker1( origcolour.hue, origcolour.saturation, bright ); bright = origcolour.value - 0.5*origcolour.value; bright = LSL::Util::Clamp( bright, 0.0, 1.0 ); wxImage::HSVValue hsvdarker2( origcolour.hue, origcolour.saturation, bright ); wxImage::RGBValue rgbdarker1 = wxImage::HSVtoRGB( hsvdarker1 ); wxImage::RGBValue rgbdarker2 = wxImage::HSVtoRGB( hsvdarker2 ); ret.Replace( 164, 147, 0, rgbdarker2.red, rgbdarker2.green, rgbdarker2.blue ); ret.Replace( 255, 228, 0, rgbdarker1.red, rgbdarker1.green, rgbdarker1.blue ); ret.Replace( 255, 253, 234, colour.Red(), colour.Green(), colour.Blue() ); return ret; }
wxColour PivotColour(const wxColour &in) { double br = in.Red(); double bg = in.Green(); double bb = in.Blue(); double pr = pivot.Red(); double pg = pivot.Green(); double pb = pivot.Blue(); double factor = 0.35; auto trans = [&](double &b, double p) { double delta = b - p; if (b > p) { delta *= p / (255 - p); } else { delta *= (255 - p) / p; } delta *= factor; b = p - delta; }; trans(br, pr); trans(bg, pg); trans(bb, pb); return NormaliseColour(br, bg, bb); }
wxColour AColor::Blend( const wxColour & c1, const wxColour & c2 ) { wxColour c3( (c1.Red() + c2.Red())/2, (c1.Green() + c2.Green())/2, (c1.Blue() + c2.Blue())/2); return c3; }
wxColour blend50(const wxColour& c1, const wxColour& c2) { unsigned char r,g,b,a; r = c1.Red()/2 + c2.Red()/2; g = c1.Green()/2 + c2.Green()/2; b = c1.Blue()/2 + c2.Blue()/2; a = c1.Alpha()/2 + c2.Alpha()/2; return a << 24 | b << 16 | g << 8 | r; }
wxString WriteColourAlpha(const wxColour& colour, const unsigned int alpha) { wxASSERT(colour.Ok()); wxASSERT(alpha <= 256); if (alpha) return wxString::Format(wxT("#%02X%02X%02X%02X"), colour.Red(), colour.Green(), colour.Blue(), alpha); else return wxString::Format(wxT("#%02X%02X%02X"), colour.Red(), colour.Green(), colour.Blue()); }
///This will explicitly shift the image color from ///srcColour to dstColour. std::unique_ptr<wxImage> ChangeImageColour(wxImage * srcImage, wxColour & srcColour, wxColour & dstColour) { // This function takes a source image, which it assumes to // be grayscale, and smoothly changes the overall color // to the specified color, and returns the result as a // NEW image. This works well for grayscale 3D images. // Audacity uses this routines to make the buttons // (skip-start, play, stop, record, skip-end) adapt to // the color scheme of the user. unsigned char *src = srcImage->GetData(); int width = srcImage->GetWidth(); int height = srcImage->GetHeight(); auto dstImage = std::make_unique<wxImage>(width, height); unsigned char *dst = dstImage->GetData(); //Get the source color int srcVal[3], srcOpp[3]; srcVal[0] = srcColour.Red(); srcVal[1] = srcColour.Green(); srcVal[2] = srcColour.Blue(); int dstVal[3], dstOpp[3]; dstVal[0] = dstColour.Red(); dstVal[1] = dstColour.Green(); dstVal[2] = dstColour.Blue(); int i; for (i = 0; i < 3; i++) { srcOpp[i] = 256 - srcVal[i]; // avoid zero! dstOpp[i] = 255 - dstVal[i]; } int c = 0; for (i = 0; i < width * height * 3; i++) { int s = (int) *src; if (s >= srcVal[c]) *dst++ = dstVal[c] + dstOpp[c] * (s - srcVal[c]) / srcOpp[c]; else *dst++ = dstVal[c] * s / srcVal[c]; src++; c = (c + 1) % 3; } return dstImage; }
static bool LINKAGEMODE MatchBoundaryPixel(wxImage *img, int x, int y, int w, int h, const wxColour & fill, const wxColour& bound) { if ((x<0)||(x>=w)||(y<0)||(y>=h)) return true; unsigned char r = img->GetRed(x,y); unsigned char g = img->GetGreen(x,y); unsigned char b = img->GetBlue(x,y); if ( fill.Red() == r && fill.Green() == g && fill.Blue() == b ) return true; if ( bound.Red() == r && bound.Green() == g && bound.Blue() == b ) return true; return false; }
bool AreColoursSimilar( const wxColour& col1, const wxColour& col2, int mindiff ) { int r,g,b; r = col1.Red() - col2.Red(); g = col1.Green() - col2.Green(); b = col1.Blue() - col2.Blue(); r = r>0?r:-r; g = g>0?g:-g; b = b>0?b:-b; int difference = std::min( r, g ); difference = std::min( difference, b ); return difference < mindiff; }
virtual void DrawTab(wxDC &dc, wxWindow *wnd, const wxAuiNotebookPage &page, const wxRect &rect, int close_button_state, wxRect *out_tab_rect, wxRect *out_button_rect, int *x_extent) { wxColour const tint = m_pNotebook->GetTabColour(page.window); if (tint.IsOk()) { #if !defined(__WXGTK__) || !defined(wxHAS_NATIVE_TABART) wxColour const baseOrig = m_baseColour; wxColour const activeOrig = m_activeColour; wxColour const base( wxColour::AlphaBlend(tint.Red(), baseOrig.Red(), tint.Alpha() / 255.0f), wxColour::AlphaBlend(tint.Green(), baseOrig.Green(), tint.Alpha() / 255.0f), wxColour::AlphaBlend(tint.Blue(), baseOrig.Blue(), tint.Alpha() / 255.0f)); wxColour const active( wxColour::AlphaBlend(tint.Red(), activeOrig.Red(), tint.Alpha() / 255.0f), wxColour::AlphaBlend(tint.Green(), activeOrig.Green(), tint.Alpha() / 255.0f), wxColour::AlphaBlend(tint.Blue(), activeOrig.Blue(), tint.Alpha() / 255.0f)); m_baseColour = base; m_activeColour = active; wxAuiDefaultTabArt::DrawTab(dc, wnd, page, rect, close_button_state, out_tab_rect, out_button_rect, x_extent); m_baseColour = baseOrig; m_activeColour = baseOrig; #else wxRect tab_rect; if (!out_tab_rect) { out_tab_rect = &tab_rect; } wxAuiDefaultTabArt::DrawTab(dc, wnd, page, rect, close_button_state, out_tab_rect, out_button_rect, x_extent); wxMemoryDC *mdc = dynamic_cast<wxMemoryDC*>(&dc); if (mdc) { wxGraphicsContext *gc = wxGraphicsContext::Create(*mdc); if (gc) { gc->SetBrush(wxBrush(tint)); gc->DrawRectangle(out_tab_rect->x, out_tab_rect->y, out_tab_rect->width, out_tab_rect->height); delete gc; } } #endif } else { wxAuiDefaultTabArt::DrawTab(dc, wnd, page, rect, close_button_state, out_tab_rect, out_button_rect, x_extent); } }
wxString ColourString(wxColour col, int type) { wxString colstring; if(type == 0) return colstring.Format("%.4f %.4f %.4f", (double)col.Red()/255, (double)col.Green()/255, (double)col.Blue()/255); else return colstring.Format("%d %d %d", col.Red(), col.Green(), col.Blue()); }
wxImage tintImage( wxImage to_colorize, wxColour col) { wxImage highlightIcon(to_colorize.GetWidth(),to_colorize.GetHeight()); bool do_alpha = false; if(to_colorize.HasAlpha()) { highlightIcon.InitAlpha(); do_alpha = true; } else if(to_colorize.HasMask()) { highlightIcon.SetMaskFromImage(to_colorize,to_colorize.GetMaskRed(),to_colorize.GetMaskGreen(),to_colorize.GetMaskBlue()); } for(int x = 0; x < highlightIcon.GetWidth(); x++) { for(int y = 0; y < highlightIcon.GetHeight(); y++) { to_colorize.GetData(); unsigned char srcR = to_colorize.GetRed(x,y); unsigned char srcG = to_colorize.GetGreen(x,y); unsigned char srcB = to_colorize.GetBlue(x,y); highlightIcon.SetRGB(x,y,(srcR + col.Red())/2,(srcG + col.Green())/2, (srcB + col.Blue())/2); if(do_alpha) highlightIcon.SetAlpha(x,y,to_colorize.GetAlpha(x,y)); } } return highlightIcon; }
bool wxGenericColour::IsSameAs( const wxColour& c ) const { wxCHECK_MSG(Ok() && c.Ok(), false, wxT("Invalid colour")); return (M_GCOLOURDATA->m_r == c.Red()) && (M_GCOLOURDATA->m_g == c.Green()) && (M_GCOLOURDATA->m_b == c.Blue()); }
void wxGenericColour::Set( const wxColour& c ) { wxCHECK_RET(Ok() && c.Ok(), wxT("Invalid colour")); M_GCOLOURDATA->m_r = c.Red(); M_GCOLOURDATA->m_g = c.Green(); M_GCOLOURDATA->m_b = c.Blue(); }
bool DrawingUtils::IsDark(const wxColour& color) { int evg = (color.Red() + color.Green() + color.Blue()) / 3; if(evg < 127) return true; return false; }
void OpenGLWrapper::SetLineColour(wxColour col, float alpha, int width) { line_r = col.Red() / 255.f; line_g = col.Green() / 255.f; line_b = col.Blue() / 255.f; line_a = alpha; line_width = width; }
inline void wxAdjustToColour( unsigned char& r, unsigned char& g, unsigned char& b, const wxColour& c) { r = wxAdjustToColour(r, c.Red()); g = wxAdjustToColour(g, c.Green()); b = wxAdjustToColour(b, c.Blue()); }
void ASSDrawFrame::wxColourToAggRGBA(wxColour &colour, agg::rgba &rgba) { rgba.r = (double) colour.Red() / 255.0; rgba.g = (double) colour.Green() / 255.0; rgba.b = (double) colour.Blue() / 255.0; rgba.a = (double) colour.Alpha() / 255.0; }
wxBitmap getColourIcon(const wxColour& colour) { wxImage img(colourbox_xpm); img.Replace(1, 1, 1, colour.Red(), colour.Green(), colour.Blue()); int r, g, b; r = colour.Red() + 80; g = colour.Green() + 80; b = colour.Blue() + 80; img.Replace(2, 2, 2, r > 255 ? 255 : r, g > 255 ? 255 : g, b > 255 ? 255 : b); /*r = colour.Red()-60; g = colour.Green()-60; b = colour.Blue()-60; img.Replace( 200, 200, 200, r<0?0:r, g<0?0:g, b<0?0:b );*/ return wxBitmap(img); // assert( IsOk() ); }
COLOR4D::COLOR4D( const wxColour& aColor ) { r = aColor.Red() / 255.0; g = aColor.Green() / 255.0; b = aColor.Blue() / 255.0; a = aColor.Alpha() / 255.0; }
int wxImageList::Add( const wxBitmap& bitmap, const wxColour& maskColour ) { wxImage img = bitmap.ConvertToImage(); img.SetMaskColour( maskColour.Red(), maskColour.Green(), maskColour.Blue() ); return Add( wxBitmap( img ) ); }
void FaceView::setBackgroundColour(wxColour col) { SetCurrent(); // m_clearColor = col; glClearColor((float)col.Red() / 255.0f, (float)col.Green() / 255.0f, (float)col.Blue() / 255.0f, 1.0f); //Background color Refresh(); }
void x11_draw_glyphs( Drawable drawable, GC gc, PangoFont *font, int x, int y, PangoGlyphString *glyphs, wxColour &colour ) { if (PANGO_XFT_IS_FONT (font)) { Display* xdisplay = wxGlobalDisplay(); int xscreen = DefaultScreen( xdisplay ); Visual* xvisual = DefaultVisual( xdisplay, xscreen ); Colormap xcolormap = DefaultColormapOfScreen( XScreenOfDisplay( xdisplay, xscreen ) ); XftDraw *draw = XftDrawCreate( xdisplay, drawable, xvisual, xcolormap ); XftColor color; color.pixel = 0; color.color.red = colour.Red() << 8; color.color.green = colour.Green() << 8; color.color.blue = colour.Blue() << 8; color.color.alpha = 65000; pango_xft_render( draw, &color, font, glyphs, x, y ); XftDrawDestroy( draw ); } }
void ModelPreview::DrawPoint(const wxColour &color, wxDouble x, wxDouble y) { glColor3ub(color.Red(), color.Green(),color.Blue()); glBegin(GL_POINTS); glBegin(GL_POINTS); glVertex2f(x, y); glEnd(); }
// ---------------------------------------------------------------------------- wxColor BrowseSelector::LightColour(const wxColour& color, int percent) // ---------------------------------------------------------------------------- { int rd, gd, bd, high = 0; wxColor end_color = wxT("WHITE"); rd = end_color.Red() - color.Red(); gd = end_color.Green() - color.Green(); bd = end_color.Blue() - color.Blue(); high = 100; // We take the percent way of the color from color --> white int i = percent; int r = color.Red() + ((i*rd*100)/high)/100; int g = color.Green() + ((i*gd*100)/high)/100; int b = color.Blue() + ((i*bd*100)/high)/100; return wxColor(r, g, b); }
static wxBitmap wxAuiBitmapFromBits(const unsigned char bits[], int w, int h, const wxColour& color) { wxImage img = wxBitmap((const char*)bits, w, h).ConvertToImage(); img.Replace(0,0,0,123,123,123); img.Replace(255,255,255,color.Red(),color.Green(),color.Blue()); img.SetMaskColour(123,123,123); return wxBitmap(img); }
void IconImageList::SetColourIcon( const int& num, const wxColour& colour ) { wxImage img( colourbox_xpm ); img.Replace( 1, 1, 1, colour.Red(), colour.Green(), colour.Blue() ); int r,g,b; r = colour.Red()+80; g = colour.Green()+80; b = colour.Blue()+80; img.Replace( 2, 2, 2, r>255?255:r, g>255?255:g, b>255?255:b ); /*r = colour.Red()-60; g = colour.Green()-60; b = colour.Blue()-60; img.Replace( 200, 200, 200, r<0?0:r, g<0?0:g, b<0?0:b );*/ if ( m_player_colour_icons[num] != 0 ) Replace( m_player_colour_icons[num], wxBitmap( img ) ); else m_player_colour_icons[num] = Add( wxBitmap( img ) ); }
static wxColour wxColourBase_ChangeLightness(const wxColour& colour, int ialpha) { wxByte r = colour.Red(); wxByte g = colour.Green(); wxByte b = colour.Blue(); wxColourBase_ChangeLightness(&r, &g, &b, ialpha); return wxColour(r,g,b); }
INLINE void wxeReturn::add(wxColour colour) { addInt(colour.Red()); addInt(colour.Green()); addInt(colour.Blue()); addInt(colour.Alpha()); addTupleCount(4); }
wxColour ColourDelta(const wxColour& colour, const int& delta) { int r = colour.Red(); int g = colour.Green(); int b = colour.Blue(); ColourDelta(r, g, b, delta); return wxColour(r, g, b); }
static bool LINKAGEMODE MatchPixel(wxImage *img, int x, int y, int w, int h, const wxColour& c) { if ((x<0)||(x>=w)||(y<0)||(y>=h)) return false; unsigned char r = img->GetRed(x,y); unsigned char g = img->GetGreen(x,y); unsigned char b = img->GetBlue(x,y); return c.Red() == r && c.Green() == g && c.Blue() == b ; }