How does HTML5 get the drawing environment by calling the getContext () method of the canvas object?
This article mainly explains "HTML5 how to get the drawing environment by calling the getContext () method of the canvas object". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how HTML5 obtains the drawing environment by calling the getContext () method of the canvas object".
Get the canvas drawing environment
The code is as follows:
HTML5 / / this function will call function pageLoaded () {/ / to get a reference to the canvas object after the page is fully loaded. Note that the tCanvas name must be the same as the id in the body below var canvas = document.getElementById ('tCanvas'); / / get the 2D drawing environment of the canvas var context = canvas.getContext (' 2d'); / / the drawing code will appear here}