Name
Canvas.getContext( ): return a context for drawing on the canvas
Synopsis
CanvasRenderingContext2D getContext(StringcontextID)Arguments
-
contextID This argument specifies the type of drawing you want to do with the canvas. Currently the only valid value is “2d”, which specifies two-dimensional drawing and causes this method to return a context object that exports a 2-D drawing API.
Returns
A CanvasRenderingContext2D object with which you can draw into the Canvas element.
Description
Returns a context representing the type of context to use in drawing. The intent is to provide different contexts for different drawing types (2-D, 3-D). Currently, the only one supported is “2d”, which returns a CanvasRenderingContext2D object that implements most of the methods used by a canvas.
See Also
CanvasRenderingContext2D
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access