added support for both canvas2D and WebGL