Context.pushGroup - multiple declarations

Function Context.pushGroup

Temporarily redirects drawing to an intermediate surface known as a group. The redirection lasts until the group is completed by a call to Context.popGroup() or Context.popGroupToSource(). These calls provide the result of any drawing to the group as a pattern, (either as an explicit object, or set as the source pattern).

The group will have a content type of content. The ability to control this content type is the only distinction between this function and Context.pushGroup() which you should see for a more detailed description of group rendering.

Prototype

void pushGroup(
  cairo_content_t cont
);

Function Context.pushGroup

Temporarily redirects drawing to an intermediate surface known as a group. The redirection lasts until the group is completed by a call to Context.popGroup() or Context.popGroupToSource(). These calls provide the result of any drawing to the group as a pattern, (either as an explicit object, or set as the source pattern).

This group functionality can be convenient for performing intermediate compositing. One common use of a group is to render objects as opaque within the group, (so that they occlude each other), and then blend the result with translucence onto the destination.

Groups can be nested arbitrarily deep by making balanced calls to Context.pushGgroup()/Context.popGroup(). Each call pushes/pops the new target group onto/from a stack.

The Context.pushGroup() function calls Context.save() so that any changes to the graphics state will not be visible outside the group, (the Context.popGroup functions call Context.restore()).

By default the intermediate group will have a content type of CAIRO_CONTENT_COLOR_ALPHA. Other content types can be chosen for the group by using Context.pushGroup(Content) instead.

As an example, here is how one might fill and stroke a path with translucence, but without any portion of the fill being visible under the stroke:

cr.pushGroup();
cr.setSource(fill_pattern);
cr.fillPreserve();
cr.setSource(stroke_pattern);
cr.stroke();
cr.popGroupToSource();
cr.paintWithAlpha(alpha);

Prototype

void pushGroup();

Authors

Johannes Pfau cairoD
Andrej Mitrovic cairoD
cairo team cairo

Copyright

License

cairoD wrapper/bindings Boost License 1.0
cairo LGPL 2.1 / MPL 1.1