[Ipe-discuss] ipeqt::Canvas clipping

Otfried Cheong otfried at ipe.airpost.net
Fri Nov 5 06:19:20 CET 2010


On 11/05/2010 11:48 AM, Dmitriy Morozov wrote:
> Is it possible in C++ to get ipeqt::Canvas to clip itself? I don't
> want it to draw anything outside of its limits (i.e. draw only on the
> white background, not on the gray global background). I can't find
> anything in the documentation, but I hope I'm missing something.

As far as I can tell, you are the first to want to use ipeqt::Canvas 
outside of Ipe.

ipeqt::Canvas does not provide an option to clip the objects to the 
paper.  You could add that easily, though, by inserting something like 
this at the beginning of Canvas::drawObjects(cairo_t *cc) (I haven't 
checked it, but this should work):

   const Layout *l = iCascade->findLayout();
   cairo_rectangle(cc, -l->iOrigin.x, -l->iOrigin.y,
		  l->iPaperSize.x, l->iPaperSize.y);
   cairo_clip(cc)

I would be happy to add this to the Canvas class (with an option to turn 
it on or off, of course) if it fills a need and you are actually reusing 
ipeqt::Canvas in your code.

Cheers,
  Otfried




More information about the Ipe-discuss mailing list