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


C++ cairo_push_group函数代码示例

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


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

示例1: draw

static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    cairo_pattern_t *pattern;

    cairo_translate (cr, PAD, PAD);

    /* mask */
    cairo_push_group (cr);
    cairo_set_source_rgba (cr, 0.8, 0.8, 0.8, 0.4);
    cairo_paint (cr);
    cairo_arc (cr, SIZE / 2, SIZE / 2, SIZE / 6, 0., 2. * M_PI);
    cairo_set_source_rgba (cr, 0.4, 0.4, 0.4, 0.8);
    cairo_fill (cr);
    pattern = cairo_pop_group (cr);

    /* source */
    cairo_push_group (cr);
    cairo_rectangle (cr, 0.3 * SIZE, 0.2 * SIZE, 0.5 * SIZE, 0.5 * SIZE);
    cairo_set_source_rgb (cr, 0, 0, 1);
    cairo_fill (cr);
    cairo_move_to     (cr,   0.0,          0.8 * SIZE);
    cairo_rel_line_to (cr,   0.7 * SIZE,   0.0);
    cairo_rel_line_to (cr, -0.375 * SIZE, -0.6 * SIZE);
    cairo_close_path (cr);
    cairo_set_source_rgb (cr, 0, 1, 0);
    cairo_fill (cr);
    cairo_pop_group_to_source (cr);

    cairo_mask (cr, pattern);
    cairo_pattern_destroy (pattern);

    return CAIRO_TEST_SUCCESS;
}
开发者ID:Dirbaio,项目名称:libgdiplus,代码行数:34,代码来源:mask-alpha.c

示例2: draw

static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    /* Neutral gray background */
    cairo_set_source_rgb (cr, 0.51613, 0.55555, 0.51613);
    cairo_paint (cr);

    /* the rest uses CAIRO_OPERATOR_SOURCE so we see better when something goes wrong */
    cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);

    /* add a rectangle */
    cairo_rectangle (cr, CLIP_OFFSET, CLIP_OFFSET, CLIP_SIZE, CLIP_SIZE);

    /* clip to the rectangle */
    cairo_clip_preserve (cr);

    /* push a group. We now have a device offset. */
    cairo_push_group (cr);

    /* push a group again. This is where the bug used to happen. */
    cairo_push_group (cr);

    /* draw something */
    cairo_set_source_rgb (cr, 1, 0, 0);
    cairo_fill_preserve (cr);

    /* make sure the stuff we drew ends up on the output */
    cairo_pop_group_to_source (cr);
    cairo_fill_preserve (cr);

    cairo_pop_group_to_source (cr);
    cairo_fill_preserve (cr);

    return CAIRO_TEST_SUCCESS;
}
开发者ID:AZed,项目名称:cairo,代码行数:35,代码来源:push-group-path-offset.c

示例3: gtk_css_image_cross_fade_draw

static void
gtk_css_image_cross_fade_draw (GtkCssImage        *image,
                               cairo_t            *cr,
                               double              width,
                               double              height)
{
  GtkCssImageCrossFade *cross_fade = GTK_CSS_IMAGE_CROSS_FADE (image);

  if (cross_fade->progress <= 0.0)
    {
      if (cross_fade->start)
        _gtk_css_image_draw (cross_fade->start, cr, width, height);
    }
  else if (cross_fade->progress >= 1.0)
    {
      if (cross_fade->end)
        _gtk_css_image_draw (cross_fade->end, cr, width, height);
    }
  else
    {
      if (cross_fade->start && cross_fade->end)
        {
          /* to reduce the group size */
          cairo_rectangle (cr, 0, 0, ceil (width), ceil (height));
          cairo_clip (cr);

          cairo_push_group (cr);

          /* performance trick */
          cairo_reset_clip (cr);

          _gtk_css_image_draw (cross_fade->start, cr, width, height);

          cairo_push_group (cr);
          _gtk_css_image_draw (cross_fade->end, cr, width, height);
          cairo_pop_group_to_source (cr);

          cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
          cairo_paint_with_alpha (cr, cross_fade->progress);

          cairo_pop_group_to_source (cr);
          cairo_paint (cr);
        }
      else if (cross_fade->start || cross_fade->end)
        {
          cairo_push_group (cr);
          _gtk_css_image_draw (cross_fade->start ? cross_fade->start : cross_fade->end, cr, width, height);
          cairo_pop_group_to_source (cr);

          cairo_paint_with_alpha (cr, cross_fade->start ? 1.0 - cross_fade->progress : cross_fade->progress);
        }
    }
}
开发者ID:3dfxmadscientist,项目名称:gtk,代码行数:53,代码来源:gtkcssimagecrossfade.c

