[cairo] Cut cairo_t out of a cairo_t

Andrea Canciani ranma42 at gmail.com
Tue Jun 7 23:27:07 PDT 2011


On Tue, Jun 7, 2011 at 10:58 PM, Robert Uhl <ruhl at xaipete.org> wrote:
> Hi,
>
> is it possible to cut a cairo_t B out of another cairo_t A?
> For example, I plot something to cairo_t A and then give this cairo_t A to
> another plotting routine, which should only be able to plot to a cut-out of
> this cairo_t A.
> I can call the routine with x and y coordinates, a width and a height of the
> allowed area to plot to, but I want to ensure that the routine is only able
> to plot to the cut-out. So it would be more secure to give only a cut-out of
> cairo_t A to the routine, not the entire cairo_t A.
>
> Is there any function in Cairo which cuts an area out of a cairo_t A and
> returns this area as a cairo_t B?

Usually this is performed using cairo_clip and/or cairo_push (if you consider
the routine "trusted", i.e. it won't do anything that might put cairo_t B in an
error status).

If you want to guarantee that the routine won't be able to escape the
boundaries you chose nor put B in an invalid status, you can use
cairo_surface_create_for_rectangle() and create a cairo_t on that
or cairo_push() and create a new cairo_t on the surface returned by
cairo_get_group_target ().

Andrea

>
> Kind regards,
> Robert
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
>


More information about the cairo mailing list