本文整理汇总了C++中cairo::RefPtr::paint方法的典型用法代码示例。如果您正苦于以下问题:C++ RefPtr::paint方法的具体用法?C++ RefPtr::paint怎么用?C++ RefPtr::paint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cairo::RefPtr
的用法示例。
在下文中一共展示了RefPtr::paint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: on_expose_event
bool Canvas::on_expose_event(GdkEventExpose * evt) {
Glib::RefPtr<Gdk::Window> window = get_window();
if (!window) return false; // no window yet?
if (!seen_first_expose_event) {
seen_first_expose_event = true;
main->controlsWindow().starting_position();
}
Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
if (!surface) return true; // Haven't rendered yet? Nothing we can do
if (evt) {
cr->rectangle(evt->area.x, evt->area.y, evt->area.width, evt->area.height);
cr->clip();
}
cr->set_source(surface, 0, 0);
cr->paint();
if (main->dragrect.is_active() && main->dragrect.surface_valid()) {
cr->save();
cr->set_source(main->dragrect.get_surface(), 0, 0);
cr->paint();
cr->restore();
}
if (main->hud_active()) {
Cairo::RefPtr<Cairo::Surface>& sfc = main->get_hud_surface();
if (sfc)
cr->set_source(sfc, 0, 0); // TODO HUD position
cr->paint();
}
return true;
}
示例2: on_draw
bool ScreenAreaCairo::on_draw(const Cairo::RefPtr<Cairo::Context>& poContext)
{
DrawingArea::on_draw(poContext);
Cairo::RefPtr<Cairo::ImageSurface> poImage;
Cairo::RefPtr<Cairo::SurfacePattern> poPattern;
Cairo::Matrix oMatrix;
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(u32);
//poContext->set_identity_matrix();
poContext->scale(m_dScaleFactor, m_dScaleFactor);
poImage = Cairo::ImageSurface::create((u8*)m_puiPixels, Cairo::FORMAT_RGB24,
m_iScaledWidth, m_iScaledHeight, iScaledPitch);
//cairo_matrix_init_translate(&oMatrix, -m_iAreaLeft, -m_iAreaTop);
poPattern = Cairo::SurfacePattern::create(poImage);
poPattern->set_filter(Cairo::FILTER_NEAREST);
//poPattern->set_matrix (oMatrix);
poContext->set_source_rgb(0.0, 0.0, 0.0);
poContext->paint();
poContext->set_source(poPattern);
poContext->paint();
return true;
}
示例3: do_render
void EmblemCellRenderer::do_render(const Cairo::RefPtr<Cairo::Context>& context, int widget, int background_area, Gdk::Rectangle &cell_area, int flags) {
context->translate(cell_area.get_x(), cell_area.get_y());
context->rectangle(0, 0, cell_area.get_width(), cell_area.get_height());
context->clip();
// TODO: Incorporate padding
context->push_group();
if (!this->_icon_name.empty()) {
Glib::RefPtr<Gdk::Pixbuf> pixbuf = this->_get_pixbuf(this->_icon_name, this->_icon_size);
context->set_operator(Cairo::OPERATOR_SOURCE);
// Assumes square icons; may break if we don't get the requested size
int height_offset = int((cell_area.get_height() - pixbuf->get_height())/2);
Gdk::Cairo::set_source_pixbuf(context, pixbuf, 0, height_offset);
context->rectangle(0, height_offset,
pixbuf->get_width(), pixbuf->get_height());
context->fill();
if (this->_tint_color) {
Gdk::RGBA* c = this->_tint_color;
gushort r = c->get_red();
gushort g = c->get_green();
gushort b = c->get_blue();
// Figure out the difference between our tint colour and an
// empirically determined (i.e., guessed) satisfying luma and
// adjust the base colours accordingly
double luma = (r + r + b + g + g + g) / 6.;
double extra_luma = (1.2 - luma) / 3.;
r = std::min(r + extra_luma, 1.);
g = std::min(g + extra_luma, 1.);
b = std::min(b + extra_luma, 1.);
context->set_source_rgba(r, g, b, 0.4);
context->set_operator(Cairo::OPERATOR_ATOP);
context->paint();
}
if (!this->_emblem_name.empty()) {
Glib::RefPtr<Gdk::Pixbuf> pixbuf = this->_get_pixbuf(this->_emblem_name, this->_emblem_size);
int x_offset = this->_icon_size - this->_emblem_size;
context->set_operator(Cairo::OPERATOR_OVER);
Gdk::Cairo::set_source_pixbuf(context, pixbuf, x_offset, 0);
context->rectangle(x_offset, 0,
cell_area.get_width(), this->_emblem_size);
context->fill();
}
}
context->pop_group_to_source();
context->set_operator(Cairo::OPERATOR_OVER);
context->paint();
}
示例4: init
void CairoPlugin::init()
{
int height, width;
preferredSize(width, height);
m_img = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, width, height);
m_store = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, width, height);
m_ctx = Cairo::Context::create(m_img);
Cairo::RefPtr < Cairo::Context > ctx = Cairo::Context::create(m_store);
ctx->save();
ctx->set_source_rgb(1.0, 1.0, 1.0);
ctx->set_operator(Cairo::OPERATOR_SOURCE);
ctx->paint();
ctx->set_operator(Cairo::OPERATOR_OVER);
ctx->restore();
m_ctx->save();
m_ctx->set_source_rgb(1.0, 1.0, 1.0);
m_ctx->set_operator(Cairo::OPERATOR_SOURCE);
m_ctx->paint();
m_ctx->set_operator(Cairo::OPERATOR_OVER);
m_ctx->restore();
m_init = false;
m_need = true;
}
示例5: ClearCanvas
static void ClearCanvas(Cairo::RefPtr<Cairo::Context>& cr)
{
CairoStateSave save(cr);
cr->set_operator(Cairo::OPERATOR_CLEAR);
cr->paint();
}
示例6: icon
void NodeRenderer::icon(const Cairo::RefPtr<Cairo::Context>& cr, AssetCache& cache)
{
// path to icon not set
if (s->icon_image.str().size() == 0 || s->icon_width == 0.0 || s->icon_height == 0.0)
return;
cr->save();
Cairo::RefPtr<Cairo::ImageSurface> image = cache.getImage(s->icon_image.str());
double width = s->icon_width < 0 ? image->get_width() : s->icon_width;
double height = s->icon_height < 0 ? image->get_height() : s->icon_height;
double x0 = floor(location.x - width/2.0);
double y0 = floor(location.y - height/2.0);
cr->translate(x0, y0);
cr->scale(width / image->get_width(),
height / image->get_height());
cr->set_source(image, 0, 0);
if (s->icon_opacity < 1.0)
cr->paint_with_alpha(s->icon_opacity);
else
cr->paint();
cr->restore();
}
示例7: renderLabels
void renderLabels(const char* path)
{
BOOST_TEST_MESSAGE("Render: " << path);
Cairo::RefPtr<Cairo::Surface> surface = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32,
META_TILE_SIZE * TILE_SIZE, META_TILE_SIZE * TILE_SIZE);
Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(surface);
cr->set_source_rgba(0.0, 0.0, 0.0, 1.0);
cr->save();
cr->set_source_rgba(1.0, 1.0, 1.0, 1.0);
cr->paint();
cr->restore();
std::vector<std::pair<string, FloatPoint>> toPlace;
toPlace.push_back(std::pair<string, FloatPoint>("Karlsruhe", FloatPoint(40, 200)));
toPlace.push_back(std::pair<string, FloatPoint>("Mannheim", FloatPoint(400, 200)));
toPlace.push_back(std::pair<string, FloatPoint>("Stuttgard", FloatPoint(200, 260)));
toPlace.push_back(std::pair<string, FloatPoint>("München", FloatPoint(380, 660)));
toPlace.push_back(std::pair<string, FloatPoint>("Pforzheim", FloatPoint(200, 600)));
toPlace.push_back(std::pair<string, FloatPoint>("Wien", FloatPoint(240, 680)));
toPlace.push_back(std::pair<string, FloatPoint>("Paris", FloatPoint(40, 880)));
toPlace.push_back(std::pair<string, FloatPoint>("Rom", FloatPoint(-40, 880)));
toPlace.push_back(std::pair<string, FloatPoint>("Nothing", FloatPoint(400, 760)));
toPlace.push_back(std::pair<string, FloatPoint>("To See", FloatPoint(720, 880)));
toPlace.push_back(std::pair<string, FloatPoint>("Here", FloatPoint(720, 560)));
toPlace.push_back(std::pair<string, FloatPoint>("Bielefeld", FloatPoint(420, 840)));
renderer->renderLabels(cr, toPlace);
BOOST_TEST_MESSAGE("Writing.");
surface->flush();
surface->write_to_png(path);
}
示例8: on_draw
bool RegionChooser::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
double clipx1, clipx2, clipy1, clipy2;
cr->get_clip_extents(clipx1, clipy1, clipx2, clipy2);
#endif
cr->save();
cr->set_line_width(1);
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2
const Gdk::Color bg = get_style()->get_bg(Gtk::STATE_NORMAL);
#else
const Gdk::RGBA bg = get_style_context()->get_background_color();
#endif
Gdk::Cairo::set_source_rgba(cr, bg);
cr->paint();
if (clipy2 > h1) {
draw_keyboard(cr, clipx1, clipx2);
}
if (clipy1 < h1 && instrument) {
draw_regions(cr, clipx1, clipx2);
}
cr->restore();
return true;
}
示例9: on_draw
bool MyWidget::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
const double scale_x = (double)get_allocation().get_width() / m_scale;
const double scale_y = (double)get_allocation().get_height() / m_scale;
// paint the background
Gdk::Cairo::set_source_rgba(cr, get_style_context()->get_background_color());
cr->paint();
// draw the foreground
Gdk::Cairo::set_source_rgba(cr, get_style_context()->get_color());
cr->move_to(155.*scale_x, 165.*scale_y);
cr->line_to(155.*scale_x, 838.*scale_y);
cr->line_to(265.*scale_x, 900.*scale_y);
cr->line_to(849.*scale_x, 564.*scale_y);
cr->line_to(849.*scale_x, 438.*scale_y);
cr->line_to(265.*scale_x, 100.*scale_y);
cr->line_to(155.*scale_x, 165.*scale_y);
cr->move_to(265.*scale_x, 100.*scale_y);
cr->line_to(265.*scale_x, 652.*scale_y);
cr->line_to(526.*scale_x, 502.*scale_y);
cr->move_to(369.*scale_x, 411.*scale_y);
cr->line_to(633.*scale_x, 564.*scale_y);
cr->move_to(369.*scale_x, 286.*scale_y);
cr->line_to(369.*scale_x, 592.*scale_y);
cr->move_to(369.*scale_x, 286.*scale_y);
cr->line_to(849.*scale_x, 564.*scale_y);
cr->move_to(633.*scale_x, 564.*scale_y);
cr->line_to(155.*scale_x, 838.*scale_y);
cr->stroke();
return true;
}
示例10: draw
void Drawable::draw(const Cairo::RefPtr<Cairo::Context>& context,
ImageBuffer& buff) {
context->save();
// std::cout << getImageName() << std::endl;
auto image = buff.getImage(getImageName(), flipped_, scaleX, scaleY);
// int width = image->get_width();
// int height = image->get_height();
proto::Position pos = getPosition();
int x = c_.scaleWidth(pos.x);
int y = c_.scaleHeight(pos.y);
// Gdk::Cairo::set_source_pixbuf(context, image, pos.x + width / 2,
// pos.y - height / 2);
Gdk::Cairo::set_source_pixbuf(context, image, x, offset_ + y);
context->paint();
// context->set_source_rgb(0.8, 0.0, 0.0);
// context->move_to(pos.x, pos.y);
// context->line_to(pos.x + width / 2, pos.y - height / 2);
// context->line_to(pos.x + width / 2, pos.y + height / 2);
// context->line_to(pos.x - width / 2, pos.y + height / 2);
// context->line_to(pos.x - width / 2, pos.y - height / 2);
// context->line_to(pos.x + width / 2, pos.y - height / 2);
// context->stroke();
context->restore();
}
示例11: drawImageSurface
void FillColorMenuToolButton::drawImageSurface(const Cairo::RefPtr<Cairo::Context> context)
{
Gdk::Cairo::set_source_pixbuf (context, pixbuf_, 3.0, 0.0);
context->paint();
drawColorRectangle (context, 0.5, getImageHeight() - 4.5, getImageWidth() - 0.5, 5 - 0.5);
}
示例12: on_draw
bool MapDrawingArea::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
cr->translate(tran_x, tran_y);
cr->set_source(surface, 0, 0);
cr->paint();
return true;
}
示例13: on_draw
bool on_draw(const Cairo::RefPtr<Cairo::Context>& c) {
Gtk::Allocation allocation = get_allocation();
const int width = allocation.get_width();
const int height = allocation.get_height();
RefPtr<ImageSurface> img = gm.get_surface();
double s = get_scale();
if (s < 1.0)
c->scale(s,s);
c->set_source_rgb(0, 0, 0);
c->paint();
c->set_source(img, 0, 0);
c->paint();
return true;
}
示例14: OnDraw
bool Window::OnDraw(const Cairo::RefPtr<Cairo::Context> & cr)
{
cr->set_source_rgba(0.337, 0.612, 0.117, 0.9);
cr->paint();
return false;
}
示例15:
bool guiRenderer2D::on_expose_event(GdkEventExpose* event) {
Glib::RefPtr<Gdk::Window> window = get_window();
if(window) {
Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
if(event) {
// clip to the area indicated by the expose event so that we only
// redraw the portion of the window that needs to be redrawn
//printf("event->area.x: %d, event->area.y: %d, event->area.width: %d, event->area.height: %d\n", event->area.x, event->area.y, event->area.width, event->area.height );
cr->rectangle(event->area.x, event->area.y, event->area.width, event->area.height);
cr->clip();
}
// Background
// cr->set_source_rgb(0.0, 0.0, 0.0);
cr->set_source_rgb(1.0, 1.0, 1.0);
cr->paint();
if(m_isRendering && m_layoutAvailable) {
Gtk::Allocation allocation = get_allocation();
int width = allocation.get_width();
int height = allocation.get_height();
if(width != m_widgetWidth || height != m_widgetHeight ) { // Allocation changed
rescaleSensorLayout(width, height);
}
drawMatrices(cr, width, height, false);
}
}
return true;
}