RadialGradient

Learn how to use the RadialGradient pattern in Pycairo.

Radial gradients

A RadialGradient is circular in appearance. It is created like this:

pattern=RadialGradient(cx0, cy0, r0, cx1, cy1, r1)

The radial gradient is defined by two circles:

  • Circle0, with centre (cx0, cy0) and radius r0
  • Circle1, with centre (cx1, cy1) and radius r1

Similar to linear gradients, these coordinates and lengths are defined in userspace, using whatever transforms are in place at the time that the RadialGradient is called.

In most cases, Circle0 is contained within Circle1, because this creates the most useful effects but, in fact, the two circles can be located anywhere.

A simple case occurs when Circle0 has a radius of 0 (that is, it is a point) and is located at the center of Circle1, like this:

Get hands-on with 1200+ tech skills courses.