0
|
1 |
var canvas = document.getElementById('tutorial');
|
|
2 |
|
|
3 |
// Make sure we don't execute when canvas isn't supported
|
|
4 |
if (canvas.getContext){
|
|
5 |
|
|
6 |
// use getContext to use the canvas for drawing
|
|
7 |
var ctx = canvas.getContext('2d');
|
|
8 |
|
|
9 |
// Filled triangle
|
|
10 |
ctx.beginPath();
|
|
11 |
ctx.moveTo(25,25);
|
|
12 |
ctx.lineTo(105,25);
|
|
13 |
ctx.lineTo(25,105);
|
|
14 |
ctx.fill();
|
|
15 |
|
|
16 |
// Stroked triangle
|
|
17 |
ctx.beginPath();
|
|
18 |
ctx.moveTo(125,125);
|
|
19 |
ctx.lineTo(125,45);
|
|
20 |
ctx.lineTo(45,125);
|
|
21 |
ctx.closePath();
|
|
22 |
ctx.stroke();
|
|
23 |
|
|
24 |
}
|