Re: Help for using cairo_region and clip
Adhir Garg <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <CAAtGbNgLs9DntT2WsuK7=RAVVAkDE=SqCqogF1W3R4iOyyLu8g@mail.gmail.com> |
Hi Carlos On Wed, Oct 10, 2012 at 4:34 PM, Carlos López González <[email protected]> wrote: > Hi Adhir, > > 2012/10/10 Adhir Garg <[email protected]>: >> Hello Carlos, >> >> Thanks for your time for replying. >> >> However, the question still remains unanswered. I am trying to explain >> problem in following steps >> >> 1. Create a big, filled Rectangle 1000x1000 - cairo_rectangle (cr, 0, >> 0, 1000, 1000); >> 2. Create a BIG Rectangle Region 100x100 using >> cairo_region_create_rectangle(cr, rectangle*); >> 3. Exclude a part (region) of it using subtract - >> cairo_region_subtract_rectangle >> Now I assume that my Region consists of reduced size < 100X100 >> 4. I try to create with another shape (say Rectangle) - cairo_rectangle >> 5. If I do cairo_clip(), I only get the rectangle of Step 4 > > Can you be more explicit with this code? Please paste the code that > currently you build and run to check that it doesn't do what you want. > I think that you cannot subtract a cairo_region_t from a path or > viceversa. Cairo regions are for raster surfaces (where those integers > coincide with pixels) but in general a rectangle represents pixels or > not, depending on the surface that the cairo context was initialized. > >> >> My final expected output is intersection of Region at (3) and Clip in (4). >> However, I am unable to find any API that makes use of cairo_region_t. >> > > Possibly you don't need to use cairo_region_t at all, and just work > with paths and clips. yes, I can work with Paths and Clips, and every time, we can query for rectangles, create again a path and then clip it. But if we have a function that would be good. >> Prior to 1.10.0, we had API set_clip_region(), This was responsible >> for setting the current clip region to current region. >> >> In case, we have such API, where we are actually making use of >> cairo_region, it would be great. > > > Does this help? > http://www.gtkforums.com/viewtopic.php?f=3&t=54873 Exactly, this is a roundabout approach for the same issue. We should have the function cairo_bool_t cairo_clip_region (cairo_t *cr, cairo_region_t *region) in Cairo API itself. Thanks a ton Carlos !! >> >> Regards, >> Adhir >> > > Regards, > >> On Wed, Oct 10, 2012 at 3:33 PM, Carlos López González >> <[email protected]> wrote: >>> 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 > > > > -- > Carlos > http://synfig.org -- cairo mailing list [email protected] http://lists.cairographics.org/mailman/listinfo/cairo