Vector Images

Vector Images

What are vector images?

Whereas bitmap files represent image data using a grid of pixels combined to make a whole picture, vector files store imge data in a completely different manner. Vector files use mathematic formulas to store the details of components of an object (such as shape, size, colour, outline) that combine together to form the final image.

Advantages of vectors

  • Generally smaller files sizes than bitmaps
  • Far more scalable than bitmap images (theoretically inifite)
  • Great for logos, cartoons or other drawn items

Disadvantages of vectors

  • More difficult to learn how to create vector drawings and use vector drawing software
  • Not appropriate for use when storing digital photos as the data is too complex.


Vector Images in Python

Vector Images using Python

You can use the drawSvg package in Python to create your own Scaled Vector Graphics files in order to illustrate how vectors work (You’ll need to execute pip3 install drawSvg in the terminal/CMD console to install the module first).

Here is the Python code to draw a rectangle.

import drawSvg as draw

d = draw.Drawing(200,100, origin='center', displayInline = False)

d.append(draw.Rectangle(0,0,40,50, fill = '#ff00ff'))



More examples of shapes and drawing techniques can be found here. 


Can you write a Python Program that draws a picture of a house (and maybe some clouds in the sky) using drawSvg?