Cairo.Group
Temporary redirection of drawing commands to intermediate surfaces.
Temporarily redirects drawing to an intermediate surface known as a group. The redirection lasts until the group is completed by a call to Cairo.Group.pop
or Cairo.Group.pop_to_source
. 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 Group.push
/Group.pop
. Each call pushes/pops the new target group onto/from a stack.
The Group.push
function calls save
so that any changes to the graphics state will not be visible outside the group, (the Group.pop
function call restore
).
val pop : context -> Pattern.any
Terminates the redirection begun by a call to Cairo.Group.push
and returns a new pattern containing the results of all drawing operations performed to the group.
The Group.pop
function calls Cairo.restore
(balancing a call to Cairo.save
by the Group.push
function), so that any changes to the graphics state will not be visible outside the group.
val pop_to_source : context -> unit
Terminates the redirection begun by a call to Group.push
and installs the resulting pattern as the source pattern in the given cairo context.
The behavior of this function is equivalent to the sequence of operations:
let group = Cairo.Group.pop cr in
Cairo.set_source cr group;