Creating an Image with Pycairo
In this lesson, we will practice making our first 2D image using Pycairo.
We'll cover the following...
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.
Here is the step-by-step guide for making a very simple PNG image, containing a single rectangle, using Pycairo.
Setting up a surface with Pycairo
First, we will create a surface to draw on. A surface is an object where we create our ...