Creating the new
canvas element is easy.
Check out how simple this is:
<!DOCTYPE html> <html> <head> <title>Canvas</title> <meta charset="utf-8" /> </head> <body> <canvas id="FirstCanvas" width="800" height="600"> <!-- Fallback code goes here --> </canvas> </body> </html>
Of course, we can use whatever height and width dimensions we need, but that simple set of tags is what we need to start.
You're probably thinking we could use CSS to control the height and width, but resist that temptation. Because the new
canvas element contains a 2d rendering context, that approach can cause unpredictable behavior.
Next, we'll call the new