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


C++ cairo_new_sub_path函数代码示例

本文整理汇总了C++中cairo_new_sub_path函数的典型用法代码示例。如果您正苦于以下问题:C++ cairo_new_sub_path函数的具体用法?C++ cairo_new_sub_path怎么用?C++ cairo_new_sub_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: photos_utils_draw_rectangle_handles

void
photos_utils_draw_rectangle_handles (cairo_t *cr,
                                     gdouble x,
                                     gdouble y,
                                     gdouble width,
                                     gdouble height,
                                     gdouble offset,
                                     gdouble radius)
{
  cairo_save (cr);

  cairo_new_sub_path (cr);
  cairo_arc (cr, x - offset, y - offset, radius, 0.0, 2.0 * M_PI);
  cairo_fill (cr);

  cairo_new_sub_path (cr);
  cairo_arc (cr, x + width + offset, y - offset, radius, 0.0, 2.0 * M_PI);
  cairo_fill (cr);

  cairo_new_sub_path (cr);
  cairo_arc (cr, x + width + offset, y + height + offset, radius, 0.0, 2.0 * M_PI);
  cairo_fill (cr);

  cairo_new_sub_path (cr);
  cairo_arc (cr, x - offset, y + height + offset, radius, 0.0, 2.0 * M_PI);
  cairo_fill (cr);

  cairo_restore (cr);
}
开发者ID:uajain,项目名称:gnome-photos,代码行数:29,代码来源:photos-utils.c

示例2: render

void render() {
	draw_fill(ctx, rgba(0,0,0,127));

	int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, window->width);
	cairo_surface_t * surface = cairo_image_surface_create_for_data(ctx->buffer, CAIRO_FORMAT_ARGB32, window->width, window->height, stride);
	cairo_t * cr = cairo_create(surface);

	cairo_set_line_width (cr, 6);

	cairo_rectangle (cr, 12, 12, 232, 70);
	cairo_new_sub_path (cr); cairo_arc (cr, 64, 64, 40, 0, 2*M_PI);
	cairo_new_sub_path (cr); cairo_arc_negative (cr, 192, 64, 40, 0, -2*M_PI);

	cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
	cairo_set_source_rgb (cr, 0, 0.7, 0); cairo_fill_preserve (cr);
	cairo_set_source_rgb (cr, 0, 0, 0); cairo_stroke (cr);

	cairo_translate (cr, 0, 128);
	cairo_rectangle (cr, 12, 12, 232, 70);
	cairo_new_sub_path (cr); cairo_arc (cr, 64, 64, 40, 0, 2*M_PI);
	cairo_new_sub_path (cr); cairo_arc_negative (cr, 192, 64, 40, 0, -2*M_PI);

	cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);
	cairo_set_source_rgb (cr, 0, 0, 0.9); cairo_fill_preserve (cr);
	cairo_set_source_rgb (cr, 0, 0, 0); cairo_stroke (cr);

	cairo_surface_flush(surface);
	cairo_destroy(cr);
	cairo_surface_flush(surface);
	cairo_surface_destroy(surface);
}
开发者ID:Atomication,项目名称:toaruos,代码行数:31,代码来源:cairo-demo.c

示例3: draw

static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    /* We draw in the default black, so paint white first. */
    cairo_save (cr);
    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
    cairo_paint (cr);
    cairo_restore (cr);

    /* subpath starts with cairo_move_to */
    cairo_new_sub_path (cr);
    cairo_move_to (cr, SIZE, SIZE);
    cairo_rel_line_to (cr, SIZE, 0);
    cairo_rel_line_to (cr, 0, SIZE);
    cairo_close_path (cr);
    cairo_rel_line_to (cr, 0.5 * SIZE, SIZE);

    /* subpath starts with cairo_line_to */
    cairo_new_sub_path (cr);
    cairo_line_to (cr, SIZE, 3 * SIZE);
    cairo_rel_line_to (cr, SIZE, 0);
    cairo_rel_line_to (cr, 0, SIZE);
    cairo_close_path (cr);
    cairo_rel_line_to (cr, 0, SIZE);

    /* subpath starts with cairo_curve_to */
    cairo_new_sub_path (cr);
    cairo_curve_to (cr,
		    SIZE, 5 * SIZE,
		    1.5 * SIZE, 6 * SIZE,
		    2 * SIZE, 5 * SIZE);
    cairo_rel_line_to (cr, 0, SIZE);
    cairo_close_path (cr);
    cairo_rel_line_to (cr, -0.5 * SIZE, SIZE);

    /* subpath starts with cairo_arc */
    cairo_new_sub_path (cr);
    cairo_arc (cr,
	       1.5 * SIZE, 7 * SIZE,
	       0.5 * SIZE,
	       M_PI, 2 * M_PI);
    cairo_rel_line_to (cr, 0, SIZE);
    cairo_close_path (cr);
    cairo_rel_line_to (cr, -0.7 * SIZE, 0.7 * SIZE);

    /* subpath starts with cairo_arc_negative */
    cairo_new_sub_path (cr);
    cairo_arc_negative (cr,
			1.5 * SIZE, 9 * SIZE,
			0.5 * SIZE,
			M_PI, 2 * M_PI);
    cairo_rel_line_to (cr, 0, SIZE);
    cairo_close_path (cr);
    cairo_rel_line_to (cr, -0.8 * SIZE, 0.3 * SIZE);

    cairo_stroke (cr);

    return CAIRO_TEST_SUCCESS;
}
开发者ID:AZed,项目名称:cairo,代码行数:59,代码来源:close-path-current-point.c

