Utility functions for the HTML5 canvas