class luma.core.render.canvas(device, background=None, dither=False)[source]

Bases: object

A canvas returns a properly-sized PIL.ImageDraw object onto which the caller can draw upon. As soon as the with-block completes, the resultant image is flushed onto the device.

By default, any color (other than black) will be generally treated as white when displayed on monochrome devices. However, this behaviour can be changed by adding dither=True and the image will be converted from RGB space into a 1-bit monochrome image where dithering is employed to differentiate colors at the expense of resolution. If a background parameter is provided, the canvas is based on the given background. This is useful to e.g. write text on a given background image.