示例4: draw

static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    const cairo_test_context_t *ctx = cairo_test_get_context (cr);
    cairo_surface_t *image;

    cairo_set_source_rgb (cr, 1, 1, 1);
    cairo_paint (cr);

    image = cairo_test_create_surface_from_png (ctx, png_filename);
    cairo_set_source_surface (cr, image, 0, 0);

    /* simple clip */
    cairo_save (cr);
    cairo_rectangle (cr, 2, 2, 16, 16);
    cairo_clip (cr);
    cairo_paint (cr);
    cairo_restore (cr);

    cairo_translate (cr, WIDTH, 0);

    /* unaligned clip */
    cairo_save (cr);
    cairo_rectangle (cr, 2.5, 2.5, 15, 15);
    cairo_clip (cr);
    cairo_paint (cr);
    cairo_restore (cr);

    cairo_translate (cr, -WIDTH, HEIGHT);

    /* aligned-clip */
    cairo_save (cr);
    cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
    cairo_rectangle (cr, 0, 0, 20, 20);
    cairo_rectangle (cr, 3, 3, 10, 10);
    cairo_rectangle (cr, 7, 7, 10, 10);
    cairo_clip (cr);
    cairo_paint (cr);
    cairo_restore (cr);

    cairo_translate (cr, WIDTH, 0);

    /* force a clip-mask */
    cairo_save (cr);
    cairo_arc (cr, 10, 10, 10, 0, 2 * M_PI);
    cairo_new_sub_path (cr);
    cairo_arc_negative (cr, 10, 10, 5, 2 * M_PI, 0);
    cairo_new_sub_path (cr);
    cairo_arc (cr, 10, 10, 2, 0, 2 * M_PI);
    cairo_clip (cr);
    cairo_paint (cr);
    cairo_restore (cr);

    return CAIRO_TEST_SUCCESS;
}
开发者ID:jaglass,项目名称:WinCairoRequirements,代码行数:55,代码来源:clip-image.c

示例5: draw

static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    const char *cairo = "Cairo";
    cairo_text_extents_t extents;
    double x0, y0;

    cairo_text_extents (cr, cairo, &extents);
    x0 = WIDTH/2. - (extents.width/2. + extents.x_bearing);
    y0 = HEIGHT/2. - (extents.height/2. + extents.y_bearing);

    cairo_set_source_rgb (cr, 1, 1, 1);
    cairo_paint (cr);

    /* aligned-clip */
    cairo_save (cr);
    cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
    cairo_rectangle (cr, 0, 0, 20, 20);
    cairo_rectangle (cr, 3, 3, 10, 10);
    cairo_rectangle (cr, 7, 7, 10, 10);
    cairo_clip (cr);

    cairo_set_source_rgb (cr, 0.7, 0, 0);
    cairo_paint (cr);
    cairo_set_source_rgb (cr, 0, 0, 0);

    cairo_move_to (cr, x0, y0);
    cairo_show_text (cr, cairo);
    cairo_restore (cr);

    cairo_translate (cr, WIDTH, 0);

    /* force a clip-mask */
    cairo_save (cr);
    cairo_arc (cr, 10, 10, 10, 0, 2 * M_PI);
    cairo_new_sub_path (cr);
    cairo_arc_negative (cr, 10, 10, 5, 2 * M_PI, 0);
    cairo_new_sub_path (cr);
    cairo_arc (cr, 10, 10, 2, 0, 2 * M_PI);
    cairo_clip (cr);

    cairo_set_source_rgb (cr, 0, 0, 0.7);
    cairo_paint (cr);
    cairo_set_source_rgb (cr, 0, 0, 0);

    cairo_move_to (cr, x0, y0);
    cairo_show_text (cr, cairo);
    cairo_restore (cr);

    return CAIRO_TEST_SUCCESS;
}
开发者ID:ghub,项目名称:NVprSDK,代码行数:51,代码来源:clip-text.c

