Member-only story
Vector drawing with generativepy
This chapter covers the basics of creating vector images with generativepy. It provides a simple template for drawing vector images using the drawing
module. It also shows how to use the geometry
module to draw various shapes, and how to style those shapes.
generativepy can also be used to create bitmap images, NumPy-based images, 3D images, and videos. These will be covered in later tutorials, but the basic process is similar in all cases.
Vector images
A computer image is often stored as a 2-dimensional array of pixels, where each pixel can be any colour. This is called a bitmap image.
However, when we use vector graphics we don’t usually specify the colours of individual pixels. Instead, we work at a higher level, defining shapes in the image. These can be simple shapes, such as rectangles, or more complex shapes, such as text characters.
When we use generativepy in vector mode, our program simply specifies a shape and specifies how it should be filled and outlined. The generativepy library is responsible for deciding the colour of each pixel.
The end result is still a bitmap image file, in PNG format. However, the way your code describes the image works at the level of shapes rather than pixels, which is more useful for mathematical images.
In this article, we will look at:
- The generativepy coordinate system
- Drawing basic shapes (lines…