GenerativePy

Python library for generative art

makeImage()

makeImage() is a function that creates a single PNG image using a supplied draw function. It is part of the drawing module.

Function

makeImage(outfile, draw, pixelSize, width=None, height=None,
              startX=0, startY=0, background=None, channels=3, orientation=OR_IMAGE)
Parameter Type Description
outfile string The full path of the png file you want to create. For example output.png to create a file in the current folder, or c:\images\output.png to create a file in the images folder of C: drive.
draw function A function object that will be called to draw the image. The function object must accept a single parameter of type Canvas that will be used to draw the image.
pixelSize (int, int) A tuple of two integers, xSize and ySize that sets the pixel width and height of the output image.
width float Sets the width in user coordinates. Optional, see user coordinates.
height float Sets the height in user coordinates. Optional, see user coordinates.
startX float Sets the horizontal (x) start in user coordinates. Optional, see user coordinates.
startY float Sets the vertical (y) start in user coordinates. Optional, see user coordinates.
background Color Specifies the background colour of the image. Optional, defaults to black.
channels int 3 creates an RGB image, 4 creates an RGBA image, see notes below. Optional, defaults to 3.
orientation int Specifies the vertical orientation of the image, see user coordinates. Optional, defaults to drawing.OR_IMAGE.

Notes

With channels set to 3 (the default) this will create an RGB image. The background of an RGB image is always fully opaque, but you can still use transparency with any items you draw on top of the background.

When channels is set to 4, and RGBA image will be created. It is then possible to make the background either fully or partially transparent (by setting the background colour with an A value of less than 1).

Example

See Simple Drawing example for an example of the makeImage function.

See also