Re: Help for using cairo_region and clip
Carlos López González <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <CAF52pz+y7k6rTPDcwWM6p3YjyZe+r-=7qiP6KeUhcf2+2PmtMg@mail.gmail.com> |
Hi Adhir, According to the manual: "Regions are a simple graphical data type representing an area of integer-aligned rectangles. They are often used on raster surfaces to track areas of interest, such as change or clip areas." Also: "cairo_clip () void cairo_clip (cairo_t *cr); Establishes a new clip region by intersecting the current clip region with the current path as it would be filled by cairo_fill() and according to the current fill rule (see cairo_set_fill_rule())." Do not confuse the "region" word from the cairo_clip description with the cairo_region_t type. They are pretty different. The first is like a path and the second is a pixel aligned rectangle. In general paths can be of any kind (arcs, strokes, rectangles). So if you want to clip your path with a rectangle, just use a rectangle path as clipping path /* prepare your context and surface here*/ cairo_rectangle(cr, x, y, width, height); /* add more paths here to the clip*/ cairo_clip(cr); /*your stroke painting stuff here*/ cairo_move_to, cairo_line_to, etc. See: http://cairographics.org/samples/clip/ I hope it helped. Carlos 2012/10/10 Adhir Garg <[email protected]> > > Hello, > > I am pretty new to Cairo and have a query regarding use of > cairo_region_t and clip. > > What I need is > 1. Create a region - created using cairo_region_create_rectangle > 2. Create a Path and clip it with region - Here if I use cairo_clip(), > then the region is not taken into consideration. > > Somehow, I couldn't locate correct API for intersection of region with clip. > On extended platforms I could get set_clip_region, but could not find > the same in Cairo listed APIs. > > Thanks in advance for your help. > > Regards, > Adhir > -- > cairo mailing list > [email protected] > http://lists.cairographics.org/mailman/listinfo/cairo -- Carlos http://synfig.org -- cairo mailing list [email protected] http://lists.cairographics.org/mailman/listinfo/cairo