[cairo] clear operator

Andrea Canciani ranma42 at gmail.com
Thu Jun 2 16:24:49 PDT 2011


On Thu, Jun 2, 2011 at 11:33 PM, control H <control.h at gmail.com> wrote:
>> In the example, the CLEAR operator is used when filling the "blue rectangle"
>> with an opaque blue solid color.
>> You are using paint(), so you're doing the same operation as that
>> example, but with a rectangle that covers the whole surface.
>
> That's CLEAR :) Thanks for explaining.
> Part of my confusion though was because I presumed transparent
> background does not do anything, since on the website it was phrased:
>
> Where the second object is drawn, the first is completely removed.
>
> In my interpretation that means that whenever a pixel is transparent,
> it will not be drawn on the second object and therefore not removed.

This interpretation is exact if applied to the mask (which is the whole
surface when using the paint operation), not to the source pattern.

Something like:

cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
cairo_set_source(cr, pattern); /* ignored */
cairo_rectangle(cr, 0,0, 100, 100);
cairo_fill(cr);

would clear the rectangle (no matter what the current source is).

This sequence:
cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
cairo_set_source(cr, pattern); /* ignored */
cairo_rectangle(cr, 0,0, 100, 100); /* ignored */
cairo_paint(cr);

would clear the whole surface..

(Please notice that setting the source is useless whenever the operator
is CLEAR, defining a path is useless if you're using paint).

> Perhaps this might confuse other people as well and the documentation
> can make a remark about it.

The docs are in a wiki, so if you can provide a better wording
or an explanation without these ambiguities, please fix it.

>
> Anyway, thanks for your answers Andrea.
> regards.
>


More information about the cairo mailing list