示例4: draw

static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    /* fill with black so we don't need an rgb test case */
    cairo_set_source_rgb (cr, 0, 0, 0);
    cairo_paint (cr);

    /* setting a scale will ensure that the device offset is transformed */
    cairo_scale (cr, 2.1, 2.8);
    cairo_set_source_rgb (cr, 1, .5,.4);

    /* all rectangles should look the same */

    /* plain rectangle */
    cairo_rectangle (cr, 4, 4, 8, 8);
    cairo_fill (cr);

    cairo_translate (cr, 10, 0);

    /* clipped rectangle */
    cairo_save (cr);
    cairo_rectangle (cr, 3, 3, 9, 9);
    cairo_clip (cr);
    cairo_rectangle (cr, 4, 4, 8, 8);
    cairo_fill (cr);
    cairo_restore (cr);

    cairo_translate (cr, 0, 10);

    /* clipped and grouped rectangle */
    cairo_save (cr);
    cairo_rectangle (cr, 3, 3, 9, 9);
    cairo_clip (cr);
    cairo_push_group (cr);
    cairo_rectangle (cr, 4, 4, 8, 8);
    cairo_fill (cr);
    cairo_pop_group_to_source (cr);
    cairo_paint (cr);
    cairo_restore (cr);

    cairo_translate (cr, -10, 0);

    /* grouped rectangle */
    cairo_push_group (cr);
    cairo_rectangle (cr, 4, 4, 8, 8);
    cairo_fill (cr);
    cairo_pop_group_to_source (cr);
    cairo_paint (cr);

    return CAIRO_TEST_SUCCESS;
}
开发者ID:499940913,项目名称:moon,代码行数:51,代码来源:clipped-group.c

示例5: fill_and_stroke

/* Given a path-generating function and two possibly translucent
 * patterns, fill and stroke the path with the patterns (to an
 * offscreen group), then blend the result into the destination.
 */
static void
fill_and_stroke (cairo_t		*cr,
		 path_func_t		 path_func,
		 cairo_pattern_t	*fill_pattern,
		 cairo_pattern_t	*stroke_pattern)
{
    cairo_push_group (cr);
    {
	(path_func) (cr);
	cairo_set_source (cr, fill_pattern);
	cairo_fill_preserve (cr);

	/* Use DEST_OUT to subtract stroke from fill. */
	cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
	cairo_set_operator (cr, CAIRO_OPERATOR_DEST_OUT);
	cairo_stroke_preserve (cr);

	/* Then use ADD to draw the stroke without a seam. */
	cairo_set_source (cr, stroke_pattern);
	cairo_set_operator (cr, CAIRO_OPERATOR_ADD);
	cairo_stroke (cr);
    }
    cairo_pop_group_to_source (cr);
    cairo_paint (cr);
}
开发者ID:AliYousuf,项目名称:cairo,代码行数:29,代码来源:fill-and-stroke-alpha-add.c

示例6: redraw_handler

static void
redraw_handler(struct widget *widget, void *data)
{
	struct editor *editor = data;
	cairo_surface_t *surface;
	struct rectangle allocation;
	cairo_t *cr;

	surface = window_get_surface(editor->window);
	widget_get_allocation(editor->widget, &allocation);

	cr = cairo_create(surface);
	cairo_rectangle(cr, allocation.x, allocation.y, allocation.width, allocation.height);
	cairo_clip(cr);

	cairo_translate(cr, allocation.x, allocation.y);

	/* Draw background */
	cairo_push_group(cr);
	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
	cairo_set_source_rgba(cr, 1, 1, 1, 1);
	cairo_rectangle(cr, 0, 0, allocation.width, allocation.height);
	cairo_fill(cr);

	cairo_pop_group_to_source(cr);
	cairo_paint(cr);

	cairo_destroy(cr);
	cairo_surface_destroy(surface);
}
开发者ID:etrunko,项目名称:weston,代码行数:30,代码来源:editor.c

