Python library for generative art

Coordinate system example

In this section we look at the default coordinate system used by generativepy.

Simple generativepy drawings are usually created with a single Python script that calls the generativepy module (which must be installed on your system). You will also need a couple of other modules installed (pycairo and numpy), see downloading.

Example script

We will use the code from the simple drawing example:

from generativepy.drawing import makeImage
from generativepy.color import Color

def draw(canvas):
    canvas.rect(50, 100, 300, 200)

makeImage("simple-drawing.png", draw, pixelSize=(500, 500),

It draws a rectangle at pixel position (50, 100), with a width of 300 pixels and a height of 200 pixels:

The grey rectangle is the full image (500 pixels square). By default, generativepy measures positions from the top left.

So when we say the blue rectangle is at position (50, 100), what we mean is that the top left-hand corner of the rectangle is:

  • 50 pixels to the right of the top left corner of the image
  • 100 pixels down from the top left corner

As shown, the rectangle is 300 pixels wide and 200 pixels high.

See also