SolidPattern

In this lesson, we'll learn about `SolidPattern` in Pycairo.

What does SolidPattern do?

A SolidPattern creates a solid color fill. Here is the full code to draw an orange circle on a white background:

Press + to interact
import cairo
import math
# Set up surface
surface = cairo.ImageSurface(cairo.FORMAT_RGB24, 400, 400)
ctx = cairo.Context(surface)
ctx.set_source_rgb(1, 1, 1)
ctx.paint()
# SolidPattern
pattern = cairo.SolidPattern(1, 0.5, 0)
ctx.set_source(pattern)
ctx.arc(200, 200, 100, 0, math.pi*2)
ctx.fill()

The SolidPattern constructor takes three values: r, g, and b, which set the RGB color of the solid fill. The ...