Canvas.draw() - newo2001/HTML5-Canvas-Wrapper GitHub Wiki

Description

Performs the user-defined part of the canvas' update routine.

Syntax

canvas.draw();

canvas (Canvas)

The instance of the canvas class to draw.

Example

let canvas = new Canvas(new Vec2(50, 50), new Vec2(100, 200));

canvas.draw = function() {
  canvas.clear();
  canvas.rect(new Vec2(200, 200), new Vec2(100, 100));
  canvas.swapBuffers();
}
Draws a rectangle to the canvas every game tick.

Notes

  • This function should not be called. Instead, you should override this function and add you own implentation. This is the function where you place all of your code that you want to be ran every game tick. This function is then called by the API when a new gametick is processed.
⚠️ **GitHub.com Fallback** ⚠️