Jakob Jenkov Last update: 2014-06-15 |
canvas
element with width
set to 500, height
set to 150, and style
set to a 1 pixel border with color #cccccc
.canvas
element is ignored, if the browser supports the HTML5 canvas element. If the HTML5 canvas element is not supported, the text will probably be displayed as ordinary text by the browser.div
element).drawExamples()
.drawExamples()
function obtains a reference to the canvas element using document.getElementById()
function, passing the id
of the canvas element, as defined in the declaration of the canvas element.drawExamples()
function obtains a reference to a 2D context from the canvas element, by calling canvas.getContext('2d')
on the canvas element obtained earlier.drawExamples()
function calls various drawing functions on the 2D context object, which results in graphics being drawn on the canvas.