示例6: draw

static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    cairo_set_source_rgb (cr, 1, 1, 1);
    cairo_paint (cr);

    cairo_translate (cr, 10, 10);

    /* simple clip */
    cairo_save (cr);
    cairo_rectangle (cr, 0, 0, 20, 20);
    cairo_clip (cr);
    shapes (cr);
    cairo_restore (cr);

    cairo_translate (cr, WIDTH, 0);

    /* unaligned clip */
    cairo_save (cr);
    cairo_rectangle (cr, 0.5, 0.5, 20, 20);
    cairo_clip (cr);
    shapes (cr);
    cairo_restore (cr);

    cairo_translate (cr, -WIDTH, HEIGHT);

    /* aligned-clip */
    cairo_save (cr);
    cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
    cairo_rectangle (cr, 0, 0, 20, 20);
    cairo_rectangle (cr, 3, 3, 10, 10);
    cairo_rectangle (cr, 7, 7, 10, 10);
    cairo_clip (cr);
    shapes (cr);
    cairo_restore (cr);

    cairo_translate (cr, WIDTH, 0);

    /* force a clip-mask */
    cairo_save (cr);
    cairo_arc (cr, 10, 10, 10, 0, 2 * M_PI);
    cairo_new_sub_path (cr);
    cairo_arc_negative (cr, 10, 10, 5, 2 * M_PI, 0);
    cairo_new_sub_path (cr);
    cairo_arc (cr, 10, 10, 2, 0, 2 * M_PI);
    cairo_clip (cr);
    shapes (cr);
    cairo_restore (cr);

    return CAIRO_TEST_SUCCESS;
}
开发者ID:ghub,项目名称:NVprSDK,代码行数:51,代码来源:clip-stroke.c

示例7: pen

static void pen(cairo_t *ctx, cairo_surface_t *buf,
		cairo_surface_t *cbuf, Theme *q) {
	XEvent ev;
	Bool on = False;
	XDefineCursor(dpy, wshow, crosshair_cursor);
	while (!XNextEvent(dpy, &ev)) {
		if (ev.type == KeyPress) { XPutBackEvent(dpy, &ev); break; }
		else if (ev.type == ButtonPress) {
			if (ev.xbutton.button == 1 && (on = !on) ) {
				cairo_new_sub_path(ctx);
				cairo_move_to(ctx, ev.xbutton.x, ev.xbutton.y);
			}
			else if (ev.xbutton.button == 2) { break; }
			else if (ev.xbutton.button == 3) {
				// TODO save changes to slide
				break;
			}
		}
		else if (ev.type == MotionNotify && on) {
			cairo_set_source_surface(ctx, cbuf, 0, 0);
			cairo_paint(ctx);
			cairo_set_source_rgba(ctx, q->R, q->G, q->B, q->A);
			cairo_line_to(ctx, ev.xbutton.x, ev.xbutton.y);
			cairo_stroke_preserve(ctx);
			cairo_set_source_surface(show->target[0].ctx, buf, 0, 0);
			cairo_paint(show->target[0].ctx);
		}
	}
}
开发者ID:thamnos,项目名称:Slider,代码行数:29,代码来源:actions.c

示例8: cr_new_sub_path

static VALUE
cr_new_sub_path (VALUE self)
{
  cairo_new_sub_path (_SELF);
  cr_check_status (_SELF);
  return self;
}
开发者ID:exvayn,项目名称:cairo-1.8.1-i386,代码行数:7,代码来源:rb_cairo_context.c

示例9: platformPath

void Path::addArc(const FloatPoint& p, float r, float startAngle, float endAngle, bool anticlockwise)
{
    // http://bugs.webkit.org/show_bug.cgi?id=16449
    // cairo_arc() functions hang or crash when passed inf as radius or start/end angle
    if (!isfinite(r) || !isfinite(startAngle) || !isfinite(endAngle))
        return;

    cairo_t* cr = platformPath()->context();
    float sweep = endAngle - startAngle;
    const float twoPI = 2 * piFloat;
    if ((sweep <= -twoPI || sweep >= twoPI)
        && ((anticlockwise && (endAngle < startAngle)) || (!anticlockwise && (startAngle < endAngle)))) {
        if (anticlockwise)
            cairo_arc_negative(cr, p.x(), p.y(), r, startAngle, startAngle - twoPI);
        else
            cairo_arc(cr, p.x(), p.y(), r, startAngle, startAngle + twoPI);
        cairo_new_sub_path(cr);
        cairo_arc(cr, p.x(), p.y(), r, endAngle, endAngle);
    } else {
        if (anticlockwise)
            cairo_arc_negative(cr, p.x(), p.y(), r, startAngle, endAngle);
        else
            cairo_arc(cr, p.x(), p.y(), r, startAngle, endAngle);
    }
}
开发者ID:bearmingo,项目名称:UI,代码行数:25,代码来源:PathCairo.cpp

