ccontext:PushGroup()
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
ccontext:PushGroup() / ccontext:PopGroup(). Each call pushes/pops the new
target group onto/from a stack.
The ccontext:PushGroup() function calls ccontext:Save() so that any
changes to the graphics state will not be visible outside the
group. The pop_group functions call ccontext: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 ccontext:PushGroupWithContent() 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) |