Prev Demo
HTML5
>
Lines On Canvas
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html/> <html> <head> <title></title> <meta charset="utf-8" /> </head> <body> <canvas id="Canvas1" width="300" height="200" style="border: 1px solid green;">Canvas is not supported in your browser </canvas> <br /> <input type="button" onclick="DrawLines()" value="Draw Line" /> <script type="text/javascript"> function DrawLines() { // alert(Modernizr.canvas); var context = document.getElementById("Canvas1").getContext("2d"); context.beginPath(); context.moveTo(50, 60); context.lineTo(50, 100); context.lineTo(200, 100); context.lineTo(200, 50); context.lineTo(70, 25); context.closePath(); // optional context.stroke(); } </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output