当前位置: 首页>>代码示例>>C++>>正文


C++ RefPtr::set_operator方法代码示例

本文整理汇总了C++中cairo::RefPtr::set_operator方法的典型用法代码示例。如果您正苦于以下问题:C++ RefPtr::set_operator方法的具体用法?C++ RefPtr::set_operator怎么用?C++ RefPtr::set_operator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cairo::RefPtr的用法示例。


在下文中一共展示了RefPtr::set_operator方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:alsabadel,项目名称:vle,代码行数:29,代码来源:CairoPlugin.cpp

示例2: 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();
}
开发者ID:egore,项目名称:meld,代码行数:50,代码来源:emblemcellrenderer.cpp

示例3: ClearCanvas

static void ClearCanvas(Cairo::RefPtr<Cairo::Context>& cr)
{
    CairoStateSave save(cr);

    cr->set_operator(Cairo::OPERATOR_CLEAR);
    cr->paint();
}
开发者ID:cargabsj175,项目名称:bombono-dvd,代码行数:7,代码来源:test_text.cpp

示例4: clear

	void clear()
	{
		cr->save();

		cr->set_operator(Cairo::OPERATOR_CLEAR);
		cr->set_source_rgba(1.0, 1.0, 1.0, 1.0);
		cr->paint();

		cr->restore();
	}
开发者ID:jorik041,项目名称:alacarte,代码行数:10,代码来源:renderer.cpp

示例5: redraw

/**
 * Makes the window draw itself.
 */
void Window::redraw()
{
	LOG(kLogDebug, "Redrawing window %p", this);
	needsRedraw = false;
	Cairo::RefPtr<Cairo::Context> context = Cairo::Context::create(store);

	context->save();
	context->set_operator(Cairo::OPERATOR_CLEAR);
	context->paint();
	context->restore();

	draw(context);
	loadTexture();
}
开发者ID:fabianschuiki,项目名称:Settlement,代码行数:17,代码来源:Window.cpp

示例6: window_expose_event

bool Liveplay::window_expose_event(GdkEventExpose *event) {
    Cairo::RefPtr<Cairo::Context> cr = Glib::wrap(event->window, true)->create_cairo_context();
    Gtk::Allocation a = liveplay_canvas->get_allocation();
    Gdk::Region region(a);
    region.intersect(Glib::wrap(event->region, true));
    Gdk::Cairo::add_region_to_path(cr, region);
    cr->clip();
    cr->set_operator(Cairo::OPERATOR_SOURCE);
    cr->set_source_rgb(0,0,0);
    cr->paint();
    //gdk_cairo_set_source_window(cr->cobj(), liveplay_canvas->get_window()->gobj(), a.get_x(), a.get_y()); gtk 2.24
    gdk_cairo_set_source_pixmap(cr->cobj(), liveplay_canvas->get_window()->gobj(), a.get_x(), a.get_y());
    cr->paint_with_alpha(pow(brightness_adj->get_value(),2.2));
    return false;
}
开发者ID:unclechu,项目名称:guitarix,代码行数:15,代码来源:liveplay.cpp

示例7: on_draw

bool TransparentSlider::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
    auto window = get_window();

    Cairo::RectangleInt window_size;
    Cairo::RectangleInt clip;
    double x1, y1, x2, y2;
    cr->get_clip_extents(x1, y1, x2, y2);

    clip.height = _round(y2-y1);
    clip.width = _round(x2-x1);
    clip.x = _round(x1);
    clip.y = _round(y1);

    window_size.x = 0;
    window_size.y = 0;
    window_size.height = window->get_height();
    window_size.width = window->get_width();

    cr->save();

    if (_SUPPORTS_ALPHA) {
        cr->set_source_rgba(                    // transparent
                _adjustmentRed->get_value(),
                _adjustmentGreen->get_value(),
                _adjustmentBlue->get_value(),
                _adjustmentAlpha->get_value());
    } else {
        cr->set_source_rgb(                     // opaque
                _adjustmentRed->get_value(),
                _adjustmentGreen->get_value(),
                _adjustmentBlue->get_value());
    }
    cr->set_operator(Cairo::OPERATOR_SOURCE);

    if (clip.height==window_size.height && clip.width==window_size.width && clip.x==window_size.x && clip.y==window_size.y) {
    } else {
        window->invalidate(true);
    }
    cr->reset_clip();
    cr->paint();
    cr->restore();

    return Gtk::Window::on_draw(cr);
}
开发者ID:AthanasiusOfAlex,项目名称:gtk-examples,代码行数:45,代码来源:transparent-slider.cpp

示例8: DrawSingleHistogramLine