示例7: draw_clb_pattern

static cairo_pattern_t *
draw_clb_pattern(drawing_context_t *ctx) {
  cairo_t *cr = ctx->cr;
  const double zoom = ctx->zoom;
  cairo_pattern_t *pat;
  unsigned width = SITE_WIDTH*zoom, height = SITE_HEIGHT*zoom;

  cairo_save (cr);

  cairo_set_source_rgb (cr, 0., 0., 0.);
  cairo_rectangle (cr, 0, 0, width, height);
  cairo_clip (cr);
  cairo_scale (cr, zoom, zoom);

  cairo_push_group (cr);

/*   cairo_rectangle (cr, 0, 0, SITE_WIDTH, SITE_HEIGHT); */
/*   cairo_set_source_rgb (cr, 0., 0., 0.); */
/*   cairo_paint (cr); */

  cairo_set_line_width (cr, 1.0);
  cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);

  _draw_clb_pattern (cr);
  pat = cairo_pop_group (cr);

  cairo_restore (cr);

  return pat;
}
开发者ID:Martoni,项目名称:debit,代码行数:30,代码来源:sites_draw.c

示例8: fadable_box_real_draw

static gboolean fadable_box_real_draw (GtkWidget* base, cairo_t* c) {
	FadableBox * self;
	gboolean result = FALSE;
	cairo_t* _tmp0_;
	cairo_t* _tmp1_;
	cairo_t* _tmp2_;
	cairo_t* _tmp3_;
	FadeTracker* _tmp4_;
	FadeTracker* _tmp5_;
	gdouble _tmp6_;
	gdouble _tmp7_;
	self = (FadableBox*) base;
	g_return_val_if_fail (c != NULL, FALSE);
	_tmp0_ = c;
	cairo_push_group (_tmp0_);
	_tmp1_ = c;
	fadable_box_draw_full_alpha (self, _tmp1_);
	_tmp2_ = c;
	cairo_pop_group_to_source (_tmp2_);
	_tmp3_ = c;
	_tmp4_ = fadable_get_fade_tracker ((Fadable*) self);
	_tmp5_ = _tmp4_;
	_tmp6_ = fade_tracker_get_alpha (_tmp5_);
	_tmp7_ = _tmp6_;
	cairo_paint_with_alpha (_tmp3_, _tmp7_);
	result = FALSE;
	return result;
}
开发者ID:wwu-cs-support,项目名称:cswwugreeter,代码行数:28,代码来源:fadable-box.c

示例9: pango_render_text_shadow

void pango_render_text_shadow(cairo_t *context, PangoLayout *layout)
{
	cairo_push_group(context);

	cairo_new_path(context);
	cairo_move_to(context, 15.0+8.0, 10.0+8.0);

	pango_cairo_layout_path(context, layout);

	cairo_set_line_width(context, 6.0);
	cairo_set_miter_limit(context, 2.0);

	cairo_set_source_rgb(context, 0.0, 0.0, 0.0);
	cairo_stroke_preserve(context);

	cairo_fill(context);

	cairo_pop_group_to_source(context);
	cairo_paint_with_alpha(context, 0.6);

	cairo_new_path(context);
	cairo_move_to(context, 15.0, 10.0);

	pango_cairo_layout_path(context, layout);

	cairo_set_line_width(context, 6.0);
	cairo_set_miter_limit(context, 2.0);

	cairo_set_source_rgb(context, 0.0, 0.3, 0.9);
	cairo_stroke_preserve(context);

	cairo_set_source_rgb(context, 0.9, 0.1, 0.8);
	cairo_fill(context);
}
开发者ID:ismaelbej,项目名称:PangoTextEffects,代码行数:34,代码来源:PangoTextEffects.cpp

示例10: redraw_handler

