Created generic functions to support drawing to the canvas.