what is the significance of (var ctx=gh.getContext("2d");

10/12/2016 4:01:41 PM

Ritesh Dash

1 Answer

New Answer


`gh` in this case will be a HTML <canvas> element. On its own it can't do much, but if you get a hold of a context, you can use that (your `ctx` variable) to draw stuff onto the canvas. "2d" isn't your only option, there are also other contexts you can get: "webgl", "webgl2", and "bitmaprenderer" are your other options, currently. All of those contexts will have different methods and are used for different things!