Pycairo RGB Colors

Learn about the RGB colors in Pycairo.

This is how we set an RGB color in Pycairo:

ctx.set_source_rgb(r, g, b)

Here, ctx is the context and r, g, and b control the amount of red, green, and blue in the color. Each color value is a float between 0.0 and 1.0, where 0.0 represents none of that particular color and 1.0 represents the maximum amount of that color. Every possible color in Pycairo is represented by some combination of red, green, and blue.

Get hands-on with 1200+ tech skills courses.