In this example, we have two rectangles. A big one and a rotating one. The big rectangle continuosly shrinks and grows. The smaller one is rotating. We apply a intersect set operation on both rectangles. The area that is inside both rectangles is painted
in black color. Note, that the intersection is not a perfect rectangle. To make it simpler, we approximate the area to a rectangle.

static gboolean xdirection = TRUE;

This variable determines the direction, in which the big rectangle is moving.

Mask

Before the source is applied to the surface, it is filtered first. The mask is used as a filter. The mask determines, where the sourse is applied and where not. Opaque parts of the mask allow to copy the source. Transparent parts do not let to copy the source
to the surface.