本文整理汇总了C++中cairo::RefPtr::begin_new_path方法的典型用法代码示例。如果您正苦于以下问题:C++ RefPtr::begin_new_path方法的具体用法?C++ RefPtr::begin_new_path怎么用?C++ RefPtr::begin_new_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cairo::RefPtr
的用法示例。
在下文中一共展示了RefPtr::begin_new_path方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw_bar
// ----------------------------------------------------------------------------
// -- Function : draw_bar(cr)
// --
// -- Takes : cr = point to a cairo reference
// --
// -- Purpose : Assumes value is already between 1 and 0! Draws the bar
// on the provided cairo reference.
void BarWidget::draw_bar(Cairo::RefPtr<Cairo::Context> cr)
{
// Get our bar coords
Size size = get_avail_rect();
Size* s = &size;
// Draw the bg first
cr->set_line_width(bar_bg_border_width);
cr->rectangle(s->x, s->y, s->width, s->height);
// -- bg border
if (draw_bar_bg_border)
{
bar_bg_border_color->set_source(cr);
cr->stroke_preserve();
}
// -- bg
if (draw_bar_bg)
{
bar_bg_color->set_source(cr);
cr->fill_preserve();
}
// Clear the path
cr->begin_new_path();
// -- Now we're drawing the value bar
// Modify the size by our value / percent
// If we're horz, modify the width.
// If we're vert, modify the height.
if (vertical)
s->height = s->height * m_value;
else
s->width = s->width * m_value;
// New path, draw!
cr->set_line_width(bar_border_width);
cr->rectangle(s->x, s->y, s->width, s->height);
// -- bar border
if (draw_bar_border)
{
bar_border_color->set_source(cr);
cr->stroke_preserve();
}
// -- Draw the bar
bar_color->set_source(cr);
cr->fill();
// clean up
cr->begin_new_path();
s = nullptr;
}
示例2: rasterpolys
bool rasterpolys(const vector<Poly> &polys,
const Vector2d &min, const Vector2d &max, double resolution,
Cairo::RefPtr<Cairo::ImageSurface> &surface,
Cairo::RefPtr<Cairo::Context> &context)
{
Vector2d diag = max - min;
int width = (int)ceil(diag.x()/resolution);
int height = (int)ceil(diag.y()/resolution);
if (height <= 0 || width <= 0)
return false;
surface = Cairo::ImageSurface::create(Cairo::FORMAT_A8, width, height);
//surface->set_device_offset(-min.x()/resolution, -min.y()/resolution);
context = Cairo::Context::create (surface);
context->set_fill_rule(Cairo::FILL_RULE_WINDING);
context->set_antialias(Cairo::ANTIALIAS_DEFAULT);
context->scale(1/resolution, 1/resolution);
context->translate(-min.x(), -min.y());
context->set_source_rgb (0,0,0);
//cerr << min << endl <<getMatrix(context) << endl;
// draw boundary
// context->begin_new_path();
// context->set_line_width(0.5);
// context->move_to(min.x(),min.y());
// context->line_to(max.x(),min.y());
// context->line_to(max.x(),max.y());
// context->line_to(min.x(),max.y());
// // context->move_to(0,0);
// // context->line_to(diag.x(),0);
// // context->line_to(diag.x(),diag.y());
// // context->line_to(0,diag.y());
// context->close_path();
// context->stroke();
context->begin_new_path();
context->set_line_width(0);
for (uint i=0; i<polys.size(); i++) {
Vector2d v = polys[i][0];
context->move_to(v.x(),v.y());
for (uint j=0; j<polys[i].size(); j++) {
Vector2d v = polys[i][j];
context->line_to(v.x(),v.y());
}
}
context->fill();
return true;
}
示例3: drawControlLine
void CurveEditPart::drawControlLine(Cairo::RefPtr<Cairo::Context> context, const Point& start_point, const Point& end_point)
{
context->begin_new_path();
context->move_to (start_point.getX(), start_point.getY());
context->line_to (end_point.getX(), end_point.getY());
context->set_source_rgba (1, 0, 0, 0.5);
std::vector< double > dashes(2);
dashes[0] = 2.0;
dashes[1] = 2.0;
context->set_dash (dashes, 0.0);
context->set_line_width (1.0);
context->stroke();
}
示例4:
void
FourdThumbnailer::receive_frame(Cairo::RefPtr<Cairo::ImageSurface> img, gint64 pos)
{
if (!m_buffer)
{
m_buffer = Cairo::ImageSurface::create(Cairo::FORMAT_RGB24,
img->get_width() * 10,
img->get_height());
}
Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(m_buffer);
int slice_width = m_buffer->get_width() / m_slices;
cr->rectangle((slice_width * m_count), 0,
slice_width, m_buffer->get_height());
cr->clip();
cr->begin_new_path();
cr->set_source(img, m_count * (m_buffer->get_width() - img->get_width()) / (m_slices-1), 0);
cr->paint();
m_count += 1;
}
示例5: on_expose_event
bool CPagePreview::on_expose_event(GdkEventExpose *event)
{
std::cout << "Fired!\n";
Glib::RefPtr<Gdk::Window> window = get_window();
if(window)
{
// get the cairo context amd allocation
Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
Gtk::Allocation allocation = get_allocation();
const int width = allocation.get_width();
const int height = allocation.get_height();
// coordinates for the center of the window
int xc, yc;
xc = width / 2;
yc = height / 2;
// clip to the area indicated by the expose event so that we only redraw
// the portion of the window that needs to be redrawn
cr->rectangle(event->area.x, event->area.y,
event->area.width, event->area.height);
cr->clip();
double border = 0.05;
double offset = 2.0;
// draw a neat shadow
cr->set_source_rgba(0.0,0.0,0.0,0.4);
cr->begin_new_path();
cr->move_to( width*border+offset,height*border+offset );
cr->line_to( width*(1.0-border)+offset,height*border+offset );
cr->line_to( width*(1.0-border)+offset,height*(1.0-border)+offset );
cr->line_to( width*border+offset,height*(1.0-border)+offset );
cr->close_path();
cr->fill();
// draw the page outline
cr->set_source_rgb(0.0,0.0,0.0); // black
cr->set_line_width( 1.0 );
cr->begin_new_sub_path();
cr->move_to( width*border-offset,height*border-offset );
cr->line_to( width*(1.0-border)-offset,height*border-offset );
cr->line_to( width*(1.0-border)-offset,height*(1.0-border)-offset );
cr->line_to( width*border-offset,height*(1.0-border)-offset );
cr->close_path();
cr->stroke_preserve();
// fill the page with white
cr->save();
cr->set_source_rgb(1.0,1.0,1.0); // white
cr->fill_preserve();
cr->restore();
// and the image preview
ImagePixbuf->render_to_drawable( get_window(),
get_style()->get_black_gc(),
0,
0,
(width-ImagePixbuf->get_width())/2,
(height-ImagePixbuf->get_height())/2,
ImagePixbuf->get_width(), //image->get_width(),
ImagePixbuf->get_height(), //image->get_height(),
Gdk::RGB_DITHER_NONE,0,0 ); // */
return true;
}
}