[cairo] Cryptic clips

Dirk Schönberger dirk.schoenberger at sz-online.de
Fri Nov 30 08:09:27 PST 2007


> Hi,
>  I'm trying to clip a number of "shapes" beneath a primary "shape". My
> approach so far is this pseudo code:
>
> 1 matrix [set translate, rotate and scale]
> 2 draw clip shape
> 3 save()
> 4 clip()
> 5   matrix [set translate, rotate and scale]
> 6   draw shape 1
> 7   matrix [set translate, rotate and scale]
> 8   draw shape 2
> 9 restore()
>
> So, the idea is that shape 1 gets a transformation, shape 2 gets another
> and
> they both are clipped by  'clip shape' (2).
>
> The thing I can't figure out is how to *not* extend the transformation
> of 'clip shape' (line 1) *over* the two sub-shapes.
>  For example, if 'clip shape' is scaled up twice, I don't want shape1 or
> shape2 to scale along with it.
>
> I tried inserting indentity_matrix() after line 4, but that just
> disappears
> both shapes.
>

I am sure that it is not clean style, and I don't know how to do it in
pycairo (I have not found a API documenttation in a hurry), but you could
play around with
cairo_get_matrix and cairo_set_matrix.

Basically you fetch a snapshot of the current transformation matrix
_befor_ a call to clip, and after you have done your clipping, incl.
transformation, you restorew the original matrix.

Regards
Dirk


More information about the cairo mailing list