示例10: draw_cairo_round_box

void
draw_cairo_round_box (cairo_t      *cr,
                      GdkRectangle  rect,
                      gint          tl_radius,
                      gint          tr_radius,
                      gint          bl_radius,
                      gint          br_radius)
{
  gdouble right = rect.x + rect.width;
  gdouble bottom = rect.y + rect.height;

  cairo_new_sub_path (cr);
  cairo_move_to (cr, rect.x, rect.y + tl_radius);

  if (tl_radius > 0)
    draw_corner (cr, rect.x, rect.y, tl_radius, CORNER_TOP_LEFT);

  cairo_line_to (cr, right - tr_radius, rect.y);

  if (tr_radius > 0)
    draw_corner (cr, right, rect.y, tr_radius, CORNER_TOP_RIGHT);

  cairo_line_to (cr, right, bottom - br_radius);

  if (br_radius > 0)
    draw_corner (cr, right, bottom, br_radius, CORNER_BOTTOM_RIGHT);

  cairo_line_to (cr, rect.x + bl_radius, bottom);

  if (br_radius > 0)
    draw_corner (cr, rect.x, bottom, bl_radius, CORNER_BOTTOM_LEFT);

  cairo_close_path (cr);
}
开发者ID:GNOME,项目名称:gnome-builder,代码行数:34,代码来源:gstyle-utils.c

示例11: ui_draw_rectangle

void ui_draw_rectangle(double x, double y, double w, double h, double radius, double line_width, int fill, double *rgba)
{
	x += line_width / 2;
	y += line_width / 2;
	w -= line_width;
	h -= line_width;

	cairo_set_line_width(ui->w[ui->cur].c, 0.0);
	if (radius > 0) {
		double deg = 0.017453292519943295; /* 2 x 3.1415927 / 360.0 */

		cairo_new_sub_path(ui->w[ui->cur].c);
		cairo_arc(ui->w[ui->cur].c, x + w - radius, y + radius, radius, -90 * deg, 0 * deg);
		cairo_arc(ui->w[ui->cur].c, x + w - radius, y + h - radius, radius, 0 * deg, 90 * deg);
		cairo_arc(ui->w[ui->cur].c, x + radius, y + h - radius, radius, 90 * deg, 180 * deg);
		cairo_arc(ui->w[ui->cur].c, x + radius, y + radius, radius, 180 * deg, 270 * deg);
		cairo_close_path(ui->w[ui->cur].c);
		cairo_set_source_rgba(ui->w[ui->cur].c, rgba[0], rgba[1], rgba[2], rgba[3]);
		if (fill) {
			cairo_set_line_width(ui->w[ui->cur].c, 0.0);
			cairo_fill_preserve(ui->w[ui->cur].c);
		} else {
			cairo_set_line_width(ui->w[ui->cur].c, line_width);
		}
		cairo_stroke(ui->w[ui->cur].c);
	} else {
		cairo_set_source_rgba(ui->w[ui->cur].c, rgba[0], rgba[1], rgba[2], rgba[3]);
		cairo_set_line_width(ui->w[ui->cur].c, line_width);
		cairo_rectangle(ui->w[ui->cur].c, x, y, w, h);
		if (fill)
			cairo_fill(ui->w[ui->cur].c);	/* FIXME Should line width be 0 here? */
		else
			cairo_stroke(ui->w[ui->cur].c);
	}
}
开发者ID:johanmalm,项目名称:jgmenu,代码行数:35,代码来源:x11-ui.c

示例12: _gtk_rounded_box_path

