Creating an Image with Pycairo

In this lesson, we will practice making our first 2D image using Pycairo.

Simple image with Pycairo

Every image is divided into two parts:

  • Surface (canvas)
  • Drawing

Let’s first look at the following slideshow to see how it works. First, we will make a 600 by 400 pixel surface. Then, we will make a red rectangle with a length of 240 pixels and a width of 100 pixels. We want this rectangle to start at 150 pixels from the x-axis, and 100 pixels from the y-axis.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy