本文整理汇总了C++中cairo::RefPtr::begin_new_sub_path方法的典型用法代码示例。如果您正苦于以下问题:C++ RefPtr::begin_new_sub_path方法的具体用法?C++ RefPtr::begin_new_sub_path怎么用?C++ RefPtr::begin_new_sub_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cairo::RefPtr
的用法示例。
在下文中一共展示了RefPtr::begin_new_sub_path方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawRoundedRectangle
void GraphicalItem::drawRoundedRectangle(
const Cairo::RefPtr<Cairo::Context>& context,
int x, int y,
int width, int height,
double aspect,
double corner_radius,
double red, double green, double blue)
{
double radius = corner_radius / aspect;
double degrees = M_PI / 180.0;
context->begin_new_sub_path();
context->arc(x + width - radius, y + radius, radius,
-90 * degrees, 0 * degrees);
context->arc(x + width - radius, y + height - radius,
radius, 0 * degrees, 90 * degrees);
context->arc(x + radius, y + height - radius, radius,
90 * degrees, 180 * degrees);
context->arc(x + radius, y + radius, radius,
180 * degrees, 270 * degrees);
context->close_path();
context->set_source_rgb(red, green, blue);
context->fill_preserve();
setColor(Settings::settings().getForegroundColor(), context);
context->stroke();
}
示例2: drawRectangle
void GraphicalItem::drawRectangle(const Cairo::RefPtr<Cairo::Context>& context,
int x, int y,
int width, int height,
double red, double green, double blue)
{
context->begin_new_sub_path();
context->move_to(x, y);
context->line_to(x + width, y);
context->line_to(x + width, y + height);
context->line_to(x, y + height);
context->line_to(x, y);
context->close_path();
context->set_source_rgb(red, green, blue);
context->fill_preserve();
setColor(Settings::settings().getForegroundColor(), context);
context->stroke();
}
示例3: 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;
}
}