var ctx = fc(function(deltaTime) { // render stuff into ctx // `this` is also ctx for ease of use});// put the canvas into a "render only when dirty" modectx.stop();// to schedule a new framectx.dirty();// subsequent calls to dirty in the same tick will have no effectctx.dirty();// to restart the auto-render modectx.start();// to fill the entire canvas with a colorctx.clear('red');// last but not least, to access the canvasctx.canvas// only render when dirtiedvar ctx = fc(function(deltaTime) {}, false);// get the current 3x3 transformation matrix (2d only)var ctx = fc(function() { ctx.translate(10, 100) console.log(ctx.getTransform())})// transform a point from screen to world spacevar ctx = fc(function() { ctx.translate(10, 100) var incoming = [10, 10] // could be a the mouse pos or similar var result = [0, 0] ctx.pointToWorld(result, incoming) // project the point into the world console.log(result)})
note: fc will render one time even if autorun is set false. During this initial render deltaTime will be 0