[cairo] API Shakeup: cairo_begin_group, cairo_end_group, cairo_get_group

mental at rydia.net mental at rydia.net
Wed Feb 16 09:11:41 PST 2005


Quoting Carl Worth <cworth at cworth.org>:

> And users can keep the two halves of the constructor close with:
>
> 	cairo_create_group_begin (cr);
> 	draw_my_group (cr, ...);
> 	group = cairo_create_group_end (cr);
>
> And better languages than C can do this kind of thing quite
> nicely.

class Context
  def create_group
    create_group_begin
    try
      yield
    rescue
      create_group_cancel
      raise
    end
    create_group_end
  end
end

Usage:

 group = cr.create_group {
   draw_my_group(cr, ...)
 }

Having written the above, the existence of a:

 void cairo_create_group_cancel(cairo_t cr);

seems appropriate...

-mental



More information about the cairo mailing list