Display Objects

oCanvas changes the way you work with the canvas element. It is a middle layer between you and the native canvas API. Instead of doing all the calls to the drawing methods, you create objects that you add to the canvas, which is a more straightforward process. These objects are called display objects. There are a few predefined display objects bundled with oCanvas, listed below. All of those extend the base display object, which has generic properties and methods that apply to all display objects.

If you want to use the native canvas API, there is a register() method on the display module, which creates a new type of display object, that can be instantiated the same way any other display object is. This is the safest way to use the native API, since it works in a way oCanvas can handle without any problems. You can also draw within the loop function, where the native canvas context is passed as the first argument to your loop function. All drawing that happens outside of this is not really safe, because oCanvas will clear and redraw the canvas and your draw calls are not called after this.