本文整理汇总了C++中wxColour::Alpha方法的典型用法代码示例。如果您正苦于以下问题:C++ wxColour::Alpha方法的具体用法?C++ wxColour::Alpha怎么用?C++ wxColour::Alpha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxColour
的用法示例。
在下文中一共展示了wxColour::Alpha方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: blend50
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;
}
示例2: DrawTab
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);
}
}
示例3: wxColourToAggRGBA
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;
}
示例4:
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;
}
示例5: add
INLINE
void wxeReturn::add(wxColour colour) {
addInt(colour.Red());
addInt(colour.Green());
addInt(colour.Blue());
addInt(colour.Alpha());
addTupleCount(4);
}
示例6:
Colour::Colour( const wxColour& colour )
: m_red(colour.Red()/255.0f), m_green(colour.Green()/255.0f),
m_blue(colour.Blue()/255.0f), m_alpha(colour.Alpha()/255.0f)
{
assert(m_alpha >= 0 && m_alpha <= 1.0);
assert(m_red >= 0 && m_red <= 1.0);
assert(m_green >= 0 && m_green <= 1.0);
assert(m_blue >= 0 && m_blue <= 1.0);
}
示例7: SetColor
static void SetColor(wrDC &dc, wxColour c, bool penifgl = false)
{
if(!dc.GetDC()) {
glColor4ub(c.Red(), c.Green(), c.Blue(), c.Alpha());
if(!penifgl)
return;
}
wxPen pen = dc.GetPen();
pen.SetColour(c);
dc.SetPen(pen);
}
示例8: drawIsoLineLabelsGL
void IsoLine::drawIsoLineLabelsGL(GRIBOverlayFactory *pof,
PlugIn_ViewPort *vp, int density, int first,
wxString label, wxColour &color, TexFont &texfont)
{
std::list<Segment *>::iterator it;
int nb = first;
#ifdef ocpnUSE_GL
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
//---------------------------------------------------------
// Ecrit les labels
//---------------------------------------------------------
wxRect prev;
for (it=trace.begin(); it!=trace.end(); it++,nb++)
{
if (nb % density == 0)
{
Segment *seg = *it;
// if(vp->vpBBox.PointInBox((seg->px1 + seg->px2)/2., (seg->py1 + seg->py2)/2., 0.))
{
wxPoint ab;
GetCanvasPixLL(vp, &ab, seg->py1, seg->px1);
wxPoint cd;
GetCanvasPixLL(vp, &cd, seg->py1, seg->px1);
int w, h;
texfont.GetTextExtent(label, &w, &h);
int label_offsetx = 6, label_offsety = 1;
int xd = (ab.x + cd.x-(w+label_offsetx * 2))/2;
int yd = (ab.y + cd.y - h)/2;
int x = xd - label_offsetx, y = yd - label_offsety;
w += 2*label_offsetx, h += 2*label_offsety;
wxRect r(x,y, w,h);
r.Inflate(w);
if (!prev.Intersects(r))
{
prev = r;
glColor4ub(color.Red(), color.Green(), color.Blue(), color.Alpha());
/* draw bounding rectangle */
glBegin(GL_QUADS);
glVertex2i(x, y);
glVertex2i(x+w, y);
glVertex2i(x+w, y+h);
glVertex2i(x, y+h);
glEnd();
glColor3ub(0, 0, 0);
glBegin(GL_LINE_LOOP);
glVertex2i(x, y);
glVertex2i(x+w, y);
glVertex2i(x+w, y+h);
glVertex2i(x, y+h);
glEnd();
glEnable(GL_TEXTURE_2D);
texfont.RenderString(label, xd, yd);
glDisable(GL_TEXTURE_2D);
}
}
}
}
glDisable( GL_BLEND );
#endif
}
示例9: IsDarkColour
inline bool IsDarkColour(const wxColour& c)
{
return (c.Red() + c.Green() + c.Blue()) * c.Alpha() * 2 < 3 * 255 * 255;
}
示例10: ScaleImage
wxImage ScaleImage(wxImage image, double source_scale_factor, double content_scale_factor,
wxSize output_size, wxRect usable_rect, LSIFlags flags,
const wxColour& fill_color)
{
if (!image.IsOk())
{
wxFAIL_MSG("WxUtils::ScaleImage expects a valid image.");
return image;
}
if (content_scale_factor != 1.0)
{
output_size *= content_scale_factor;
usable_rect.SetPosition(usable_rect.GetPosition() * content_scale_factor);
usable_rect.SetSize(usable_rect.GetSize() * content_scale_factor);
}
// Fix the output size if it's unset.
wxSize img_size = image.GetSize();
if (output_size.GetWidth() < 1)
output_size.SetWidth(
static_cast<int>(img_size.GetWidth() * (content_scale_factor / source_scale_factor)));
if (output_size.GetHeight() < 1)
output_size.SetHeight(
static_cast<int>(img_size.GetHeight() * (content_scale_factor / source_scale_factor)));
// Fix the usable rect. If it's empty then the whole canvas is usable.
if (usable_rect.IsEmpty())
{
// Constructs a temp wxRect 0,0->output_size then move assigns it.
usable_rect = output_size;
}
else if (!usable_rect.Intersects(output_size))
{
wxFAIL_MSG("Usable Zone Rectangle is not inside the canvas. Check the output size is correct.");
image.Create(1, 1, false);
image.SetRGB(0, 0, fill_color.Red(), fill_color.Green(), fill_color.Blue());
if (fill_color.Alpha() == wxALPHA_TRANSPARENT)
image.SetMaskColour(fill_color.Red(), fill_color.Green(), fill_color.Blue());
usable_rect = output_size;
}
// Step 1: Scale the image
if ((flags & LSI_SCALE) != LSI_SCALE_NONE)
{
if (flags & LSI_SCALE_NO_ASPECT)
{
// Stretch scale without preserving the aspect ratio.
bool scale_width = (img_size.GetWidth() > usable_rect.GetWidth() && flags & LSI_SCALE_DOWN) ||
(img_size.GetWidth() < usable_rect.GetWidth() && flags & LSI_SCALE_UP);
bool scale_height =
(img_size.GetHeight() > usable_rect.GetHeight() && flags & LSI_SCALE_DOWN) ||
(img_size.GetHeight() < usable_rect.GetHeight() && flags & LSI_SCALE_UP);
if (scale_width || scale_height)
{
// NOTE: Using BICUBIC instead of HIGH because it's the same internally
// except that downscaling uses a box filter with awful obvious aliasing
// for non-integral scale factors.
image.Rescale(scale_width ? usable_rect.GetWidth() : img_size.GetWidth(),
scale_height ? usable_rect.GetHeight() : img_size.GetHeight(),
wxIMAGE_QUALITY_BICUBIC);
}
}
else
{
// Scale while preserving the aspect ratio.
double scale = std::min(static_cast<double>(usable_rect.GetWidth()) / img_size.GetWidth(),
static_cast<double>(usable_rect.GetHeight()) / img_size.GetHeight());
int target_width = static_cast<int>(img_size.GetWidth() * scale);
int target_height = static_cast<int>(img_size.GetHeight() * scale);
// Bilinear produces sharper images when upscaling, bicubic tends to smear/blur sharp edges.
if (scale > 1.0 && flags & LSI_SCALE_UP)
image.Rescale(target_width, target_height, wxIMAGE_QUALITY_BILINEAR);
else if (scale < 1.0 && flags & LSI_SCALE_DOWN)
image.Rescale(target_width, target_height, wxIMAGE_QUALITY_BICUBIC);
}
img_size = image.GetSize();
}
// Step 2: Resize the canvas to match the output size.
// NOTE: If NOT using LSI_SCALE_DOWN then this will implicitly crop the image
if (img_size != output_size || usable_rect.GetPosition() != wxPoint())
{
wxPoint base = usable_rect.GetPosition();
if (flags & LSI_ALIGN_HCENTER)
base.x += (usable_rect.GetWidth() - img_size.GetWidth()) / 2;
else if (flags & LSI_ALIGN_RIGHT)
base.x += usable_rect.GetWidth() - img_size.GetWidth();
if (flags & LSI_ALIGN_VCENTER)
base.y += (usable_rect.GetHeight() - img_size.GetHeight()) / 2;
else if (flags & LSI_ALIGN_BOTTOM)
base.y += usable_rect.GetHeight() - img_size.GetHeight();
int r = -1, g = -1, b = -1;
if (fill_color.Alpha() != wxALPHA_TRANSPARENT)
{
r = fill_color.Red();
g = fill_color.Green();
b = fill_color.Blue();
}
//.........这里部分代码省略.........
示例11: DoPreviewBitmap
void wxGenericColourDialog::DoPreviewBitmap(wxBitmap& bmp, const wxColour& colour)
{
if ( bmp.HasAlpha() && colour.Alpha() != wxALPHA_OPAQUE )
{
// For real ARGB draw a chessboard grid
// with actual ARGB fields and reference RGB fields.
const int w = bmp.GetWidth();
const int h = bmp.GetHeight();
// Calculate field size: 4 fields per row/column,
// with size in range [2..10]
int dx = wxMax(wxMin(w / 4, 10), 2);
int dy = wxMax(wxMin(h / 4, 10), 2);
// We want a square field
dx = wxMax(dx, dy);
dy = dx;
// Prepare opaque colour
wxColour colourRGB(colour.Red(), colour.Green(), colour.Blue(), wxALPHA_OPAQUE);
{
wxBrush brushARGB(colour);
wxBrush brushRGB(colourRGB);
wxMemoryDC mdc(bmp);
{
wxGCDC gdc(mdc);
gdc.SetPen(*wxTRANSPARENT_PEN);
for (int x = 0, ix = 0; x < w; x += dx, ix++)
{
for (int y = 0, iy = 0; y < h; y += dy, iy++)
{
if ( (ix+iy) % 2 == 0 )
{
gdc.SetBrush(brushARGB);
}
else
{
gdc.SetBrush(brushRGB);
}
gdc.DrawRectangle(x, y, dx, dy);
}
}
// Draw a frame
gdc.SetPen(*wxBLACK_PEN);
gdc.SetBrush(*wxTRANSPARENT_BRUSH);
gdc.DrawRectangle(0, 0, w, h);
}
}
}
else
{
wxMemoryDC mdc(bmp);
// Fill with custom colour
wxBrush brush(colour);
mdc.SetPen(*wxBLACK_PEN);
mdc.SetBrush(brush);
mdc.DrawRectangle(wxPoint(0, 0), bmp.GetSize());
}
}
示例12: wxColour
SkinColor::SkinColor(const wxColour& c)
: wxColour(c)
, SkinRegion(*wxTRANSPARENT_PEN)
{
m_opaque = c.Alpha() == 255;
}
示例13: SelectColour
void wxDC::SelectColour(const wxColour& clr)
{
m_surface->SetColor(clr.Red(), clr.Green(), clr.Blue(), clr.Alpha());
#warning "use SetColorIndex?"
}
示例14: Darken
static wxColour Darken(wxColour c)
{
return wxColour(c.Red()*2/3, c.Green()*2/3, c.Blue()*2/3, c.Alpha());
}
示例15: drawTextWithSpacing
void drawTextWithSpacing(GraphicsContext* graphicsContext, const SimpleFontData* font, const wxColour& color, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point)
{
#if USE(WXGC)
wxGCDC* dc = static_cast<wxGCDC*>(graphicsContext->platformContext());
wxGraphicsContext* gc = dc->GetGraphicsContext();
gc->PushState();
cairo_t* cr = (cairo_t*)gc->GetNativeContext();
wxFont* wxfont = font->getWxFont();
cairo_scaled_font_t* scaled_font = 0;
#if wxUSE_PANGO
PangoFont* pangoFont = createPangoFontForFont(wxfont);
PangoFontMap* fontMap = pangoFontMap();
PangoContext* pangoContext = pango_cairo_font_map_create_context(PANGO_CAIRO_FONT_MAP(fontMap));
scaled_font = createScaledFontForFont(wxfont);
#elif __WXMSW__
cairo_matrix_t sizeMatrix, ctm;
cairo_matrix_init_identity(&ctm);
int size = font->platformData().size();
cairo_matrix_init_scale(&sizeMatrix, size, size);
cairo_font_options_t* fontOptions = cairo_font_options_create();
cairo_font_options_set_antialias(fontOptions, CAIRO_ANTIALIAS_SUBPIXEL);
cairo_font_face_t* win_face = cairo_win32_font_face_create_for_hfont((HFONT)wxfont->GetHFONT());
scaled_font = cairo_scaled_font_create(win_face, &sizeMatrix, &ctm, fontOptions);
#endif
ASSERT(scaled_font);
GlyphBufferGlyph* glyphs = const_cast<GlyphBufferGlyph*>(glyphBuffer.glyphs(from));
float offset = point.x();
for (int i = 0; i < numGlyphs; i++) {
#if wxUSE_PANGO
glyphs[i].index = pango_font_get_glyph(pangoFont, pangoContext, glyphBuffer.glyphAt(from + i));
#endif
glyphs[i].x = offset;
glyphs[i].y = point.y();
offset += glyphBuffer.advanceAt(from + i);
}
cairo_set_source_rgba(cr, color.Red()/255.0, color.Green()/255.0, color.Blue()/255.0, color.Alpha()/255.0);
cairo_set_scaled_font(cr, scaled_font);
cairo_show_glyphs(cr, glyphs, numGlyphs);
cairo_scaled_font_destroy(scaled_font);
gc->PopState();
#else
wxDC* dc = graphicsContext->platformContext();
wxFont* wxfont = font->getWxFont();
if (wxfont && wxfont->IsOk())
dc->SetFont(*wxfont);
dc->SetTextForeground(color);
// convert glyphs to wxString
GlyphBufferGlyph* glyphs = const_cast<GlyphBufferGlyph*>(glyphBuffer.glyphs(from));
int offset = point.x();
wxString text = wxEmptyString;
for (unsigned i = 0; i < numGlyphs; i++) {
text = text.Append((wxChar)glyphs[i]);
offset += glyphBuffer.advanceAt(from + i);
}
// the y point is actually the bottom point of the text, turn it into the top
float height = font->ascent() - font->descent();
wxCoord ypoint = (wxCoord) (point.y() - height);
dc->DrawText(text, (wxCoord)point.x(), ypoint);
#endif
}