Clone of the html5canvas code