static void
redraw_handler(struct widget *widget, void *data)
{
	struct cliptest *cliptest = data;
	struct geometry *g = cliptest->view.geometry;
	struct rectangle allocation;
	cairo_t *cr;
	cairo_surface_t *surface;
	GLfloat ex[8];
	GLfloat ey[8];
	int n;

	n = calculate_edges(&cliptest->view, &g->clip, &g->surf, ex, ey);

	widget_get_allocation(cliptest->widget, &allocation);

	surface = window_get_surface(cliptest->window);
	cr = cairo_create(surface);
	widget_get_allocation(cliptest->widget, &allocation);
	cairo_rectangle(cr, allocation.x, allocation.y,
			allocation.width, allocation.height);
	cairo_clip(cr);

	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
	cairo_set_source_rgba(cr, 0, 0, 0, 1);
	cairo_paint(cr);

	cairo_translate(cr, allocation.x, allocation.y);
	cairo_set_line_width(cr, 1.0);
	cairo_move_to(cr, allocation.width / 2.0, 0.0);
	cairo_line_to(cr, allocation.width / 2.0, allocation.height);
	cairo_move_to(cr, 0.0, allocation.height / 2.0);
	cairo_line_to(cr, allocation.width, allocation.height / 2.0);
	cairo_set_source_rgba(cr, 0.5, 0.5, 0.5, 1.0);
	cairo_stroke(cr);

	cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
	cairo_push_group(cr);
		cairo_translate(cr, allocation.width / 2.0,
				allocation.height / 2.0);
		cairo_scale(cr, 4.0, 4.0);
		cairo_set_line_width(cr, 0.5);
		cairo_set_line_join(cr, CAIRO_LINE_JOIN_BEVEL);
		cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
				       CAIRO_FONT_WEIGHT_BOLD);
		cairo_set_font_size(cr, 5.0);
		draw_geometry(cr, &cliptest->view, ex, ey, n);
	cairo_pop_group_to_source(cr);
	cairo_paint(cr);

	cairo_set_source_rgba(cr, 0.0, 1.0, 0.0, 1.0);
	cairo_select_font_face(cr, "monospace", CAIRO_FONT_SLANT_NORMAL,
			       CAIRO_FONT_WEIGHT_NORMAL);
	cairo_set_font_size(cr, 12.0);
	draw_coordinates(cr, 10.0, 10.0, ex, ey, n);

	cairo_destroy(cr);

	cairo_surface_destroy(surface);
}
开发者ID:ChristophHaag,项目名称:weston,代码行数:60,代码来源:cliptest.c

示例11: ags_vindicator_draw

void
ags_vindicator_draw(AgsVIndicator *indicator)
{
  GtkWidget *widget;
  GtkAdjustment *adjustment;
  cairo_t *cr;
  gdouble value;
  guint width, height;
  guint segment_width, segment_height;
  guint padding;
  guint i;

  widget = GTK_WIDGET(indicator);
  adjustment = AGS_INDICATOR(indicator)->adjustment;

  //  g_message("draw %f\0", adjustment->value);

  cr = gdk_cairo_create(widget->window);

  if(cr == NULL){
    return;
  }

  width = 16;
  height = 100;

  segment_width = 16;
  segment_height = 7;

  padding = 3;

  cairo_push_group(cr);

  for(i = 0; i < height / (segment_height + padding); i++){
    if(adjustment->value > 0.0 &&
       (1 / adjustment->value * i < (height / (segment_height + padding)))){
      /* active */
      cairo_set_source_rgba(cr, 0.9, 0.7, 0.2, 1.0);
    }else{
      /* normal */
      cairo_set_source_rgba(cr, 0.0, 0.0, 0.4, 1.0);
    }

    cairo_rectangle(cr,
		    0, height - i * (segment_height + padding) - segment_height,
		    segment_width, segment_height);
    cairo_fill(cr);

    cairo_set_source_rgba(cr, 0.0, 0.0, 1.0, 0.3);
    cairo_rectangle(cr,
		    0, height - i * (segment_height + padding) - segment_height,
		    segment_width, segment_height);
    cairo_stroke(cr);
  }

  cairo_pop_group_to_source(cr);
  cairo_paint(cr);

  cairo_destroy(cr);
}
开发者ID:joelkraehemann,项目名称:gsequencer,代码行数:60,代码来源:ags_vindicator.c

示例12: ags_automation_area_expose_event

