Getting a context
The canvas API is accessed via a canvas context object. You get the context by calling the getContext()
method of the <canvas>
element, passing in a string parameter that defines the type of the context you want:
var context = $("canvas")[0].getContext("2d");
The only valid context type parameter you can pass into getContext()
at this time is "2d"
. This begs the question, "Is there a 3D context?" The answer is no, there is not. But we can always hope for one in the future.