void
_gtk_rounded_box_path (const GtkRoundedBox *box,
                       cairo_t             *cr)
{
  cairo_new_sub_path (cr);

  _cairo_ellipsis (cr,
                   box->box.x + box->corner[GTK_CSS_TOP_LEFT].horizontal,
                   box->box.y + box->corner[GTK_CSS_TOP_LEFT].vertical,
                   box->corner[GTK_CSS_TOP_LEFT].horizontal,
                   box->corner[GTK_CSS_TOP_LEFT].vertical,
                   G_PI, 3 * G_PI_2);
  _cairo_ellipsis (cr, 
                   box->box.x + box->box.width - box->corner[GTK_CSS_TOP_RIGHT].horizontal,
                   box->box.y + box->corner[GTK_CSS_TOP_RIGHT].vertical,
                   box->corner[GTK_CSS_TOP_RIGHT].horizontal,
                   box->corner[GTK_CSS_TOP_RIGHT].vertical,
                   - G_PI_2, 0);
  _cairo_ellipsis (cr,
                   box->box.x + box->box.width - box->corner[GTK_CSS_BOTTOM_RIGHT].horizontal,
                   box->box.y + box->box.height - box->corner[GTK_CSS_BOTTOM_RIGHT].vertical,
                   box->corner[GTK_CSS_BOTTOM_RIGHT].horizontal,
                   box->corner[GTK_CSS_BOTTOM_RIGHT].vertical,
                   0, G_PI_2);
  _cairo_ellipsis (cr,
                   box->box.x + box->corner[GTK_CSS_BOTTOM_LEFT].horizontal,
                   box->box.y + box->box.height - box->corner[GTK_CSS_BOTTOM_LEFT].vertical,
                   box->corner[GTK_CSS_BOTTOM_LEFT].horizontal,
                   box->corner[GTK_CSS_BOTTOM_LEFT].vertical,
                   G_PI_2, G_PI);

  cairo_close_path (cr);
}
开发者ID:Therzok,项目名称:gtk,代码行数:33,代码来源:gtkroundedbox.c

示例13: krad_vector_render_rrect

static void krad_vector_render_rrect(cairo_t *cr, int x, int y, int w,
 int h, float r, float g, float b, float op) {

  double aspect;
  double corner_radius;
  double radius;
  double degrees;

  if (w > h) {
    aspect = w/h;
  } else {
    aspect = h/w;
  }
  corner_radius = h / 15.0;
  radius = corner_radius / aspect;
  degrees = M_PI / 180.0;

  cairo_new_sub_path(cr);
  cairo_arc(cr, x + w - radius, y + radius, radius, -90 * degrees, 0);
  cairo_arc(cr, x + w - radius, y + h - radius, radius, 0, 90 * degrees);
  cairo_arc(cr, x + radius, y + h - radius, radius, 90 * degrees,
   180 * degrees);
  cairo_arc(cr, x + radius, y + radius, radius, 180 * degrees, 270 * degrees);
  cairo_close_path(cr);
  cairo_set_source_rgba(cr, r, g, b, op);
  cairo_fill_preserve(cr);
  cairo_set_source_rgba(cr, r, g, b, op);
  cairo_set_line_width(cr, 5.0);
  cairo_stroke(cr);

  return;
}
开发者ID:kripton,项目名称:krad_radio-1,代码行数:32,代码来源:cairo_sandbox.c

示例14: paint_marker

static void
paint_marker(cairo_t *cr, int x, int y)
{
	enum igt_text_align align;
	int xoff, yoff;

	cairo_move_to(cr, x, y - 20);
	cairo_line_to(cr, x, y + 20);
	cairo_move_to(cr, x - 20, y);
	cairo_line_to(cr, x + 20, y);
	cairo_new_sub_path(cr);
	cairo_arc(cr, x, y, 10, 0, M_PI * 2);
	cairo_set_line_width(cr, 4);
	cairo_set_source_rgb(cr, 0, 0, 0);
	cairo_stroke_preserve(cr);
	cairo_set_source_rgb(cr, 1, 1, 1);
	cairo_set_line_width(cr, 2);
	cairo_stroke(cr);

	xoff = x ? -20 : 20;
	align = x ? align_right : align_left;

	yoff = y ? -20 : 20;
	align |= y ? align_bottom : align_top;

	cairo_move_to(cr, x + xoff, y + yoff);
	cairo_set_font_size(cr, 18);
	igt_cairo_printf_line(cr, align, 0, "(%d, %d)", x, y);
}
开发者ID:mv0,项目名称:intel-gpu-tools,代码行数:29,代码来源:igt_fb.c

示例15: cairo_new_sub_path_l

static int cairo_new_sub_path_l( lua_State* L )
{
  lua_cairo_t* lc = lua_cairo_check( L, 1 );

  cairo_new_sub_path( lc->cairo );

  return( 0 );
}
开发者ID:matthewburk,项目名称:cel-reactor,代码行数:8,代码来源:cairo_L.c


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