The kontra library object. Typically you will call kontra.init() as the first thing and give it the canvas to use. This will allow all kontra objects to reference the canvas when created.


Table of Contents


The main game canvas. By default, all kontra objects will use this canvas.


The main game context. By default, all kontra objects will render to this context.


canvas {string | HTMLCanvasElement}
The canvas for kontra to use. Can either be the id of the canvas element or the canvas element itself. Defaults to using the first canvas element on the page.

Initialize the library and set up the canvas. You should call this function first before creating any kontra objects.