void HistogramDrawingArea::DrawSingleHistogramLine( 
    Cairo::RefPtr<Cairo::Context> refCairo,
    ImageStatistics::StatisticsChannel channel )
{       
    unsigned int rangeMin, rangeMax, pixelValueMin, pixelValueMax;
    unsigned int numPixelValues;
    float pixelValueMean;
    int* pHistogram;

    m_histogramStats.GetStatistics( 
        channel,
        &rangeMin,
        &rangeMax,
        &pixelValueMin,
        &pixelValueMax,
        &numPixelValues,
        &pixelValueMean,
        &pHistogram );    
           
    std::vector<float> percentages = GetPercentages( numPixelValues, pHistogram );

    refCairo->save();

    // Reserve the outside 10%
    float paddedLeft, paddedTop, paddedWidth, paddedHeight;
    GetPaddedSize( paddedLeft, paddedTop, paddedWidth, paddedHeight ); 

    const float xScale = static_cast<float>(paddedWidth / numPixelValues);
    const float yScale = paddedHeight / static_cast<float>(m_maxVal);

    // Set draw color
    double red, green, blue;
    GetLineColor( channel, red, green, blue );
    refCairo->set_source_rgb(red, green, blue);

    // Set line width
    refCairo->set_line_width(1.0);

    if ( numPixelValues > 256 )
    {        
        const int k_pixelsToAvg = static_cast<int>(numPixelValues / paddedWidth);

        for ( unsigned int i=0; i < numPixelValues; i += k_pixelsToAvg )
        {
            float maxVal = 0.0;
            for ( int j=0; j < k_pixelsToAvg; j++ )
            {
                if ( i+j >= numPixelValues )
                {
                    break;
                }

                if ( percentages[i+j] > maxVal )
                {
                    maxVal = percentages[i+j];
                }
            }

            // Calculate the scaled height of the current percentage
            float yScaledHeight = yScale * maxVal;

            if ( i == 0 )
            {
                refCairo->move_to( paddedLeft, (paddedTop + paddedHeight - yScaledHeight) );
            }

            refCairo->line_to( paddedLeft + (xScale * i), paddedTop + paddedHeight - yScaledHeight );    
        }
    }
    else
    {
        for ( unsigned int i=0; i < numPixelValues; i++ )
        {
            // Calculate the scaled height of the current percentage
            float yScaledHeight = yScale * percentages[i];

            if ( i == 0 )
            {
                refCairo->move_to( paddedLeft, (paddedTop + paddedHeight - yScaledHeight) );
            }

            refCairo->line_to( paddedLeft + (xScale * i), paddedTop + paddedHeight - yScaledHeight );    
        }
    }    
   
    refCairo->stroke();

    // Overwrite anything that appears on the paddedTop section
    refCairo->rectangle(
        paddedLeft, 
        0,
        paddedWidth, 
        paddedTop );

    refCairo->set_source_rgb( 255, 255, 255 );

    refCairo->set_operator( Cairo::OPERATOR_OVER );

    refCairo->fill();    

//.........这里部分代码省略.........
开发者ID:Vaa3D,项目名称:vaa3d_tools,代码行数:101,代码来源:HistogramDrawingArea.cpp

示例9: drawImage

void ImageDrawable::drawImage(const Cairo::RefPtr<Cairo::Context> &cr, const Gtk::Allocation &allocation) {
	auto image = images->current();
	auto surface = image->getPrimary();
	int rwidth, rheight;
	double rscale;
	double rx, ry;

	//cout << "image " << iwidth << "x" << iheight << " " << iorientation.first << "," << iorientation.second << endl;

	calcRenderedImage(image, allocation, rwidth, rheight, rscale, rx, ry);

	cr->translate(rx, ry);
	cr->scale(rscale, rscale);

	waiting = !surface;

	if (image->isPrimaryFailed()) {
		// TODO display fancy failed indicator
		cr->set_source_rgb(0.75, 0.5, 0.5);
		cr->rectangle(0, 0, rwidth, rheight);
		cr->clip();
		cr->paint();
		return;
	} else if (!surface) {
		// TODO display fancy loading animation
		cr->set_source_rgb(0.5, 0.75, 0.5);
		cr->rectangle(0, 0, rwidth, rheight);
		cr->clip();
		cr->paint();
		return;
	}

	switch (image->getOrientation().first) {
	case Image::Rotate::ROTATE_NONE:
		break;

	case Image::Rotate::ROTATE_90:
		cr->translate(image->height(), 0);
		cr->rotate_degrees(90);
		break;

	case Image::Rotate::ROTATE_180:
		cr->translate(image->width(), image->height());
		cr->rotate_degrees(180);
		break;

	case Image::Rotate::ROTATE_270:
		cr->translate(0, image->width());
		cr->rotate_degrees(270);
		break;
	}

	if (image->getOrientation().second) {
		cr->translate(image->width(), 0);
		cr->scale(-1, 1);
	}

	auto pattern = Cairo::SurfacePattern::create(surface);
	pattern->set_filter(Cairo::Filter::FILTER_FAST);
	cr->set_source(pattern);

	//auto start = chrono::steady_clock::now();
	cr->paint();
	//auto stop = chrono::steady_clock::now();
	//cout << "paint " << chrono::duration_cast<chrono::milliseconds>(stop - start).count() << "ms" << endl;

	if (afPoints) {
		//start = chrono::steady_clock::now();
		auto properties = image->getProperties();
		valarray<double> dashes(5.0 / rscale, 5.0 / rscale);

		cr->save();
		cr->set_operator(static_cast<Cairo::Operator>(CAIRO_OPERATOR_DIFFERENCE));

		for (auto &rect : properties.focusPoints) {
			if (properties.focusPointsActive.find(rect) != properties.focusPointsActive.cend()) {
				cr->set_source_rgb(1, 0, 1);
				cr->set_line_width(4.0 / rscale);
				cr->unset_dash();
			} else if (properties.focusPointsSelected.find(rect) != properties.focusPointsSelected.cend()) {
				cr->set_source_rgb(1, 0, 0);
				cr->set_line_width(2.0 / rscale);
				cr->unset_dash();
			} else {
				cr->set_source_rgb(1, 1, 1);
				cr->set_line_width(1.0 / rscale);
				cr->set_dash(dashes, 0);
			}
			cr->rectangle(rect.x, rect.y, rect.width, rect.height);
			cr->stroke();
		}

		cr->restore();

		//stop = chrono::steady_clock::now();
		//cout << "afpaint " << chrono::duration_cast<chrono::milliseconds>(stop - start).count() << "ms" << endl;
	}
}
开发者ID:lp0,项目名称:fiv,代码行数:98,代码来源:ImageDrawable.cpp


注:本文中的cairo::RefPtr::set_operator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。