diff options
Diffstat (limited to 'examples/script/context2d/scripts/moveto2.js')
-rw-r--r-- | examples/script/context2d/scripts/moveto2.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/script/context2d/scripts/moveto2.js b/examples/script/context2d/scripts/moveto2.js new file mode 100644 index 0000000..021f47b --- /dev/null +++ b/examples/script/context2d/scripts/moveto2.js @@ -0,0 +1,24 @@ +var canvas = document.getElementById('tutorial'); + + // Make sure we don't execute when canvas isn't supported + if (canvas.getContext){ + + // use getContext to use the canvas for drawing + var ctx = canvas.getContext('2d'); + + // Filled triangle + ctx.beginPath(); + ctx.moveTo(25,25); + ctx.lineTo(105,25); + ctx.lineTo(25,105); + ctx.fill(); + + // Stroked triangle + ctx.beginPath(); + ctx.moveTo(125,125); + ctx.lineTo(125,45); + ctx.lineTo(45,125); + ctx.closePath(); + ctx.stroke(); + + } |