BASIC TOOLS:
1. HTML5 Canvas
The following code shows how to place a canvas element on a web page.
The Example: As you can see there are seven lines between the
SCRIPT tags (not couting the empty lines). Here's a basic line-by-line analysis of the example:
Line Number(s) | Explanation |
---|---|
1 | The variable can stores a reference to the canvas object previously defined on the page. |
2 | The variable ctx stores a reference to the context. |
3 | The fillStyle attribute is set to a shade of blue. |
4 | Using the fillRect(x,y,width,height) method the entire canvas area is painted with the current color. |
5 | The font attribute is set to a specific size and font type. |
6 | The fillStyle attribute is set to black. |
7 | The fillText(str,x,y) method is used to render a string within the canvas area. |
Create a new web page and on it display a modified version of the JavaScript applet shown on this page. Change the background color to yellow. Change the font color to red. Change to a slightly smaller font size and display two lines, both centered in the canvas area. The top line should say, "Hello, my name is" and the bottom line should be your first and last name.