Prev Demo
Line Cap
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <canvas id="mycanvas" width="680" height="200"> </canvas> <script> var canvas = document.getElementById("mycanvas"); var context = canvas.getContext("2d"); context.beginPath(); context.moveTo(100, canvas.height /2-50); context.lineTo(canvas.width, canvas.height / 2 - 50); context.lineWidth = 10; context.strokeStyle = 'pink'; context.lineCap = 'square'; context.stroke(); context.beginPath(); context.moveTo(200, canvas.height / 2); context.lineTo(canvas.width - 200, canvas.height / 2); context.lineWidth = 0; context.strokeStyle = 'green'; context.lineCap = 'round'; context.stroke(); </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output