[Mono-list] Clipping with Cairo

Jonathan Pobst monkey at jpobst.com
Wed Nov 17 10:56:41 EST 2010


Draw your clipping rectangle path, call Clip, then set up and stroke 
your line:

cc = Gdk.CairoHelper.Create (drawingarea1.GdkWindow);
cc.Rectangle (50,50,80,80);
cc.Clip ();

cc.Color = new Cairo.Color (0,0,0);
cc.MoveTo (10,10);
cc.LineTo (100, 100);
cc.Stroke();

Jonathan


On 11/17/2010 9:45 AM, Francisco M. Marzoa wrote:
> Hello again,
>
> I want to draw something in a Cairo surface but when Stroking, just
> paint the things that are within a given rectangle.
>
> I think I understand the theory: draw things into the source, then
> create a rectangle for clipping into the mask, and finally stroke it to
> the destination.
>
> The problem is that I do not know how to draw within the path, so I
> cannot create that rectangle before stroking.
>
> For example:
>
>          cc = Gdk.CairoHelper.Create (drawingarea1.GdkWindow);
>          cc.Color = new Cairo.Color (0,0,0);
>          cc.MoveTo (10,10);
>          cc.LineTo (100, 100);
>          cc.Rectangle (50,50,80,80);
>          cc.Stroke();
>
> In this code the Rectangle which I want to use to cut the line, is drawn
> also on source surface, not on mask as path. The concrete question is
> then, how I can draw that rectangle as a path to clip the line?
>
> Thanks a lot in advance,
>
>
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
>



More information about the Mono-list mailing list