Masking

Learn about the concept of masking in Pycairo.

We'll cover the following...

What is masking?

Masking paints a pattern through a mask, which can be another pattern or surface, such as an image surface.

Masking allows us to use any pattern as a transparency mask on any other pattern.

As we discussed previously, a pattern can be a solid color, gradient, image, or surface with vector content.

There are three stages to this.

First, we create the mask:

radial=cairo.RadialGradient(200, 200, 100, 200, 200, 200)
radial.add_color_stop_rgba(0, 0, 0, 0, 1)
radial.add_color_stop_rgba(1, 0, 0, 0, 0)

The pattern radial is a radial gradient. The center is (200, 200), the inner circle has a radius of 100, and the outer ...