gboolean
ags_automation_area_expose_event(GtkWidget *widget, GdkEventExpose *event,
				 AgsAutomationArea *automation_area)
{
  AgsAutomationEditor *automation_editor;
  cairo_t *cr;

  g_message("debug: c");
  
  automation_editor = gtk_widget_get_ancestor(automation_area,
					      AGS_TYPE_AUTOMATION_EDITOR);

  cr = gdk_cairo_create(widget->window);
  cairo_push_group(cr);

  ags_automation_area_draw_strip(automation_area,
				 cr);
  ags_automation_area_draw_scale(automation_area,
				 cr);
  ags_automation_area_draw_automation(automation_area,
				      cr);

  cairo_pop_group_to_source(cr);
  cairo_paint(cr);

  return(TRUE);
}
开发者ID:joelkraehemann,项目名称:gsequencer,代码行数:27,代码来源:ags_automation_area_callbacks.c

示例13: ASSERT

void PlatformContextCairo::pushImageMask(cairo_surface_t* surface, const FloatRect& rect)
{
    // We must call savePlatformState at least once before we can use image masking,
    // since we actually apply the mask in restorePlatformState.
    ASSERT(!m_stateStack.isEmpty());
    m_state->m_imageMaskInformation.update(surface, rect);

    // Cairo doesn't support the notion of an image clip, so we push a group here
    // and then paint it to the surface with an image mask (which is an immediate
    // operation) during restorePlatformState.

    // We want to allow the clipped elements to composite with the surface as it
    // is now, but they are isolated in another group. To make this work, we're
    // going to blit the current surface contents onto the new group once we push it.
    cairo_surface_t* currentTarget = cairo_get_target(m_cr.get());
    cairo_surface_flush(currentTarget);

    // Pushing a new group ensures that only things painted after this point are clipped.
    cairo_push_group(m_cr.get());
    cairo_set_operator(m_cr.get(), CAIRO_OPERATOR_SOURCE);

    cairo_set_source_surface(m_cr.get(), currentTarget, 0, 0);
    cairo_rectangle(m_cr.get(), rect.x(), rect.y(), rect.width(), rect.height());
    cairo_fill(m_cr.get());
}
开发者ID:1833183060,项目名称:wke,代码行数:25,代码来源:PlatformContextCairo.cpp

示例14: gd_stack_draw_crossfade

static void
gd_stack_draw_crossfade (GtkWidget *widget,
                         cairo_t *cr)
{
  GdStack *stack = GD_STACK (widget);
  GdStackPrivate *priv = stack->priv;

  if (priv->last_visible_surface)
    {
      cairo_set_source_surface (cr, priv->last_visible_surface,
				priv->last_visible_surface_allocation.x,
				priv->last_visible_surface_allocation.y);
      cairo_set_operator (cr, CAIRO_OPERATOR_ADD);
      cairo_paint_with_alpha (cr, MAX (1.0 - priv->transition_pos, 0));
    }

  cairo_push_group (cr);
  cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
  gtk_container_propagate_draw (GTK_CONTAINER (stack),
                                priv->visible_child->widget,
                                cr);
  cairo_pop_group_to_source (cr);
  cairo_set_operator (cr, CAIRO_OPERATOR_ADD);
  cairo_paint_with_alpha (cr, priv->transition_pos);
}
开发者ID:Udit93,项目名称:gnome-music,代码行数:25,代码来源:gd-stack.c

示例15: cr_push_group

static VALUE
cr_push_group (int argc, VALUE *argv, VALUE self)
{
  VALUE result = Qnil;
  VALUE content, pop_to_source;
  rb_scan_args (argc, argv, "02", &content, &pop_to_source);

  if (NIL_P(content))
    cairo_push_group (_SELF);
  else
    cairo_push_group_with_content (_SELF, RVAL2CRCONTENT(content));
  cr_check_status (_SELF);

  if (rb_block_given_p ())
    {
      int state = 0;

      if (NIL_P (pop_to_source))
        pop_to_source = Qtrue;

      result = rb_protect (rb_yield, self, &state);
      if (cairo_status(_SELF) == CAIRO_STATUS_SUCCESS)
        {
          if (RVAL2CBOOL (pop_to_source))
            cr_pop_group_to_source (self);
          else
            result = cr_pop_group (self);
        }

      if (state)
        rb_jump_tag (state);
    }

  return result;
}
开发者ID:exvayn,项目名称:cairo-1.8.1-i386,代码行数:35,代码来源:rb_cairo_context.c


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